Cut code comments to contracts, traps and pointers #101
Labels
No labels
blocked
bug
decision
duplicate
enhancement
help wanted
invalid
landed?
question
ready-to-merge
stale
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/archetypes#101
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Cut the comments in this repository's Nix and shell code to the three things a comment is for, a contract a caller relies on, the trap the obvious alternative falls into, and a pointer to where the long version lives, and move everything else out or delete it, so a reader gets the rule without the story and the rule cannot rot when code moves.
Primary goals:
nix.mdor another memory topic file, or to the issue it cites, and the comment becomes the pointer.Current state and specifics
Measured on master after allod/archetypes#93, #97 and #98 landed, across
*.nixand*.shoutsidechecks/fork-fixture/: 2766 comment lines in this repository, of about 4600 across the workspace. Of the workspace total, 155 lines point by location ("above", "below"), 92 narrate history ("used to", "They were", "no longer", or a fix round), 53 cite an issue inline, and 13 files retell the allod/archetypes#88 story in their own words. The longest blocks are 64 lines atchecks/consumed-file-carve-out.nix:103, 52 atmodules/public-host.nix:1, 50 atmodules/host-user-credentials.nix:1, 49 atchecks/dev-forge-opt-out.nix:164, and 47 to 48 at the heads ofcheck-selftest.shandfork-safety.sh. The builder arguments innix/builders/dev.nixandnix/builders/hypervisor.nixeach carry a paragraph where a name and a one-line contract would do.Not every long block is rot.
modules/public-host.nix's header is the design record of why there is a module and not a builder, and themkDefault/hostPlatform,tryEval/abortandsecrets-shadowing notes are traps a competent reader walks into because the code looks like it could be simpler; principle 13 says those lessons are not repurchased. The test for a block is not its length but whether a good reader, without it, would plausibly change the code to something wrong. If yes, it stays as the trap plus a pointer. If it explains what, or history, or something a name could say, it goes.The rule itself belongs in
writing.mdin allod/memory, as a short section on code comments, so it outlives this pass; that PR opens first and this issue's PRs cite it.Scope
In scope: every
*.nixand*.shfile in this repository outsidechecks/fork-fixture/, as one PR per area (nix/builders/,modules/,checks/, the two wrapper scripts and their selftests) so each diff is reviewable. Each PR carries two mechanical gates: zero non-comment lines changed, shown by filtering the diff, and every machine's and every check's derivation path unchanged, by the capture allod/archetypes#93 used; comments inside Nix indented strings are part of a derivation, so those are edited only where the check's own build is the witness, and the PR says which. Each PR gets one cold review asking one question per deleted block: what wrong edit was it preventing, and what prevents it now.Not in scope: renaming or restructuring code to make a comment unnecessary, which is a code change with its own issue, and the other repositories, which follow once the rule and the gates have been exercised here.
Refs allod/archetypes#93
The PR set for this issue is open. One decision changed the shape the issue sketched: five archetypes PRs, not four. The three shell scripts under
modules/are shipped into dev machines, so their comment edits move theallod-devtoplevel and thepi-provider-lifecyclecheck; they went into their own PR with the executing witness named, so the modules PR proper keeps every derivation path identical.writing.md, plus thenix.mdentry the builders PR points at.check.sh,fork-safety.shand their selftests. Derivation paths identical; both selftests green.nix/builders/,flake.nix,nix/vm-facts.nix,nix/build-zola-site.nix. Identical.modules/*.nix. Identical.modules/*.sh. Two derivations move, named in the body;sync-pr-branch-protection.shhas no check that executes it, before or after.checks/. Ten checks' derivations move, named in the body, each rebuilt green; this one carriesCloses.Each PR passed the comment-only gate (Nix parse tree and comment-stripped shell diffed against master), the derivation-path capture,
./check.sh, and one coldgpt-5.6-terrareview asking per deleted block what wrong edit it prevented and what prevents it now; the reviews found four real defects across the set, all fixed before the PRs opened. Workspace-wide comment lines in this repository: 2766 to about 2130. The rot the pass could not reach, assertion and error message strings that point by position, is allod/archetypes#106.