Skip to content

canon(principles): add type-contract-plus-adversarial-review#136

Merged
klappy merged 2 commits into
mainfrom
feat/canon-type-contract-plus-adversarial-review
Apr 24, 2026
Merged

canon(principles): add type-contract-plus-adversarial-review#136
klappy merged 2 commits into
mainfrom
feat/canon-type-contract-plus-adversarial-review

Conversation

@klappy
Copy link
Copy Markdown
Owner

@klappy klappy commented Apr 24, 2026

Summary

Adds canon/principles/type-contract-plus-adversarial-review.md as a tier-2 canon principle. Graduates a paired pattern that was manually enforced across the aquifer-mcp J-002 → H11b session (PRs klappy/aquifer-mcp#17 through #20).

The principle: When a function's correctness depends on reporting its own incompleteness honestly, a type-system contract at the API boundary is necessary but not sufficient. The type forces every caller to acknowledge the incompleteness axis; adversarial review catches the implementation lying about that axis. Either defense alone ships silent-truth-loss bugs. The pair collapses to a single line of defense when the build pipeline bypasses the type system (esbuild transpile-only), at which point adversarial review is the only thing standing between compile and production.

Three Deciding-Argument Recurrences

  1. PR fix(entity): bound bootstrap fanout to prevent Worker OOM (closes J-002, J-003) aquifer-mcp#18BootstrapEntityResult + 9 Bugbot findings including 3 silent-truth-loss bugs (complete=true could ship under contract-violating conditions). The paired pattern was the reason those bugs did not ship.
  2. PR feat(entity): H11b — partial data with transparency + background warm aquifer-mcp#20FanOutEntityResult + High-severity ctx ReferenceError that esbuild transpile-only compiled cleanly and would have shipped as production crash on every cold-cache entity search. Bugbot was the sole defense.
  3. esbuild-transpile-only boundary condition (J-005 generalization) — orchestrator's load-bearing decision to treat Bugbot as the sole defense (not secondary) across the remaining session PRs. Distinct deciding-argument recurrence because the decision was about the pair itself.

Under the operator's manual-enforcement reading of the graduation test, all three cleared the bar in one session.

Writing Canon Checklist

  • Title test — names concept and stance.
  • Blockquote test — full compressed argument; independently actionable.
  • Metadata test — full frontmatter schema compliance per klappy://canon/meta/frontmatter-schema.
  • Summary test## Summary — The Pair Is Load-Bearing, Not the Parts is self-contained.
  • Header scan test — headers tell the document's argument in sequence, descriptive subtitles throughout.
  • No buried claims — every key assertion present at a higher tier.
  • Axiom space test — amplifies Axioms 2 and 4; does not crowd them out.
  • Ghost writer test — em-dash density 0.30 vs reference 0.24 (20% over, within tolerance); no formulaic transitions; no negation parallelism.

Release-Validation-Gate Disposition

Per klappy://canon/constraints/release-validation-gate:

Rule 1 (no merge with active reviews): will wait for Bugbot to reach completed status; dispositioning every finding before merge.

Rule 2 (independent fresh-context validation): Rule 2's trigger list is scoped to oddkit worker surface (orchestrate.ts, bm25.ts, governance file reads, response envelope). A new canon doc at a new URI is ambiguous under that list. Per the gate's "ambiguous cases default to load-bearing" clause, dispatching a fresh-context Sonnet 4.6 validator via Managed Agents before merge. Validator findings will be dispositioned in a closeout comment on this PR.

Rule 3 (canon wins over session artifacts): the handoff that proposed this graduation recommended promoting only one candidate principle (not two). The operator reframed toward manual-enforcement-as-deciding-argument, which graduated this and the sibling partial-data principle. Canon rule (graduation test) was honored; handoff recommendation was overridden by operator direction; audit trail lives in the graduation ledger on the sibling PR.

Companion Artifacts

  • Sibling PR: feat/canon-partial-data-with-transparency-and-background-warm graduates the second principle and carries the session graduation ledger (odd/ledger/2026-04-24-aquifer-session-principles-graduated.md). The two PRs cross-reference each other by URI; URIs will resolve once both merge.

Not In Scope

  • observe-before-you-fix-the-wrong-axis — one explicit recurrence only; held for future session graduation.
  • aquifer-mcp project carry-forwards (H15 observability monitoring, H16 bootstrap deletion, H12 fan-out audit) remain at the source project.

Note

Low Risk
Low risk because this PR only adds documentation and does not change runtime code or behavior.

Overview
Introduces a new canon principle doc, canon/principles/type-contract-plus-adversarial-review.md, which formalizes a paired requirement: typed boundary contracts for partial/failed results plus adversarial review of implementations against those contracts.

The document defines what qualifies as a trust boundary and adversarial review, and records three manual-enforcement recurrences (including the esbuild transpile-only type-bypass case) as justification for graduating the principle.

Reviewed by Cursor Bugbot for commit fd6f0ea. Bugbot is set up for automated code reviews on this repo. Configure here.

Graduates the paired pattern observed across the aquifer-mcp J-002 -> H11b
session (PRs klappy/aquifer-mcp#17 through #20) as tier-2 canon.

Three deciding-argument recurrences:
1. PR #18 (BootstrapEntityResult) - Bugbot caught 3 silent-truth-loss bugs
   where complete=true could ship under contract-violating conditions.
2. PR #20 (FanOutEntityResult) - Bugbot caught High-severity ctx ReferenceError
   that esbuild transpile-only would have shipped as production crash.
3. esbuild-transpile-only boundary condition - orchestrator's load-bearing
   decision to treat Bugbot as sole defense (not secondary) in pipelines
   that bypass the type system.

Under the manual-enforcement reading of the graduation test (multiple PRs,
adversarial review dispositioned each time, principle cited as reason for
architecture choices), all three cleared the bar in one session.

Writing Canon checklist: title names concept + stance; blockquote contains
full compressed argument; Summary section is self-contained; headers are
descriptive and tell the document's story on scan; no formulaic transitions;
em-dash density within 20% of reference canon (0.30 vs 0.24 baseline).

Frontmatter schema: eight universal fields present; tier unquoted integer;
booleans unquoted (none in this doc); date unquoted; simple identifiers
unquoted; strings with special characters quoted.

Release-validation-gate disposition: this PR added a new canon doc under
canon/principles/. The gate's 'governs' clause includes klappy.dev canon PRs
that change governance docs the worker reads at runtime. Rule 2's trigger
list is worker-surface-specific; a new canon doc at a new URI is ambiguous
under that list, and the gate's 'ambiguous cases default to load-bearing'
clause binds. Bugbot dispositioned below; fresh-context Sonnet validator
dispatch recorded separately in the closeout PR comment before merge.

Companion graduation ledger ships in the partial-data PR to ensure all
URI cross-references resolve at the time of the ledger's merge.
B1: Removed odd/ledger/2026-04-24-aquifer-session-principles-graduated.md
from derives_from. The canon principle does not epistemically derive from
the session ledger documenting its own graduation; the direction is the
reverse. Validator correctly flagged this as an unacknowledged broken
reference (the ledger ships with PR #137, not this branch).

B2: Restructured the inline 9-field listing on the Recurrence 1 paragraph
from em-dash parenthetical to parens. Dropped em-dash density from 0.30
to 0.28 (closer to existing canon baseline ~0.24-0.25). The reframe also
aligns with the operative ai-voice-cliches signal (paragraph clusters,
not ratios) — no remaining narrative em-dash clusters.

N6: Fixed typo 'dispositon' -> 'disposition' on line 83.

W1/W2 waived: Bold-then-explain and scope-limiting 'Does NOT Say'
section are established canon precedent (contract-governs-handoff-drift,
cache-fetches-and-parses). Validator 2 on the sibling PR confirmed these
are structural governance patterns, not the conversational AI-tell that
ai-voice-cliches targets.

W3 (Recurrence 3 unverifiable without ledger) resolves when PR #137
merges and the ledger goes live.
klappy pushed a commit that referenced this pull request Apr 24, 2026
Canon doc: Removed ledger path from derives_from for same epistemic
reason as PR #136: the canon principle does not derive from the session
ledger documenting its graduation. Direction is the reverse.

Ledger: Updated session_span from '2026-04-24' to '2026-04-24 closed'
to align with frontmatter-schema example format ('YYYY-MM-DD closed' or
'YYYY-MM-DD to YYYY-MM-DD'). Validator flagged W-B1 as schema-example
conformance; this session is in fact closed at the canon-promotion stage.

Other validator warnings dispositioned in PR closeout comment:
- W-A1 (em-dash methodology): operative signal per ai-voice-cliches is
  paragraph clusters, not ratios; only 1 genuine narrative cluster found,
  within tolerance.
- W-A2 ('Does NOT Say' negation cluster): validator agreed this is
  scope-limiting governance, not conversational AI-tell. Waived.
- W-A3 (forward ref to type-contract): resolves when sibling PR #136 merges.
- W-A4 (Related Canon + See Also overlap): established canon precedent
  (contract-governs-handoff-drift, cache-fetches-and-parses use both
  sections). Waived.
- W-B2 (forward refs in ledger Related Canon not labeled): low priority;
  'The Canon PRs' section already discloses the forward-reference nature.
@klappy
Copy link
Copy Markdown
Owner Author

klappy commented Apr 24, 2026

Closeout — Release-Validation-Gate Disposition

Rule 1 — Bugbot

Original commit 2c40a8d: Bugbot completed conclusion=success, 0 findings, mergeable_state=clean. Satisfied.

Follow-up commit fd6f0ea (validator fixes): Bugbot re-running. Will not merge until completed with acceptable conclusion.

Rule 2 — Independent Fresh-Context Validator

Dispatched Sonnet 4.6 validator via Managed Agents (session sesn_011CaMtQCYU9xpdUcREMyH6s) against commit 2c40a8d. Validator ran under a clean agent system prompt with full oddkit MCP access, pulled live governance docs, verified claims against GitHub source data, and reported.

Verdict: PARTIAL — 2 blockers, 3 warnings, 6 notes. All findings now dispositioned.

Blockers — Fixed in fd6f0ea

B1 — derives_from forward reference to non-existent ledger file

  • Validator: odd/ledger/2026-04-24-aquifer-session-principles-graduated.md listed in derives_from but lives on sibling PR canon(principles): add partial-data-with-transparency-and-background-warm + graduation ledger #137 branch only; not acknowledged as forward reference in PR body.
  • Disposition: Fixed. Removed ledger path from derives_from. The canon principle does not epistemically derive from the session ledger documenting its own graduation — direction is reverse. This was a real error; the validator's catch was correct.

B2 — Em-dash density self-report inaccurate (0.30 claimed, 0.34 actual)

  • Validator: specific driver was inline 9-field listing on line 67.
  • Disposition: Fixed. Restructured the 9-field parenthetical from em-dash to parens. Density now 0.28 (~15% over existing canon baseline 0.24-0.25, previously 20% over). Also operationally aligned with the ai-voice-cliches constraint's actual operative signal (paragraph clusters, not ratios).

Warnings — Waived with Reasoning

W1 — Bold-then-explain pattern (14 instances, 4 sections)

  • Disposition: Waived. Established canon precedent. klappy://canon/principles/contract-governs-handoff-drift and klappy://canon/principles/cache-fetches-and-parses both use the same structural pattern at similar density. The pattern is canonical for tier-2 principle docs; flagging it as saturated in one doc while the precedent canon uses it would fork the style without a principle change. If canon voice is to evolve away from this pattern, it should evolve via a writing-canon amendment, not a single-doc rewrite.

W2 — Negation cluster in "Does NOT Say" section (4 consecutive **It does not say X.**) + bold-then-explain

  • Disposition: Waived. Validator 2 on sibling PR canon(principles): add partial-data-with-transparency-and-background-warm + graduation ledger #137 independently reached the opposite conclusion on the same structural pattern, noting: "This is a governance scope-limitation structure, not the conversational 'It's not X. It's Y.' AI-tell the constraint specifically names. No conversational negation parallelism was found in the document." Validator 2's reading is the more precise application of ai-voice-cliches — the pattern specifically named there is conversational AI-tell, which this section is not.

W3 — Recurrence 3 unverifiable without ledger

Notes — All Verified

  • N1 Frontmatter schema: full pass (validator confirmed).
  • N2 Writing-canon Tiers 1–4: all pass.
  • N3 PR body attestations structurally complete (subject to the above dispositions).
  • N4 Recurrences 1 and 2 fully corroborated by validator against GitHub source: 9 Bugbot findings on aquifer-mcp#18 with verbatim match; ctx ReferenceError on aquifer-mcp#20 with exact esbuild diagnosis in finding text.
  • N5 All currently-resolvable cross-references resolve on main.
  • N6 Typo dispositondisposition: Fixed in fd6f0ea.

Rule 3 — Canon Wins Over Session Artifacts

The upstream handoff recommended promoting only one principle. The operator's reframe (manual enforcement across session PRs = deciding-argument recurrence) took precedence and produced this canon promotion. The reframe is an operator directive, not a session-artifact recommendation, so Rule 3 is not triggered. Audit trail lives in the graduation ledger on sibling PR #137.

Validator session references

  • Session: sesn_011CaMtQCYU9xpdUcREMyH6s
  • Agent: agent_011CaMtQAxiNaLfEmpFKnukM
  • Model: claude-sonnet-4-6
  • Environment: env_016RffZyqSdHeb5s3Z6UABw8
  • Full findings: encoded by validator to its session storage

Merge plan

  1. Wait for Bugbot re-run on fd6f0ea to reach completed with acceptable conclusion.
  2. Merge this PR.
  3. Sibling PR canon(principles): add partial-data-with-transparency-and-background-warm + graduation ledger #137 then has no forward references to unmerged work for its canon doc's sibling ref.
  4. Sibling closeout + merge follows.

@klappy klappy merged commit cb16cd0 into main Apr 24, 2026
1 check passed
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