Skip to content

feat(self-audit): check documentation in the other direction too - #491

Merged
sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a
Aug 20, 2026
Merged

sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a

Conversation

@sandstream

@sandstream sandstream commented Aug 20, 2026 •

Copy link
Copy Markdown
Owner

Description

The docs-claims rules prove no doc names something kit lacks. They cannot prove the reverse, and not by oversight — an undocumented command has no doc reference for a forward gate to check. So the gate that exists could never have caught an undocumented enforcement off-switch, which is exactly what was sitting there.

The new undocumented commands rule requires every human-facing command to appear in at least one non-exempt doc, in invocable form. It found 13:

command why it matters
kit hooks uninstall Removes the git-hook enforcement floor. Its installers were documented; the off-switch was not — so a reader auditing "how could the gate be off?" would not find it
kit broker, broker enforce, broker enforce-readiness Mentioned only in ROADMAP.md and CHANGELOG.md, both exempt — a shipped command whose only trace is the roadmap
kit profile × 7 (show, freeze, check, sign, verify, export, import) The whole command surface of what the README calls Pillar 4
kit memory context, kit insight —

All 13 are now in docs/COMMANDS.md, with text taken from each command's own help string rather than written from the outside.

Type of Change

  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Bug fix (two test-integrity fixes, below)

Related Issues

None — found by auditing the docs against the 6.6.5 surface. Same family as #470 and #489: a verdict that reads stronger than its evidence.

Changes Made

  • undocumentedCommands() in src/self-audit-docs.ts. The oracle is a union of two sources, which is the design decision worth reviewing. Each alone hides a real gap: the committed contract lists top-level verbs and no subcommands, so it cannot see kit hooks uninstall; COMMAND_HELP lists subcommands but omits some top-level verbs, so it cannot see kit insight. Measured on this tree — contract-only reported 1 gap, help-only reported 9, neither a superset of the other.
  • Harness-audience verbs are excluded, read from x-kit-audience in the contract rather than a hardcoded list, so a newly added gate verb inherits the exclusion. gate-bash, gate-env, gate-fs, gate-egress are invoked by hook wiring and never typed by a human; requiring them in human docs would manufacture busywork. This also corrects my own first pass, which called those three a documentation gap before I checked how the contract classifies them.
  • Brace form counts — kit hooks {install,add,sync} documents each member. Without it the repo's own house style reads as 40+ false gaps.
  • docs/COMMANDS.md: two new sections (exec-broker runtime posture, traveling profile) plus rows for hooks uninstall, memory context and insight.

Testing

Test Coverage

  • Added new tests
  • Updated existing tests
  • All tests pass (npm test)

Full suite: 4265 tests, 4262 pass, 0 fail, 3 skipped. self-audit: 16 rules, 0 fail, 0 warn. Every commit went through the repo's own pre-commit gate (security scan-staged → build → npm test); no --no-verify.

Mutation-proved: deleting the kit hooks uninstall row from COMMANDS.md turns the rule red naming that exact command; restoring it returns to green.

7 new tests cover the pass case, the fail case, brace form, the harness exclusion, the subcommand the contract cannot express, and didNotRun when no oracle can be read.

Manual Testing

  1. kit self-audit → PASS undocumented commands: all 136 human-facing command(s) appear in the docs (6 harness-audience excluded).
  2. Remove any documented command's row from docs/COMMANDS.md → the rule fails and names it.
  3. documented commands went 730 → 742 refs, all still resolving — the new docs add claims and none of them is drift.

Breaking Changes

None / N/A

Checklist

  • I've read CONTRIBUTING.md
  • My code follows the project's style guidelines
  • I've updated documentation as needed
  • All new code has test coverage
  • All tests pass locally (npm test)
  • No new warnings or errors introduced
  • Commit messages follow conventions
  • No hardcoded secrets or sensitive data
  • Code has been self-reviewed

Two unrelated fixes, both found by this work

Neither was worked around:

  • skips node_modules asserted res[0].status. Adding a row first displaced it, failing a test about something else entirely. The row is now appended, and that assertion looks rows up by name — a positional assertion in a test about an unrelated property is a trap for the next person.
  • The writeCheckDetail failed-write test forced its precondition with chmod 0o500 without checking whether the mode denies this process. root mkdirs straight through it, so the failure path was never exercised and the test reported a working write path as broken. Same guard, same reasoning, as the WAL-sidecar test in 6.6.3: probe with a real write, skip loudly when the mode does not deny. Proven pre-existing on a clean tree before touching it.

Known limit, recorded rather than papered over

The same inverse check is impossible for flags. Nothing in the repo inventories the flags kit accepts: contracts/kit.opencli.json carries x-kit-args-modeled: false on all 71 commands, and the forward rule's flag oracle is a scrape of source literals that also contains flags kit passes to subprocesses (--severity for trivy, --name-only for git, --no-same-owner for tar).

My first attempt at the flag inverse produced "53 of 101 undocumented" from that contaminated set. The number was meaningless and is reported nowhere. Argument modeling in the contract has to come first — that is its own PR, not something to half-do here.

Reviewer Notes

The judgement worth a second opinion is requiring the invocable form (kit profile import) rather than accepting a prose mention. It is deliberate and symmetric with the sibling rule, which extracts kit <command> refs — a command a reader cannot see how to type is not documented. The cost is that a doc discussing a command in prose only still counts as a gap; docs/ENV_FUELING.md mentions "profile import" that way and did not satisfy the rule.

Second: exempt docs (ROADMAP.md = planned surface, CHANGELOG.md = historical record) deliberately do not count as documentation for this rule. That is what surfaced kit broker — shipped, but described only where future and past work live.

🤖 Generated with Claude Code

The docs-claims rules prove no doc names something kit lacks. They cannot prove the
reverse, and not by oversight — an undocumented command has no doc reference for a
forward gate to check. So the gate that exists could never have caught an undocumented
enforcement off-switch, which is exactly what was sitting there.

`undocumented commands` requires every human-facing command to appear in at least one
non-exempt doc, in invocable form. It found 13: `kit broker` plus its two subcommands,
all seven `kit profile` subcommands, `kit insight`, `kit memory context`, and
`kit hooks uninstall` — whose installers were documented while the off-switch for the
git-hook enforcement floor was not. All 13 are now in docs/COMMANDS.md, with text taken
from each command's own help string rather than written from the outside.

THE ORACLE IS A UNION, and that is the design decision worth reviewing. Each source
alone hides a real gap: the committed contract lists top-level verbs and no subcommands,
so it cannot see `kit hooks uninstall`; `COMMAND_HELP` lists subcommands but omits some
top-level verbs, so it cannot see `kit insight`. Measured on this tree: contract-only
reported 1 gap, help-only reported 9, and neither was a superset of the other.

Harness-audience verbs are excluded — `gate-bash`, `gate-env`, `gate-fs`, `gate-egress`
are invoked by hook wiring and never typed, so requiring them in human docs would
manufacture busywork. That exclusion reads `x-kit-audience` from the contract rather than
a hardcoded list, so a new gate verb inherits it. This also corrects my own first pass,
which called those three a documentation gap before I checked how the contract
classifies them.

Brace form counts (`kit hooks {install,add,sync}` documents each member); without it the
repo's own house style would read as 40+ false gaps.

Mutation-proved: deleting the `kit hooks uninstall` row from COMMANDS.md turns the rule
red naming that exact command; restoring it returns to green. 7 new tests cover the pass
case, the fail case, brace form, the harness exclusion, the subcommand the contract
cannot express, and didNotRun when no oracle can be read.

Two unrelated things fixed rather than worked around, both found by this work:

- `skips node_modules` asserted `res[0].status`, so adding a row first displaced it. The
  row is now appended, and that assertion looks rows up by name — a positional assertion
  in a test about something else is a trap for the next person.
- The `writeCheckDetail` failed-write test forced its precondition with `chmod 0o500` and
  never checked whether the mode denied this process; root mkdirs through it, so the test
  reported a working write path as broken. Same guard as the WAL-sidecar test in 6.6.3.
  Proven pre-existing on a clean tree first.

KNOWN LIMIT, recorded rather than papered over: the same check is impossible for flags.
Nothing inventories the flags kit ACCEPTS — the contract says `x-kit-args-modeled: false`
on all 71 commands, and the forward rule's flag oracle is a source scrape that also
contains flags kit passes to subprocesses (`--severity` for trivy, `--name-only` for
git). My first attempt at the flag inverse produced "53 of 101 undocumented" from that
contaminated set; the number was meaningless and is reported nowhere. Argument modeling
has to come first.

self-audit: 16 rules, 0 fail, 0 warn.
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit a933695 into main Aug 20, 2026
19 checks passed
@sandstream
sandstream deleted the claude/web-kit-status-sync-p6fg9a branch August 20, 2026 07:09
sandstream added a commit that referenced this pull request Aug 20, 2026
Minor, not patch: `kit` now REJECTS a flag it does not accept, on every command.
Nothing documented stops working — the flag surface is generated from the source
and its drift test keeps it that way — but an invocation that silently did
nothing now exits 1, and a script that passed a flag kit ignored will notice.
That deserves a minor.

The section: unknown flags rejected from a declared surface (#488), the union
view over every sealed audit log (#470), documentation checked in both
directions (#491), the git-hook floor reporting where it is and whether it can
fail (#496, #497), triage's pip path no longer scoring higher for running fewer
probes (#489), and `kit add --list` listing adapters instead of trying to
provision one called "--list".

Dated the day it ships, not in advance: 6.6.3 was dated five days early and went
stale twice before it went out. The date claims when a version SHIPPED.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants