Repository navigation
Make Threat Modeling and Reuse a Design Step, and Give Review a Design Lens #2516
Description
Problem
#2507 landed "Trust Boundaries and Hardening Effort", which tells a session and a reviewer how much hardening an input earns. Two gaps remain, and both burn the same budget the rule exists to save.
- The rule is applied at review and triage, not at design. Nothing asks a session to model the threat before it writes code. So a change is built first, hardened by habit, and the hardening is declined afterwards, one review round at a time. The rule saves the issue but not the work that preceded it.
- Nothing asks a session to reuse before it builds, or to consolidate once a pattern repeats. The only reuse rule is the "Contracts state what, not how, and favor reuse" principle, and it is scoped to the workflow contract. In HomeAutomation-Config, file manipulation and secret reading each carry careful handling, and sessions re-implemented that handling per script rather than calling one shared helper. The maintainer had to ask for consolidation repeatedly. The hub shows the same shape. Codify: Let the Real Operation Be the Check, and Close a Defect Class Through One Primitive #2431 records a FIFO-blocks-the-read defect fixed three times at three sites before
read_regular_file()closed the class. Canonicalize -Dir in bootstrap.ps1 Before Refusing a Drive or Share Root #2495 asks for a canonicalizing directory check inbootstrap.ps1thathost-setup/menu.ps1already does.
Neither review lens looks for this. fleet-code-review "Review the Change" lists correctness, regressions, security, compatibility, error handling, concurrency, resource lifetime, tests, and contract drift. It has no design dimension, and its "omit pure preferences" item reads a duplication finding as one. local-strict-review's brief adds coercions, races, and platform differences, all hardening lenses. So a correct diff that duplicates an existing helper, or adds a fourth per-site check for a class already seen, passes both reviews clean.
Threat modeling and reuse are ordinary engineering practice, not a hub convention, so they belong with the foundational rules every session reads, not in one repository's memory.
Proposed change
- A
GOVERNANCE.mdsection on design, beside "Trust Boundaries and Hardening Effort", routed from theAGENTS.mdtable. Working title "Design Before Code". It states:- Model the threat before the first edit. Name the change's inputs, the class of each under "Trust Boundaries and Hardening Effort", and the deployment the code runs in. That model sets the hardening budget, so hardening the model does not call for is not written, rather than written and then declined.
- Reuse before building. Search this repository and the hub for an existing primitive before adding one, and extend it rather than add a sibling that does almost the same thing.
- A defect class seen a second time gets one primitive, and every site moves onto it. A per-site check repeats its own platform and edge-case defects at every site, as Codify: Let the Real Operation Be the Check, and Close a Defect Class Through One Primitive #2431 measured. This absorbs Codify: Let the Real Operation Be the Check, and Close a Defect Class Through One Primitive #2431's second lesson.
- Complexity is a cost that needs a reason. Code that answers no requirement and no realistic threat is removed, not maintained.
- Codify: Let the Real Operation Be the Check, and Close a Defect Class Through One Primitive #2431's other two lessons go to
CODESTYLE.mdGeneral, since they are code-level: let the real operation be the check rather than a prediction of it, and a failure message states the error, the path, and the remedy without describing the state the failure left. - Widen the Foundational Principles reuse bullet from the workflow contract to all code, pointing at the new section.
- Give review a design lens.
fleet-code-review"Review the Change" carries the new section as a generated include, the way it carries "Trust Boundaries and Hardening Effort", and adds design to its criteria: logic an existing helper already provides, a per-site fix for a class already seen elsewhere, and hardening or abstraction the threat model does not justify. A finding backed by the new section is not a preference.local-strict-review's brief asks the reviewer, for each new function or helper the diff adds, to search the repository for an existing one doing the same job, bounded to that search, and to report a consolidation finding or an over-hardening finding alongside its correctness findings.- A consolidation finding outside the diff is filed as one issue naming every site, not fixed in the change under review.
- Surface the design step at the moment it applies.
agent-conductgains a trigger at "about to design or start implementing a change", pointing at the new section, so the threat model happens before the code rather than in review. - A repository names its shared primitives.
OPERATIONS.md, beside the trust boundaries it already lists underConfiguration Layout, names the helpers that own file I/O, secret reads, and any other class the repository has consolidated. A session then finds the primitive without searching for it. - The re-triage of the open hardening backlog moved to Re-Triage the Open Hardening Backlog Against the Trust-Boundary and Design Rules #2517, since closing issues on judgment, and working the guard's attended-only tree, is the maintainer's.
Done when
- The new section is in
GOVERNANCE.md, routed fromAGENTS.md, and Codify: Let the Real Operation Be the Check, and Close a Defect Class Through One Primitive #2431's lessons are in their homes, closing Codify: Let the Real Operation Be the Check, and Close a Defect Class Through One Primitive #2431. fleet-code-reviewandlocal-strict-reviewcarry the design lens, andagent-conductsurfaces the design step.OPERATIONS.md's template asks for the shared-primitive list.- Downstream consolidation, such as HomeAutomation-Config's file and secret helpers, is filed in each repository by its own session after the carried change reaches it on resync.
🤖 Generated with Claude Code
Activity
ptr727 commentedon Oct 8, 2026
Adopted, with the documentation choices delegated
The maintainer adopted this issue and left where and how to document it to the implementing session, in their words: "your choice in documenting, i would like to see this get implemented soon". So the outcome below is settled, and an unattended worker may take this issue without parking on it.
The choices, settled here
GOVERNANCE.mdlevel-two section, "Design Before Code", placed directly before "Trust Boundaries and Hardening Effort" and routed from theAGENTS.md"Where the Rules Live" table. It carries the four bullets of item 1 above and nothing more. Keep it short. Each bullet states the rule and its reason, one example at most, since a growing list of cases is what draws review findings round after round.CODESTYLE.mdGeneral as one new subsection, "Operations and Failure Messages": let the real operation be the check, and a failure message states the error, the path, and the remedy without describing the state the failure left.fleet-code-review"Review the Change" carries "Design Before Code" as a generated include beside the "Trust Boundaries and Hardening Effort" include, perskill-lifecycle. Add "design" to the opening criteria sentence, and add one numbered item: report logic an existing helper already provides, a per-site fix for a class already seen, and hardening or abstraction the threat model does not justify, a finding the carried section backs not being a preference.local-strict-reviewadds one line to its brief's "Rules that bind this task": for each function or helper the diff adds, search the repository for one doing the same job, and report a consolidation or over-hardening finding. Its "Paths" bound already permits a read a finding's proof depends on, so that bound stays as it is.agent-conductgains one trigger, "about to design or start implementing a change", pointing at "Design Before Code".OPERATIONS.mdgains the shared-primitive list beside the trust boundaries underConfiguration Layout, in the same shape.host-setup/agent-safety/, which is attended-only. This issue no longer owes it.One pull request carries items 1 through 7, since they state one rule on several surfaces and splitting them leaves the surfaces disagreeing between merges.
Model the Threat and Reuse Before Building, and Give Review a Design …
Promote develop to main: Design Before Code (#2607)