Skip to content

D316 — a module's formatter runs at the commit, from the verb it declares - #594

Merged
napkinstack-agent[bot] merged 5 commits into
mainfrom
d316-module-format-at-commit
Nov 30, 2026
Merged

napkinstack-agent[bot] merged 5 commits into
mainfrom
d316-module-format-at-commit

Conversation

@napkinstack-agent

Copy link
Copy Markdown
Contributor

Workstream

D316 — a module's formatter ran only in CI or at attest (#593). Reported by the consumer project's coordinator (PR #1390: a red cargo fmt --check seen after the push and the verifier's round). Decided after an independent audit (no over-engineering, language-agnostic), for v0.35.5.

What it changes

flowchart LR
  C["git commit"] --> H["pre-commit hook nstack-format<br/>.nstack/format-before-commit.sh"]
  H -->|"nstack absent, or an engine<br/>without the verb"| P["says so: commit goes, CI judges"]
  H --> S["modules whose files are staged"]
  S --> F["nstack format &lt;module&gt;<br/>(commands.format, from its folder)"]
  F -->|0| OK["passes"]
  F -->|"127: its tool not installed"| P
  F -->|"other"| X["FAIL: not formatted: &lt;modules&gt;"]
  MC["Module checks (CI, attest)"] --> B["bootstrap → format → check → test"]
Loading

Legend: format is the formatter's check alone. It writes nothing and builds nothing, in seconds, and it is optional like bootstrap or e2e. The rewriting command belongs in the module's AGENTS.md.

  • modules.OPTIONAL and the CLI gain format.
  • Skeleton:
    • .pre-commit-config.yaml gains the nstack-format hook, and .nstack/format-before-commit.sh is new;
    • check-modules.sh runs format after bootstrap;
    • 09-platform.md §2 gets a verb row and a paragraph;
    • INSTALL.md, the manifest template and the workflow's comment name the verb.
  • The repository's own copies (P3).
  • Register row D316.

What a project receives

  • 2 files changed (.pre-commit-config.yaml, check-modules.sh) and 1 new (format-before-commit.sh), with the handbook pages.
  • Nothing runs until a module declares format.
  • Migration, optional: move the formatter's check out of check into format.

Verification

  • Red first: test_format_hook.py fails 8 of 8 on main.

  • Fresh read-only verifier on d6968bb. Blocking, fixed in 711eea3: the oracle's Module checks sequence lacked format. Also fixed:

    • a staged path that git quotes (café.txt) was skipped: it is now read unquoted;
    • the header claimed untracked files were set aside, which is untrue: it now says what pre-commit sets aside;
    • three guards were untested: a folder another's begins with, a formatter reading stdin, an engine older than the verb;
    • the docs and the help text named format inside check.

    The verifier checked under dash (shellcheck clean) and with real pre-commit: a partly staged file, the first commit, contracts/ and platform/, a rename, a deletion.

  • Then the oracle asked the repository's own config to match the skeleton's (P3), in c3498d6. The hook repositories in run.sh now hold the scripts the hooks run, in 93ea9e4.

  • Mutants killed:

    • exit 127 not spared;
    • no staged filter;
    • no nstack guard;
    • never failing;
    • Module checks without format;
    • no stdin guard;
    • the prefix bug;
    • no old-engine guard;
    • quoted paths.
  • uv run bash platform/tests/run.sh at 93ea9e4: Platform tests: OK.

  • Not changed:

    • a module keeping its formatter in check and adding format runs it twice in CI, a few seconds;
    • cargo installed without rustfmt exits otherwise than 127, so the hook says "not formatted";
    • ADR-0005's list of verbs is history.

DoD

  • Register row D316
  • Prior art on the issue, decided before the change
  • Oracle green on the committed tree

🤖 Generated with Claude Code

napkinstack-agent Bot and others added 4 commits November 30, 2026 04:51
…ares (#593)

Downstream, a red `cargo fmt --check`, inside a module's check, was seen only
at attest, after the push and the verifier's round. A module now declares its
formatter's check as the optional verb `format`; the skeleton's pre-commit
hook nstack-format runs it on the modules whose files are staged, and Module
checks runs it after bootstrap, before check, so the one line is judged at
the commit and in CI alike. Where nstack, an engine without the verb, or the
module's own tool (exit 127) is missing, the hook says so and lets the commit
go: CI judges. Chosen after an independent audit of moonrepo, lefthook,
lint-staged, trunk, Bazel and Pants.

Agent-Session: napkinstack-os-1e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…engine (#593)

The verifier found the oracle's Module checks sequence missing format; a
staged path git quotes (café.txt) skipped; the header's claim on untracked
files untrue; and three guards untested. The oracle expects format; paths are
read unquoted; the header says what pre-commit sets aside; tests cover a
folder another's begins with, a formatter reading stdin, a quoted path and
an engine older than the verb. The manifest template, INSTALL's commands,
09-platform's check row, the CLI's help and platform/README name format.

Agent-Session: napkinstack-os-1e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The repository's .pre-commit-config.yaml is the skeleton's, as the oracle
requires; .nstack/format-before-commit.sh beside fitness-before-push.sh.

Agent-Session: napkinstack-os-1e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…593)

Agent-Session: napkinstack-os-1e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@napkinstack-agent
napkinstack-agent Bot requested a review from a team as a code owner November 30, 2026 04:15
Agent-Session: napkinstack-os-1e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@napkinstack-agent
napkinstack-agent Bot merged commit 2e53703 into main Nov 30, 2026
3 checks passed
@napkinstack-agent
napkinstack-agent Bot deleted the d316-module-format-at-commit branch November 30, 2026 12:03
napkinstack-agent Bot added a commit that referenced this pull request Nov 30, 2026
…s formatter at the commit (#597)

D312 (#590), D313 (#591), D314 (#592), D315 (#596), D316 (#594).

Agent-Session: napkinstack-os-1e

Co-authored-by: napkinstack-agent[bot] <330339777+napkinstack-agent[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <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.

1 participant