Skip to content

snappy-koi-58 - #1638

Merged
briansrls merged 101 commits into
mainfrom
codex/cc1-target-integer-structural-fold
May 4, 2026
Merged

briansrls merged 101 commits into
mainfrom
codex/cc1-target-integer-structural-fold

Conversation

@briansrls

@briansrls briansrls commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

R3 Debt Receipt

Debt paid: ROADMAP Row 46 — production declaration_by_name use in src/v3/compiler/src/emit* is dissolved. Fixed emit-time anchors now resolve once through bootstrap-populated typed caches, and production emit code consumes DeclarationId fields instead of name strings. The regression gate emit_production_code_has_no_declaration_by_name_calls asserts production emit modules do not call Dag::declaration_by_name.

Debt newly found: none. Audit found no caller-provided string lookup sites in production emit. Remaining declaration_by_name calls under emit are test fixture lookups only.

Remaining row: ROADMAP Row 46 closes for production emit. Test-only fixture lookups remain outside the row scope and are excluded by the ratchet's #[cfg(test)] split.

Audit Catalog

All production sites classified as (a) substrate-fixed string / fixed emit-model coproduct:

  • src/v3/compiler/src/emit/fold_method_contract.rs: MethodTemplateContract, fold_method. Role: validate CollectionOps.fold_contract references the canonical method-template contract and registry method. Consumption: contract identity comparison. Migrated to Dag::method_template_contract_decl() and Dag::fold_method_decl().
  • src/v3/compiler/src/emit.rs: MethodEmitTemplate. Role: recover method-template variant labels for target method template dispatch. Consumption: method template label lookup. Migrated to Dag::method_emit_template_decl().
  • src/v3/compiler/src/emit.rs: PatternStrategy.VectorList. Role: parse PatternRealization.strategy. Consumption: constructor identity check. Migrated to Dag::emit_model_variants().pattern_strategy.vector_list.
  • src/v3/compiler/src/emit.rs and src/v3/compiler/src/emit/rust_target.rs: FieldAccess.DirectField, FieldAccess.AccessorMethod. Role: parse field-binding access policy. Consumption: constructor dispatch. Migrated to EmitModelVariants.field_access.
  • src/v3/compiler/src/emit.rs and src/v3/compiler/src/emit/rust_target.rs: ParameterDisposition.Borrowed, ParameterDisposition.Consumed. Role: parse callable parameter disposition rows. Consumption: constructor dispatch. Migrated to EmitModelVariants.parameter_disposition.
  • src/v3/compiler/src/emit.rs, src/v3/compiler/src/emit/rust_target.rs, src/v3/compiler/src/emit/python_target.rs: MemoryModel.{ValueOnly,GarbageCollected,RefCounted,OwnershipBased}. Role: parse target execution memory model. Consumption: target execution binding dispatch. Migrated to EmitModelVariants.memory_model.
  • src/v3/compiler/src/emit.rs, src/v3/compiler/src/emit/rust_target.rs, src/v3/compiler/src/emit/python_target.rs: ScopeModel.{LexicalScoping,DynamicScoping}. Role: parse target execution scope model. Consumption: target execution binding dispatch. Migrated to EmitModelVariants.scope_model.
  • src/v3/compiler/src/emit/rust_target.rs: ReadStrategy.{Borrow,PassByValue} and ConstructStrategy.{CopyOrClone,PassByValue}. Role: parse Rust rendering model. Consumption: borrow/construct rendering policy. Migrated to EmitModelVariants.read_strategy and construct_strategy.
  • src/v3/compiler/src/emit/rust_target.rs: Mutability.{Immutable,Mutable}, Purity.{Pure,Effectful}, Structure.{ExplicitDAG,Arbitrary}, Iteration.{Bounded,Unbounded}. Role: parse Rust source computation model. Consumption: computation-model binding dispatch. Migrated to the corresponding EmitModelVariants groups.

No (b) caller-provided string production sites found. No (c) diagnostic/debug-only production sites need exemption.

Verification

  • cargo test -p v3-compiler emit_production_code_has_no_declaration_by_name_calls -- --nocapture
  • cargo test -p v3-compiler emit_model_variants_populated_after_bootstrap -- --nocapture
  • cargo test -p v3-compiler emit_anchor_cache_populated_after_bootstrap -- --nocapture
  • cargo test -p v3-compiler rendering_model_read_strategy_controls_function_parameter_shape -- --nocapture
  • cargo test -p v3-compiler parameter_dispositions_reject_arity_drift_and_slot_collisions -- --nocapture

Full cargo test -p v3-compiler was also run. It passed 306 lib tests, 9 determinism tests, and 792 integration tests before failing only sg6_regen_lens_cli_smoke_regenerates_named_entry_without_drift because the shared cargo target reused a regen_lens binary compiled from another worktree path (crisp-ibex-569 instead of this worktree). The failure is path-cache environmental, not related to Row 46.

briansrls added 30 commits May 2, 2026 17:19
@briansrls

Copy link
Copy Markdown
Contributor Author

Review metadata

  • Provider / model: openai-pro / gpt-5-5-pro
  • Commit: 87ea799b · Trigger: manual
  • Comparison: main @ 822b6e0d ... codex/cc1-target-integer-structural-fold @ 1d0c99a4
  • Conversation: View conversation

1. Story of the diff

This PR retires the ROADMAP debt row for production emit-time Dag::declaration_by_name(...) lookups by moving those fixed emit-model identities into bootstrap-populated DeclarationId caches (ROADMAP.md:373). The load-bearing mechanism is an expanded EmitAnchorCache plus a new EmitModelVariants cache on Dag, where fixed emit-model coproduct variants such as FieldAccess, MemoryModel, ReadStrategy, and Iteration are resolved once during bootstrap and then exposed through typed Dag accessors (src/v3/compiler/src/dag.rs:2279-2370, src/v3/compiler/src/dag.rs:3170-3173, src/v3/compiler/src/dag.rs:3904-4070).

The emitters then stop walking parent-name/variant-label strings locally and instead compare constructors against the cached IDs, preserving the same fail-closed error shapes when a required declaration is absent (src/v3/compiler/src/emit.rs:2775-2791, src/v3/compiler/src/emit/rust_target.rs:2411-2438, src/v3/compiler/src/emit/python_target.rs:1873-1931). The PR also adds cache-population tests and a regression ratchet that scans production emit* modules for reintroduced .declaration_by_name( calls (src/v3/compiler/src/dag.rs:4455-4539, src/v3/compiler/tests/integration/sg0_census_test.rs:43-76).

2. Invariant categories

  1. LAYER MODEL (substrate vs implementation).

Compliant — the diff touches Dag, but as an implementation-side derived cache rather than a new substrate fact: EmitModelVariants is documented as “cached variant DeclarationIds” populated at bootstrap, and consumers read it through Dag::emit_model_variants() rather than authoring a second semantic source (src/v3/compiler/src/dag.rs:2355-2370, src/v3/compiler/src/dag.rs:3170-3173).

  1. INVARIANTS.md + modeling-discipline.md.

Compliant — single authority / facts-flow-forward are improved: the authoritative declarations are resolved once into emit_model_variants at bootstrap (src/v3/compiler/src/dag.rs:3904-4070), while emit consumers fail closed through existing error carriers when a cached ID is absent instead of defaulting or fabricating (src/v3/compiler/src/emit/rust_target.rs:2434-2438, src/v3/compiler/src/emit/python_target.rs:1892-1893).

  1. CODING.md.

Compliant — the change removes repeated local name-walker helpers from emit code in favor of precise Dag accessors and structured error returns; for example, fold contract validation now asks dag.method_template_contract_decl() / dag.fold_method_decl() and converts missing anchors through ok_or(...) (src/v3/compiler/src/emit/fold_method_contract.rs:15-20), and target emit parsing reads a typed variant cache instead of reconstructing parent/variant lookup logic (src/v3/compiler/src/emit.rs:2775-2791).

  1. TESTING.md.

Compliant — the diff adds both a focused cache-population test for the new bootstrap invariant (src/v3/compiler/src/dag.rs:4455-4539) and a regression/census ratchet that checks the promised production emit boundary directly (src/v3/compiler/tests/integration/sg0_census_test.rs:43-76).

  1. LOCKED DESIGN DECISIONS.

N/A — the diff retires a ROADMAP debt row and adjusts Rust implementation/cache plumbing; it does not modify a thesis/design document or alter a “LOCKED” decision in the reviewed diff (ROADMAP.md:373).

  1. TRACKED vs UNTRACKED DEBT.

Compliant — the only debt movement is tracked and bounded: the ROADMAP row is explicitly retired with the named ratchet emit_production_code_has_no_declaration_by_name_calls (ROADMAP.md:373), and that ratchet is implemented in the same diff (src/v3/compiler/tests/integration/sg0_census_test.rs:43-76). I did not see new TODOs, scaffolds, or temporary bridge shapes in the changed lines.

3. Verdict

APPROVE

The PR moves emit lookup behavior toward single-authority cached substrate identities, keeps absence fail-closed, and includes a direct regression ratchet for the retired debt row. I did not find a diff-citable invariant violation.

@briansrls

Copy link
Copy Markdown
Contributor Author

Review metadata

  • Provider / model: cursor / composer-2
  • Commit: 1d0c99a4 · Trigger: schedule
  • Comparison: origin/main @ 822b6e0d ... review/pr-1638-1d0c99a4 @ 1d0c99a4
  • Thinking: 83s wall

Findings

None. The diff moves fixed emit-model resolution to bootstrap-filled caches on Dag, keeps missing-meta paths as structured emit errors, and adds a census ratchet so production emit*.rs does not call declaration_by_name again. That matches P2 (single resolution at bootstrap, consumers read one cache) and P3 (missing anchors still surface as errors, not silent defaults). New EmitModelVariants / *Variants types are implementation (Rust on Dag), not new substrate DAG types, so the “new enum needs 🟢/🟡/🔴” rule in docs/modeling-discipline.md does not apply to these record-shaped caches.

The new emit_production_code_has_no_declaration_by_name_calls test (src/v3/compiler/tests/integration/sg0_census_test.rs:43+) is source-scanning policy in an existing SG-0 census file; that is consistent with that module’s role and is not a TESTING.md “pin internal layout of the compiler under test” smell in the sense of lens unit tests.

Verdict

APPROVE — Scoped, aligns emit with cached declaration ids and a documented ROADMAP retirement, with a regression guard. No diff-grounded violations of INVARIANTS.md, docs/modeling-discipline.md, CODING.md, or TESTING.md identified.

@briansrls

Copy link
Copy Markdown
Contributor Author

Ready to merge — reviewer sign-off

4 CI green, mergeable, ready-for-review, body has the full audit catalog + R3 debt receipt (4532 chars).

Substantive contributions:

  • All 20+ production declaration_by_name sites in src/v3/compiler/src/emit* migrated to bootstrap-populated typed caches (EmitAnchorCache extensions + EmitModelVariants typed sub-struct grouping).
  • Audit complete: every site classified (a) substrate-fixed; no caller-provided strings, no diagnostic-only sites needing exemption.
  • Cross-validation gate emit_production_code_has_no_declaration_by_name_calls lands fail-closed on future production drift; #[cfg(test)] split correctly excludes test-only fixture lookups without weakening production constraint.
  • Population witness ratchets (emit_model_variants_populated_after_bootstrap, emit_anchor_cache_populated_after_bootstrap) catch silent-empty-cache failures at bootstrap time, not emit time.
  • ROADMAP:46 closes for production emit; test-only callers correctly excluded from row scope.

Cannot self-approve via API. Director / merge-cap holder may proceed.

— sent from silent-ant-322 (inbox #1133); reply at #1133

@briansrls briansrls left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review metadata

  • Provider / model: codex / unknown
  • Commit: 1d0c99a4 · Trigger: schedule
  • Thinking: 276s wall

✅ No blocking concerns found in the mixed code/docs changes.

@briansrls

Copy link
Copy Markdown
Contributor Author

Review metadata

  • Provider / model: codex / codex-default
  • Commit: fb7a680e · Trigger: schedule
  • Comparison: origin/main @ 5daa5bba ... review/pr-1638-fb7a680e @ fb7a680e
  • Thinking: 62s wall

Verdict: APPROVE

No concrete violations found in the diff. The PR moves emit consumers from repeated declaration_by_name/variant-name walks to cached DeclarationId accessors, with fail-closed None/typed error handling at the call sites and a focused census ratchet for production emit code. I did not run builds or tests, per instruction.

@briansrls

Copy link
Copy Markdown
Contributor Author

Review metadata

  • Provider / model: codex / codex-default
  • Commit: 680cee22 · Trigger: schedule
  • Comparison: origin/main @ 266d28b3 ... review/pr-1638-680cee22 @ 680cee22
  • Thinking: 88s wall

Verdict: APPROVE

The diff is narrowly aligned with the rubric: emit-time name lookups are moved behind bootstrap-populated typed DeclarationId caches, consumers continue to fail closed when required anchors are missing, and the new ratchet test guards production emit code against reintroducing Dag::declaration_by_name. No concrete invariant, coding, or testing violations observed in the changed lines.

@briansrls

Copy link
Copy Markdown
Contributor Author

Review metadata

  • Provider / model: cursor / composer-2
  • Commit: d7a0aa70 · Trigger: schedule
  • Comparison: origin/main @ b22b9280 ... review/pr-1638-d7a0aa70 @ d7a0aa70
  • Thinking: 53s wall

Findings

None. The diff matches the intended direction in ROADMAP: emit stops doing production-time declaration_by_name for fixed anchors and instead reads bootstrap-filled caches (EmitAnchorCache / EmitModelVariants), which strengthens P2 (single resolution at bootstrap, consumers read one place) without adding parallel substrate authority. Failure paths still use typed EmitError / EmitPythonError / &'static str where they already did—no new P3 silent-success behavior. New types are implementation caches on Dag, not new Dag-carried substrate.

Verdict

APPROVE — Change is coherent, fail-closed behavior is preserved, and emit_production_code_has_no_declaration_by_name_calls in sg0_census_test.rs gives a clear ratchet for the emit tree layout you have today (flat emit/*.rs).

Exploratory observations (optional)

  • dag.rs: emit_model_variants_populated_after_bootstrap asserts many variant slots in one test; TESTING.md prefers one claim per test—splitting would be polish, not a functional issue.
  • Cache population still matches variant labels with string literals at bootstrap (same class of knowledge as before, just centralized once); fine for this PR’s scope.

@briansrls
briansrls merged commit 7711d4d into main May 4, 2026
4 checks passed
@briansrls

Copy link
Copy Markdown
Contributor Author

Review metadata

  • Provider / model: openai-pro / gpt-5-5-pro
  • Commit: d7a0aa70 · Trigger: manual
  • Conversation: View conversation

1. Story of the diff

This PR retires the ROADMAP debt row for production emit-time declaration_by_name(...) lookups by moving those fixed emit/model anchors into bootstrap-populated Dag caches. The load-bearing change is in dag.rs: EmitAnchorCache grows method/template anchors, a new EmitModelVariants record caches fixed coproduct constructor DeclarationIds, and bootstrap population resolves the string names once at Dag initialization rather than at each emit parse site (src/v3/compiler/src/dag.rs:2279-2291, src/v3/compiler/src/dag.rs:2361-2376, src/v3/compiler/src/dag.rs:3792-3801, src/v3/compiler/src/dag.rs:3929-4095). The emitters then consume those cached typed IDs and preserve existing malformed-spec/realization errors when an expected anchor is absent, while local named_variant_id helpers disappear from emit modules.

The PR also updates generated bootstrap initializers so the new Dag field is present, adds a unit test proving the cache is populated after normal bootstrap, and adds an SG-0 ratchet that scans production emit* modules for reintroduced .declaration_by_name( calls (src/v3/compiler/src/dag.rs:4486-4570, src/v3/compiler/tests/integration/sg0_census_test.rs:43-77). The ROADMAP row is marked retired with the mechanism and ratchet named explicitly (ROADMAP.md:373).

2. Invariant categories

  1. LAYER MODEL (substrate vs implementation) — Compliant. The diff is Dag-adjacent, but the new EmitModelVariants is explicitly a cached projection of existing declaration facts, not a new substrate authority: “Cached variant DeclarationIds for fixed emit-model coproducts” and “Populated once at bootstrap end” are stated at src/v3/compiler/src/dag.rs:2361-2363. Emit-side consumers read the cached IDs through dag.emit_model_variants() rather than re-resolving names in target code, for example src/v3/compiler/src/emit.rs:1271-1275 and src/v3/compiler/src/emit/rust_target.rs:1467-1487.
  2. INVARIANTS.md + modeling-discipline.md — Compliant. This is a single-authority/facts-flow-forward improvement: fixed declaration facts are resolved once into Dag caches (src/v3/compiler/src/dag.rs:3929-4095) and then read by emit consumers. Fail-closed behavior is preserved where missing cache entries become existing typed errors rather than fabricated defaults, for example EmitError::MalformedRealization at src/v3/compiler/src/emit.rs:2780-2791 and EmitError::MalformedTargetSyntax at src/v3/compiler/src/emit/rust_target.rs:2255-2267.
  3. CODING.md — Compliant. The new implementation follows the repo’s data-plus-functions direction: the cache is plain data (src/v3/compiler/src/dag.rs:2365-2376), Dag exposes narrow typed accessors such as emit_model_variants() (src/v3/compiler/src/dag.rs:3191-3194), and emit parsing remains in free functions that convert absent data into structured errors. The method-contract helper also now receives the cached declaration ID through method_template_contract_decl() instead of doing its own name lookup (src/v3/compiler/src/emit/collection_ops_method_contract.rs:16-18).
  4. TESTING.md — Compliant. The diff adds the right two levels of tests for this change: a bootstrap/unit-style presence check that every new emit-model cache slot is populated by Dag::new() (src/v3/compiler/src/dag.rs:4486-4570), and an integration ratchet that scans production emit modules and fails if .declaration_by_name( returns there (src/v3/compiler/tests/integration/sg0_census_test.rs:43-77). Since the PR is a lookup-authority refactor rather than a new user-visible emit behavior, I do not see a missing behavior regression test.
  5. LOCKED DESIGN DECISIONS — N/A. The diff retires a ROADMAP debt row and changes Rust implementation/cache plumbing; it does not reference or alter a locked thesis/design decision.
  6. TRACKED vs UNTRACKED DEBT — Compliant. This closes tracked debt rather than adding an untracked bridge: ROADMAP.md:373 names the retired row, the mechanism (EmitAnchorCache / EmitModelVariants), and the ratchet (emit_production_code_has_no_declaration_by_name_calls). The ratchet is present in the diff and bounded to production src/v3/compiler/src/emit* code at src/v3/compiler/tests/integration/sg0_census_test.rs:43-77.

3. Verdict

APPROVE

The PR consistently moves distributed emit-time string lookup into a single bootstrap-populated Dag cache, preserves fail-closed error paths at use sites, and adds both population and reintroduction ratchets. I did not find a diff-line-backed invariant violation.

briansrls added a commit that referenced this pull request May 6, 2026
…ft-items + Grounding side-branches

Per bold-ferret-748 Grounding Mgr review at PR #1808 #issuecomment-4384302437.
5 findings, all VALID. Substantive structural fixes:

Finding 1 (authority hierarchy correctness) — Plan §5 cited
docs/audit/r3-debt-sweep-2026-05-06.md as source-of-truth, but that file is
on PR #1804 (not merged to main yet). Plan PR could merge into broken
authority. Fix: §5 added "Cross-PR dependency" header noting PR #1808
sequenced AFTER PR #1804 (claude APPROVE'd, doc-only, mergeable).

Finding 2 (v2-retirement dependency direction REVERSED) — Plan §2.2 placed
PR-F + Float migration as prerequisites for v2_directory_deleted. Wrong per
r3-structure.md: T-V2-Retirement depends on T-FixedPoint + T-LensProducer
+ T-Numeric-Construction Int<N>; PR-F + Float are blockers for FULL Rust
primitive grounding (T-Ground-Rust complete-coverage), NOT v2 deletion. Fix:
§2.2 corrected sequence + added separate "Grounding-side dependency branch"
section covering PR-F + Float for T-Ground-Rust + L5 closure.

Finding 3 (§3 T-Anthropic-Wire status drift) — Plan said GREEN-pending /
no blocker, but #1702 CLOSED + held pending Substrate variant-aware
projection metadata carrier. Fix: §3 row corrected to RED with
Q-Anthropic-Variant-Aware blocker; cites preserved branch
codex/cc1-target-integer-structural-fold sha 51c6a4a.

Finding 4 (§6 Grounding side-branches missing — closes G10) — Plan §6
DAG didn't include Grounding-driven re-dispatch edges. Fix: added
"Grounding-side dependency branches" 5-row table covering: PR-F →
T-Ground-Rust Phase 1; EmissionPathProjection → L6 CrossTarget-Meta;
variant-aware projection → #1702 Anthropic re-dispatch; LanguageSpec
projection → Coercion-Fold retirement; F10 install_hint cleanup. G10
closes.

Finding 5 (§5 drift items wrong) — Plan listed #1638/#1499/declaration_by_name
but #1638 + declaration_by_name are SAME issue (double-counted) +
CollectionOps/StringOps/MapOps drift omitted. Fix: §5 normalized to
correct three: declaration_by_name ROADMAP↔ledger; #1499 transitional
fence ledger-gap; CollectionOps/StringOps/MapOps stale ledger refresh.

Plus minor: §2.4 Class 5 cascade-gating clarified per Director finding 2.4
(NOT parallel-to-LBP; depends on PB chain T-FixedPoint → T-LensProducer-
Retirement).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
briansrls added a commit that referenced this pull request May 6, 2026
…ass-surfaces clarification

Per quiet-otter-416 review at gunbc#846 #issuecomment-4384239011.
Substantive findings on plan + canvas fold-in.

Findings absorbed:

§1 Two distinct Pass surfaces clarification — Plan §1.5 said "ALL gates
pass + zero tracked-debt rows survive" but didn't explicitly distinguish
the lane TestClaim gates (70 total) from r3_debt_paydown_zero_remaining
(standing-program ledger predicate). Risk: "70 gates green" mis-merging
into "debt gate satisfied." Fix: §1 added "Two distinct Pass surfaces"
paragraph explicitly stating both must hold.

§3 T-Debt-Paydown row was stale ("(TBD from canvas)"). Updated to
YELLOW with concrete in-flight anchors: PR #1807 (SG-0 PR-body /
diff-reconcile gate; OPEN); PR #1566 (rollup hygiene; OPEN/DRAFT per
debt-paydown-ledger); Tier-1 dispatch-brief drift sweep verified.
Current dispatch column now lists all four owned mechanisms (per-PR
rule, drift-reconcile, velocity tripwire, closure-receipt cadence,
SG-0 PR-window discipline).

§7 PR-authoring contract — r3-structure.md §"Standing program —
R3 Debt-Paydown" lists FOUR owned mechanisms. Plan §7 only had
debt-receipt + ratchet/anticipation as first-class subsections;
velocity tripwire + closure-receipt cadence + SG-0 PR-window
discipline missing. Risk: §7 reads as "debt receipt only" violating
canonical authority's four-mechanism structure.

Fix: §7 expanded with three new subsections:
- §7.6 Velocity tripwire (Debt-Paydown owned mechanism #2)
- §7.7 Closure-receipt cadence (Debt-Paydown owned mechanism #3)
- §7.8 SG-0 PR-window net-shrink discipline (Debt-Paydown owned
  mechanism #4 — merge-discipline gate, separate Pass surface from
  lane gates)

§7 header reorganized to mirror canonical "four owned mechanisms"
structure with explicit (1)-(4) enumeration per Debt-Paydown Mgr
review.

§5 drift items + Q-Drift-Reconcile: already covered at sha 2294265
(Grounding finding 5 normalization). Debt-Paydown Mgr's review confirms
PM accuracy on #1638/#1499/declaration_by_name + acceptable one-PR
default for Q-Drift-Reconcile.

§5 SG-0 path counts (46/89/1 → 136): Debt-Paydown Mgr verified at HEAD;
matches plan prose. No fix needed.

Q7 + #1566 + velocity tripwire operational reporting: Debt-Paydown Mgr
"still holding" items; surface in plan §10.3 as continuation but not
blocking plan PR open.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
briansrls added a commit that referenced this pull request May 6, 2026
…ctionOps)

Retire declaration_by_name emit-pattern row per PR #1638; add #1499 acknowledgment
row for plan §533 stratum B; refresh CollectionOps strand cross-reference.
Update r3-program-plan drift bullets to reconciled status.

Debt receipt (R3 standing program):
- Debt paid: ROADMAP/ledger rows cited in docs/debt/r3-debt-paydown-ledger-2026-05-02.md
  catalog + docs/r3-program-plan.md § drift list (Q7 single PR).

Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls added a commit that referenced this pull request May 6, 2026
#1892)

* ci+docs: SG-0 net-shrink PR-body discipline (Director Risk 5)

- Add scripts/check-pr-sg0-net-shrink-discipline.sh: when a pull_request
  touches sg0_census_test.rs, require PR body lines SG-0 hand-path delta:
  and SG-0 pairing: (a|b|c) for strict net +N adds; embedded --self-test.
- Wire ci job: full checkout, fetch origin/main, run checker + self-test.
- Extend PULL_REQUEST_TEMPLATE.md with SG-0 net-shrink section + anchors.
- ROADMAP: SG-0 PR-window net-shrink discipline row (process complement to
  BridgeLedgerZero course correction #4).

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: fail-closed SG-0 PR-body delta and pairing validation

Tighten check-pr-sg0-net-shrink-discipline.sh: accept only signed integer
tokens (reject bogus -words), and require structured (a)/(b)/(c) pairing
evidence per PR template. Extend self-test with malformed cases.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: anchor SG-0 pairing lines; reject extra CLI args

Harden check-pr-sg0-net-shrink-discipline.sh: pick the first body line that
starts (after optional whitespace) with SG-0 pairing: so mid-line prose
cannot satisfy the gate; require --self-test/--check-body-only to be the
sole flag. Extend self-test for anchored vs substring-only cases.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: reconcile SG-0 PR-body delta with census git diff

After format/pairing validation on pull_request, compare the declared
net hand-path count to adds−removes of EXPECTED_* string rows in
sg0_census_test.rs (git diff origin/main...HEAD). Documents counter
limits in the script header.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: allow SG-0 (a)/(c) pairing evidence on the following line

Flatten pairing line + continuation for path/dispatch regexes so
"immediately after" matches template wording; add self-tests.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: avoid SIGPIPE false-negative in SG-0 census path detection

Replace `git diff --name-only … | grep -Fxq` with
`git diff --quiet origin/main...HEAD -- <census>`: under pipefail, early
grep exit can SIGPIPE git (exit 141), and `if !` then skips the gate.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: derive SG-0 hand-path delta from git show census snapshots

Count EXPECTED_HAND_AUTHORED_{NON_TEST,TEST,FRAGMENTS} rows at origin/main
vs HEAD instead of diffing raw EXPECTED_* line churn (excludes
EXPECTED_GENERATED_* and other inventories). Propagate counter errors into
the mismatch gate.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: here-string SG-0 PR-body scans; clarify template vs CI prefix

Avoid printf|grep|awk pipelines on PR_BODY under pipefail (SIGPIPE false
missing-delta). Add template note: raw lines must start with SG-0…, not
markdown checklist bullets alone.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: require column-0 SG-0 pairing line to match PR template

The gate already required ^SG-0 hand-path delta:; pairing used
^[[:space:]]*SG-0 pairing:, diverging from the template single-authority
contract. Anchor pairing extraction and (a)/(b)/(c) checks at column 0;
add self-test for indented pairing rejection.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: require path-shaped tokens after "removed" for SG-0 pairing (a)

The (a) gate accepted `removed <any-token>`, which could satisfy same-PR
retirement without naming a real path. Tighten to `src/v3/compiler/…` or
*.rs / *.txt after "removed"; add self-test for the weasel case.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: fail closed when origin/main missing on pull_request SG-0 gate

Skipping the gate on a missing base ref was fail-open for PR runs.
CI already fetches main to origin/main; absent ref is a setup error.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: require explicit removed + path for SG-0 pairing (a); ROADMAP authority

Codex blocking: (a) no longer accepts standalone .rs / slash tokens without
the retirement keyword. Document fail-closed origin/main + (a) contract in
ROADMAP SG-0 bullet.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: here-string first token parse; local pairing_flat in SG-0 gate

Address review nits: use read <<< for delta token first field; declare
pairing_flat with other function locals.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: document rustfmt + FRAGMENTS shape assumptions in SG-0 census counter

Claude exploratory: note trailing-comma row regex and single-line vs block
FRAGMENTS parsing so future census edits do not silently miscount.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: fail-closed SG-0 census counter + hermetic counter self-tests

Require exactly one NON_TEST/TEST/FRAGMENTS const each, reject unclosed arrays,
and exit nonzero from awk on malformed snapshots. Extend --self-test with
synthetic stdin cases for the counter path (gpt-5-5-pro P3/TESTING).

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: (a) .txt under census root; multiline FRAGMENTS counter self-test

Claude exploratory: require `src/v3/compiler/…` for removed *.txt evidence
(short *.rs unchanged). Add census self-test for multiline FRAGMENTS (hand==1
path) and PR-body self-tests for bare .txt vs fragment-shaped .txt.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: strip CR from GitHub PR body before SG-0 gate parse

pull_request.body may be CRLF; +1\\r failed numeric token match. Normalize
before grep/read and add CRLF self-tests (+0, +1 (b), URL on next line).

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: count census path rows with EOL // comments; fail on unsupported shape

Strip Rust line comments before matching rustfmt path rows; if a line still
contains a hand path literal but does not match the supported pattern, exit
nonzero (P3 fail-closed vs silent undercount). Add counter self-tests.

Co-authored-by: Cursor <cursoragent@cursor.com>

* WIP: R3 Debt-Paydown

* docs(debt): DP1 Q7 reconcile ledger with ROADMAP (#1638, #1499, CollectionOps)

Retire declaration_by_name emit-pattern row per PR #1638; add #1499 acknowledgment
row for plan §533 stratum B; refresh CollectionOps strand cross-reference.
Update r3-program-plan drift bullets to reconciled status.

Debt receipt (R3 standing program):
- Debt paid: ROADMAP/ledger rows cited in docs/debt/r3-debt-paydown-ledger-2026-05-02.md
  catalog + docs/r3-program-plan.md § drift list (Q7 single PR).

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
briansrls added a commit that referenced this pull request May 6, 2026
* ci+docs: SG-0 net-shrink PR-body discipline (Director Risk 5)

- Add scripts/check-pr-sg0-net-shrink-discipline.sh: when a pull_request
  touches sg0_census_test.rs, require PR body lines SG-0 hand-path delta:
  and SG-0 pairing: (a|b|c) for strict net +N adds; embedded --self-test.
- Wire ci job: full checkout, fetch origin/main, run checker + self-test.
- Extend PULL_REQUEST_TEMPLATE.md with SG-0 net-shrink section + anchors.
- ROADMAP: SG-0 PR-window net-shrink discipline row (process complement to
  BridgeLedgerZero course correction #4).

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: fail-closed SG-0 PR-body delta and pairing validation

Tighten check-pr-sg0-net-shrink-discipline.sh: accept only signed integer
tokens (reject bogus -words), and require structured (a)/(b)/(c) pairing
evidence per PR template. Extend self-test with malformed cases.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: anchor SG-0 pairing lines; reject extra CLI args

Harden check-pr-sg0-net-shrink-discipline.sh: pick the first body line that
starts (after optional whitespace) with SG-0 pairing: so mid-line prose
cannot satisfy the gate; require --self-test/--check-body-only to be the
sole flag. Extend self-test for anchored vs substring-only cases.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: reconcile SG-0 PR-body delta with census git diff

After format/pairing validation on pull_request, compare the declared
net hand-path count to adds−removes of EXPECTED_* string rows in
sg0_census_test.rs (git diff origin/main...HEAD). Documents counter
limits in the script header.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: allow SG-0 (a)/(c) pairing evidence on the following line

Flatten pairing line + continuation for path/dispatch regexes so
"immediately after" matches template wording; add self-tests.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: avoid SIGPIPE false-negative in SG-0 census path detection

Replace `git diff --name-only … | grep -Fxq` with
`git diff --quiet origin/main...HEAD -- <census>`: under pipefail, early
grep exit can SIGPIPE git (exit 141), and `if !` then skips the gate.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: derive SG-0 hand-path delta from git show census snapshots

Count EXPECTED_HAND_AUTHORED_{NON_TEST,TEST,FRAGMENTS} rows at origin/main
vs HEAD instead of diffing raw EXPECTED_* line churn (excludes
EXPECTED_GENERATED_* and other inventories). Propagate counter errors into
the mismatch gate.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: here-string SG-0 PR-body scans; clarify template vs CI prefix

Avoid printf|grep|awk pipelines on PR_BODY under pipefail (SIGPIPE false
missing-delta). Add template note: raw lines must start with SG-0…, not
markdown checklist bullets alone.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: require column-0 SG-0 pairing line to match PR template

The gate already required ^SG-0 hand-path delta:; pairing used
^[[:space:]]*SG-0 pairing:, diverging from the template single-authority
contract. Anchor pairing extraction and (a)/(b)/(c) checks at column 0;
add self-test for indented pairing rejection.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: require path-shaped tokens after "removed" for SG-0 pairing (a)

The (a) gate accepted `removed <any-token>`, which could satisfy same-PR
retirement without naming a real path. Tighten to `src/v3/compiler/…` or
*.rs / *.txt after "removed"; add self-test for the weasel case.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: fail closed when origin/main missing on pull_request SG-0 gate

Skipping the gate on a missing base ref was fail-open for PR runs.
CI already fetches main to origin/main; absent ref is a setup error.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: require explicit removed + path for SG-0 pairing (a); ROADMAP authority

Codex blocking: (a) no longer accepts standalone .rs / slash tokens without
the retirement keyword. Document fail-closed origin/main + (a) contract in
ROADMAP SG-0 bullet.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: here-string first token parse; local pairing_flat in SG-0 gate

Address review nits: use read <<< for delta token first field; declare
pairing_flat with other function locals.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: document rustfmt + FRAGMENTS shape assumptions in SG-0 census counter

Claude exploratory: note trailing-comma row regex and single-line vs block
FRAGMENTS parsing so future census edits do not silently miscount.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: fail-closed SG-0 census counter + hermetic counter self-tests

Require exactly one NON_TEST/TEST/FRAGMENTS const each, reject unclosed arrays,
and exit nonzero from awk on malformed snapshots. Extend --self-test with
synthetic stdin cases for the counter path (gpt-5-5-pro P3/TESTING).

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: (a) .txt under census root; multiline FRAGMENTS counter self-test

Claude exploratory: require `src/v3/compiler/…` for removed *.txt evidence
(short *.rs unchanged). Add census self-test for multiline FRAGMENTS (hand==1
path) and PR-body self-tests for bare .txt vs fragment-shaped .txt.

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: strip CR from GitHub PR body before SG-0 gate parse

pull_request.body may be CRLF; +1\\r failed numeric token match. Normalize
before grep/read and add CRLF self-tests (+0, +1 (b), URL on next line).

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: count census path rows with EOL // comments; fail on unsupported shape

Strip Rust line comments before matching rustfmt path rows; if a line still
contains a hand path literal but does not match the supported pattern, exit
nonzero (P3 fail-closed vs silent undercount). Add counter self-tests.

Co-authored-by: Cursor <cursoragent@cursor.com>

* WIP: R3 Debt-Paydown

* docs(debt): DP1 Q7 reconcile ledger with ROADMAP (#1638, #1499, CollectionOps)

Retire declaration_by_name emit-pattern row per PR #1638; add #1499 acknowledgment
row for plan §533 stratum B; refresh CollectionOps strand cross-reference.
Update r3-program-plan drift bullets to reconciled status.

Debt receipt (R3 standing program):
- Debt paid: ROADMAP/ledger rows cited in docs/debt/r3-debt-paydown-ledger-2026-05-02.md
  catalog + docs/r3-program-plan.md § drift list (Q7 single PR).

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs(r3): record §S4 actions.dag audit receipt on #1771 (#1873 closed)

Debt-Paydown coordination: audit-and-delta prerequisite satisfied per
quick-ferret receipt; T-LBP COMPLETE remains for downstream S4 dispatch.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.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