Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions docs/briefs/r3-pb-regen-lens-consumer-audit.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# R3 PB — `regen_lens.rs` consumer audit (carrier-independent, docs-only)

**Status:** AUDIT artifact (docs-only, carrier-independent). Authored 2026-05-01 by PB Manager continuation per Director follow-up on inbox #1149 — bounded post-#1347 planning slice that maps `src/v3/compiler/src/bin/regen_lens.rs`'s consumer / build / CI / call surfaces and the exact handoff points for the future `BinShim` carrier + instance + emitter + §7.2 equivalence fixture, **without** waiting on or inventing the carrier.
**Status:** AUDIT artifact (docs-only, carrier-independent). Authored 2026-05-01 by PB Manager continuation per Director follow-up on inbox #1149 — bounded post-#1347 planning slice that maps `src/v3/compiler/src/bin/regen_lens.rs`'s consumer / build / CI / call surfaces and the exact handoff points for **`BinShim` instance + emitter + §7.2 equivalence** (substrate `BinShim` carrier is on `main`; this audit does **not** invent carrier fields).

**Parent authorities:**
- [`docs/design-pb-runtime-interpreter.md`](../design-pb-runtime-interpreter.md) §4 (Item 5 emit pattern), §4.3 (dissolution path), §5.1 (sub-gate decomposition), §7.2 (BinShim equivalence fixture).
Expand All @@ -13,13 +13,13 @@ This audit does NOT introduce authority. Every cell cites a live file/line on or

## Scope

Carrier-independent dependency map for the future sub-gate-3 retirement worker. Names every consumer / build / CI / call / test / doc surface that participates in the cutover from the hand-Rust `regen_lens.rs` to the `.dag`-emitted equivalent. **Does NOT** propose carrier shape, emit semantics, or implementation order — those are quick-newt's territory + Substrate Manager's territory + future carrier-landing PR's territory.
Carrier-independent dependency map for the future sub-gate-3 retirement worker. Names every consumer / build / CI / call / test / doc surface that participates in the cutover from the hand-Rust `regen_lens.rs` to the `.dag`-emitted equivalent. **Does NOT** propose emit semantics or implementation order — carrier shape lives in `src/v3/std/bin_shim.dag`; instance / emitter / §7.2 sequencing remain PB + Substrate dispatch per linked briefs.

## Non-overlap reminder

- **This audit:** consumer / handoff map. Docs-only.
- **quick-newt** (separate session): retirement-readiness implementation attempt path → see `r3-pb-regen-lens-first-binshim-target-retirement-readiness.md` referenced above.
- **Substrate Manager**: `BinShim` carrier-type shape (not yet on main; STOP+PING tracked in #1347).
- **Substrate Manager**: `BinShim` carrier regressions + **P1** if instance authoring surfaces carrier-shape pressure (`BinShim` record is on `main`; not “waiting on carrier landing”).
- **PB framework PR (#1347):** `dsl/std/runtime/bin_shims/` framework directory + naming convention. Authored.

## Source surface (the file itself)
Expand All @@ -31,7 +31,7 @@ Carrier-independent dependency map for the future sub-gate-3 retirement worker.
| Header docstring | "Unified lens-regen driver. Narrow host shim for `src/v3/compiler/regen.dag`: reads every `data <name>_entry: LensRegistryEntry` record out of the bootstrap Dag, compiles the referenced `.dag` lens, and writes the `emit_rust_module` projection to the declared output path." (line 1-6) |
| Entry-point shape | `fn main() -> ExitCode` (line 33) — already returns a `std::process::ExitCode`, structurally close to the design-doc §4.2 `entry: () -> std.process.ProcessExit` contract. Re-declaring it as a `BinShim.entry` does NOT require evolving the substrate `ProcessExit` shape. |
| `LENS_REGISTRY_ENTRY_TYPE` | `&str = "LensRegistryEntry"` (line 26) — string-keyed lookup against `regen.dag`'s `data <name>_entry: LensRegistryEntry` records. |
| Authority source | `src/v3/compiler/regen.dag` — the bin reads 11 `LensRegistryEntry` records here (verified `grep -c "_entry: LensRegistryEntry" src/v3/compiler/regen.dag`). |
| Authority source | `src/v3/compiler/regen.dag` — the bin reads **9** `data …_entry: LensRegistryEntry` rows (`rg -n '^data .*_entry: LensRegistryEntry'`). A broader `_entry: LensRegistryEntry` match counts comment lines too — use the anchored query for totals (see §Delta — 2026-05-05). |

## Internal crate imports (the bin's PB-Runtime-equivalent surfaces)

Expand All @@ -51,16 +51,16 @@ These imports are what the future `BinShim` emitter must end up calling from emi

| Surface | Live location (verified) | Cutover delta |
|---|---|---|
| **Cargo bin entry** | `src/v3/compiler/Cargo.toml`: `[[bin]] name = "regen_lens" path = "src/bin/regen_lens.rs"` | `path` updates to the emitted location once the file is generated. The `name = "regen_lens"` and CLI invocation surface stay stable so the 8-bin Cargo manifest's authority surface is unchanged. |
| **`build.rs` `REGEN_OUTPUTS`** | `src/v3/compiler/build.rs:479-516` (25 entries on origin/main HEAD at audit time) | Add the emitted shim's path to `REGEN_OUTPUTS` so SG-0's `sg0_generated_partition_is_producer_owned` invariant counts the file as generated. The current `REGEN_OUTPUTS` lists every per-lens `lens_*_generated.rs` (the bin's *outputs*) but NOT the bin itself — `regen_lens.rs` is the producer, not a generated artifact. After retirement, the bin moves from "hand-authored producer" to "generated artifact" and the manifest grows by 1. |
| **`GENERATED_FILES` runtime constant** | Built from `REGEN_OUTPUTS` per `build.rs:520-526`, exposed as `v3_compiler::generated_files::GENERATED_FILES`. | Auto-updates when `REGEN_OUTPUTS` grows; no separate edit. The bin imports this exact constant (line 22), so its own re-emission produces a consistent self-reference. |
| **Package `v3-compiler` declares eight `[[bin]]` targets**: `regen_bootstrap`, `regen_lens`, `regen_parse`, `regen_parse_tables`, `regen_tokenize`, `regen_v3`, `self_host_fixed_point`, `r1c_e_emit_gates` | `src/v3/compiler/Cargo.toml` `[[bin]]` blocks | Other bins follow the same template after `regen_lens` lands as the canonical first slice (per design-doc §4.3 + BinShim brief §"First slice"). They are NOT in scope for sub-gate 3 — but they ARE in scope for the broader BinShim retirement program once the carrier and pattern stabilize. |
| **Cargo bin entry** | `src/v3/compiler/Cargo.toml`: `[[bin]] name = "regen_lens" path = "src/bin/regen_lens.rs"` | `path` updates to the emitted location once the file is generated. The `name = "regen_lens"` and CLI invocation surface stay stable so the nine-bin Cargo manifest's authority surface is unchanged (binary name is what tooling and diagnostics key on). |
| **`build.rs` `REGEN_OUTPUTS`** | `src/v3/compiler/build.rs:479-513` (25 entries on origin/main HEAD at audit time) | Add the emitted shim's path to `REGEN_OUTPUTS` so SG-0's `sg0_generated_partition_is_producer_owned` invariant counts the file as generated. The current `REGEN_OUTPUTS` lists every per-lens `lens_*_generated.rs` (the bin's *outputs*) but NOT the bin itself — `regen_lens.rs` is the producer, not a generated artifact. After retirement, the bin moves from "hand-authored producer" to "generated artifact" and the manifest grows by 1. |
| **`GENERATED_FILES` runtime constant** | `REGEN_OUTPUTS` (`build.rs:479-513`) is iterated into the emitted manifest (`build.rs:514-526` writes `out_dir/v3_generated_files.rs` with `pub static GENERATED_FILES: &[&str]`); exposed as `v3_compiler::generated_files::GENERATED_FILES`. | Auto-updates when `REGEN_OUTPUTS` grows; no separate edit. The bin imports this exact constant (`regen_lens.rs` line 22), so its own re-emission produces a consistent self-reference. |
| **Package `v3-compiler` declares nine explicit `[[bin]]` targets** (`regen_bootstrap`, `regen_lens`, `regen_parse`, `regen_parse_tables`, `regen_tokenize`, `regen_v3`, `emit_method_template_projection`, `self_host_fixed_point`, `r1c_e_emit_gates`) | `src/v3/compiler/Cargo.toml:47-85` `[[bin]]` blocks | Other bins follow the same template after `regen_lens` lands as the canonical first slice (per design-doc §4.3 + BinShim brief §"First slice"). They are NOT in scope for sub-gate 3 — but they ARE in scope for the broader BinShim retirement program once the carrier and pattern stabilize. |

## SG-0 census surface

| Authority | Live location (verified) | Cutover delta |
|---|---|---|
| `EXPECTED_HAND_AUTHORED_NON_TEST` | `src/v3/compiler/tests/integration/sg0_census_test.rs:174` lists `"src/v3/compiler/src/bin/regen_lens.rs"` | Remove the entry. SG-0 census decreases by 1; `REGEN_OUTPUTS` grows by 1 (above). Both updates land atomically in the same retirement PR. |
| `EXPECTED_HAND_AUTHORED_NON_TEST` | `src/v3/compiler/tests/integration/sg0_census_test.rs:237` lists `"src/v3/compiler/src/bin/regen_lens.rs"` (table `EXPECTED_HAND_AUTHORED_NON_TEST` begins `:211`) | Remove the entry. SG-0 census decreases by 1; `REGEN_OUTPUTS` grows by 1 (above). Both updates land atomically in the same retirement PR. |
| Census comment trail | `sg0_census_test.rs:50-67` documents the 2026 SG-6 cutover that folded 4 per-lens regen bins + `regen_infer_helpers` into the unified `regen_lens` shim. | Future entry: comment annotation that `regen_lens.rs` retired via Item-5 BinShim emit pattern + `data regen_lens_shim` instance under `dsl/std/runtime/bin_shims/regen_lens.dag`. |

## Test surface (consumers that exercise the bin or its registry)
Expand Down Expand Up @@ -92,19 +92,19 @@ These imports are what the future `BinShim` emitter must end up calling from emi
| `docs/audit/t-v2-retirement-audit.md` §"1. STOP conditions for implementation" S-3 row | S-3 entry (`regen_lens.rs` retirement) — "NOT MET" | Flips to "MET" when retirement lands. |
| `docs/briefs/t-pb-a-lens-producer-priority-slice-first-retirement-worker.md` §"Lens producers / lens-adjacent (priority-slice candidates)" `regen_lens.rs` row + §"Queue after Slice 1 (recommended order for follow-on briefs)" Tier-1/regen entry | Earlier T-PB-A scoping ("Tier-1 / regen: regen_lens.rs — depends on PB-1 + emit") | Already names the dependency chain; informational. |

## Handoff points for the future `BinShim` carrier + instance + emitter + §7.2 fixture
## Handoff points — landed `BinShim` carrier; instance + emitter + §7.2 fixture

This is the load-bearing audit deliverable: a per-handoff row naming exactly what each future PR consumes from this audit.

| Handoff | Owner | Consumes from this audit | What that PR adds |
|---|---|---|---|
| **`type BinShim` carrier landing** | Substrate Manager (per design-doc §5.4 + #1347 STOP+PING) | Field requirements named in design-doc §4.2's example `data regen_lens_shim: BinShim = { name: "regen_lens", entry: regen_lens, ... }`: a `name` field whose value is the **Cargo `[[bin]]` target name** (e.g. `"regen_lens"` per `src/v3/compiler/Cargo.toml`'s `[[bin]] name = "regen_lens"` block), and `entry: () -> std.process.ProcessExit` whose structural model is the bin's existing `fn main() -> ExitCode` (line 33). Whatever pipeline-composition fields the §4.2 sketch settles on are Substrate Manager's call. **Not derivable from `LENS_REGISTRY_ENTRY_TYPE` at line 26** — that constant is the registry-entry meta-tag string the bin uses to look up `LensRegistryEntry` records inside `regen.dag`, not a property of the bin-shim itself. | `type BinShim { ... }` declaration in `dsl/std/runtime/bin_shim.dag` (or wherever Substrate picks). |
| **`data regen_lens_shim: BinShim` instance authoring** | PB Manager (R3 worker, dispatched by PB on carrier landing) | Field values from the audit's "Source surface" + "Internal crate imports" tables. The `entry` field references a `regen_lens_main` declaration that fold-mirrors the current `fn main` body via the locked PB-Runtime emit pattern. | New file `dsl/std/runtime/bin_shims/regen_lens.dag` per the framework convention in PR #1347. |
| **`type BinShim` carrier** | Substrate Manager — **landed on main** (`src/v3/std/bin_shim.dag:19-23`) | Live substrate record: `entrypoint_name: NonEmptyStr`, `description: String`, `entry: DeclarationRef` (points at a `.dag` entry function for the shim body — see [`dsl/std/runtime/bin_shims/README.md`](../../dsl/std/runtime/bin_shims/README.md) naming convention). Design-doc §4.2 sketches historically used a `name` field; scheduled work keys off **`entrypoint_name`** matching the Cargo `[[bin]]` name (`"regen_lens"`). **`entry` resolves in substrate** to the declaration named by the ref — not to `LENS_REGISTRY_ENTRY_TYPE` at line 26 of `regen_lens.rs`, which tags rows inside `regen.dag`. Hand-Rust `fn main() -> ExitCode` (line 33) remains the behavioral model for §7.2 until `.dag` entry replaces it. | No further carrier-introduction PR required for retirement chain; regressions remain Substrate-owned per §5.4. |
| **`data regen_lens_shim: BinShim` instance authoring** | PB Manager (R3 worker; PB dispatch for the `dsl/std/runtime/bin_shims/` instance slice — **not** contingent on carrier introduction, which is already on `main`) | Field values from the audit's "Source surface" + "Internal crate imports" tables. The `entry` field references a `regen_lens_main` declaration that fold-mirrors the current `fn main` body via the locked PB-Runtime emit pattern. | New file `dsl/std/runtime/bin_shims/regen_lens.dag` per the framework convention in PR #1347. |
| **BinShim emit pattern (the `.dag` emitter)** | PB Manager (R3 worker) | The bin's import surface (the 5 internal crates listed above) — the emitter must produce emitted Rust that calls these same crate APIs, since they are NOT being retired (they're producer-side authority). | New `.dag` emitter program analogous to `dsl/extdeps/languages/rust/emit.dag` per design-doc §4.2 + anti-bridge invariant #4. |
| **§7.2 equivalence fixture authoring** | PB Manager (R3 worker) — same retirement PR | The behavioral spec from the bin's docstring + `sg6_regen_lens_cli_smoke_regenerates_named_entry_without_drift` test (which IS the runtime evidence base). The fixture asserts: emitted-Rust + hand-Rust produce identical regenerated `lens_*_generated.rs` output for every `LensRegistryEntry` in `regen.dag`. | TestClaim `regen_lens_bin_shim_emits_behaviorally_equivalent_to_hand_rust` per design-doc §7.2 locked name. |
| **Cargo `path` flip** | PB Manager (same retirement PR) | The Cargo `[[bin]]` block at `Cargo.toml` (above). | `path = "src/bin/regen_lens.rs"` updates to whatever absolute path the emitted file lands at (or stays the same if the emitter writes to the same path). |
| **`REGEN_OUTPUTS` extension** | PB Manager (same retirement PR) | The list at `build.rs:479-516` (25 entries on origin/main HEAD at audit time). | Add `"src/v3/compiler/src/bin/regen_lens.rs"` (the now-emitted path). |
| **SG-0 census drop** | PB Manager (same retirement PR) | `sg0_census_test.rs:174`. | Remove the entry. |
| **`REGEN_OUTPUTS` extension** | PB Manager (same retirement PR) | The list at `build.rs:479-513` (25 entries on origin/main HEAD at audit time). | Add `"src/v3/compiler/src/bin/regen_lens.rs"` (the now-emitted path). |
| **SG-0 census drop** | PB Manager (same retirement PR) | `sg0_census_test.rs:237`. | Remove the entry. |
| **Doc status flips** | PB Manager (same retirement PR) | The 4 doc references in §"Documentation surface" above. | Mark RESOLVED/MET/closed as appropriate. |

## STOP / report-instead-of-invent
Expand Down Expand Up @@ -145,6 +145,21 @@ Observed deltas:

No carrier/emitter implementation is implied by these deltas. The current cutover blocker is not "find the `BinShim` carrier"; it is "provide a non-fabricated `regen_lens_main` entry target and loader story, then author the instance/emitter/§7.2/SG-0 changes in their assigned slices."

## Delta — 2026-05-06 mechanical verification (warm-ant-877 dispatch)

Repro pin: `origin/main @ 194ddb7a8e3cb033698e4f6749f93f436afde354`.

PB Manager dispatch: close honest checklist rows with **docs + mechanical audits** only — no `BinShim` carrier-field invention, no `.dag` instance authoring.

| Audit | Command / surface | Result |
|---|---|---|
| Registry data rows | `rg -n '^data .*_entry: LensRegistryEntry' src/v3/compiler/regen.dag` | **9** rows |
| Cargo bins | `src/v3/compiler/Cargo.toml:47-85` | **9** `[[bin]]` targets; `regen_lens` at `:52-54` |
| Producer manifest | `src/v3/compiler/build.rs:479-513` | **25** `REGEN_OUTPUTS` paths; still **no** `src/v3/compiler/src/bin/regen_lens.rs` |
| SG-0 census | `sg0_census_test.rs` | `regen_lens.rs` path string at **:237**; `EXPECTED_HAND_AUTHORED_NON_TEST` at `:211-293` |
| Instance directory | `dsl/std/runtime/bin_shims/` | **README.md only** (no `regen_lens.dag`) — row #1 / `regen_lens_main` STOP still authoritative per README §"Substrate prerequisite" |
| Carrier | `src/v3/std/bin_shim.dag:19-23` | Unchanged live `BinShim` record |

## Cross-refs

- Parent design lock: [`docs/design-pb-runtime-interpreter.md`](../design-pb-runtime-interpreter.md) §4 (Item 5 emit pattern), §4.3 (dissolution path), §5.1 (sub-gate decomposition), §7.2 (BinShim equivalence fixture).
Expand All @@ -154,4 +169,4 @@ No carrier/emitter implementation is implied by these deltas. The current cutove
- Quick-newt's parallel readiness checklist: [`docs/briefs/r3-pb-regen-lens-first-binshim-target-retirement-readiness.md`](r3-pb-regen-lens-first-binshim-target-retirement-readiness.md).
- PB Manager brief: [`docs/briefs/r2-pure-bootstrap-manager.md`](r2-pure-bootstrap-manager.md#program-scope-t-pb-post-r1-only) — R3 continuation table row for BinShim instances + emit pattern + retirement dispatch.
- Substrate-fact-introduction procedure: [`INVARIANTS.md`](../../INVARIANTS.md) §P1.
- Live source paths cited (anchor for future workers): `src/v3/compiler/src/bin/regen_lens.rs`, `src/v3/compiler/regen.dag`, `src/v3/compiler/Cargo.toml`, `src/v3/compiler/build.rs:479-516`, `src/v3/compiler/tests/integration/sg0_census_test.rs:174`, `src/v3/compiler/tests/integration/lens_register_correspondence_test.rs`, `src/v3/compiler/tests/integration/sg6_hand_authored_census_test.rs`, `scripts/slow-test-exemptions.txt:78`, `dsl/std/process.dag:39` (`type ProcessExit`).
- Live source paths cited (anchor for future workers): `src/v3/compiler/src/bin/regen_lens.rs`, `src/v3/compiler/regen.dag`, `src/v3/compiler/Cargo.toml`, `src/v3/compiler/build.rs:479-513`, `src/v3/compiler/tests/integration/sg0_census_test.rs:237`, `src/v3/compiler/tests/integration/lens_register_correspondence_test.rs`, `src/v3/compiler/tests/integration/sg6_hand_authored_census_test.rs`, `scripts/slow-test-exemptions.txt:78`, `dsl/std/process.dag:39` (`type ProcessExit`).
Loading
Loading