Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ Three distinct reflective/exploratory analyses ran against `main@7f74f09` and `m

- **Lossy user-lens reflection vs full substrate** (PARTIAL — exact issue novel): the declared substrate has rich `Behavior` records — `ValueNode { id, payload, result_port, span, lane2_workflow }` (`src/v3/std/substrate.dag:292-298`), `TransformNode { target, inputs, result_port, span }` (`:300-306`), `BranchNode { input, paths, result_port, span }`, `LoopNode { source, init, body, bound, result_port, span }`, `BindNode { id, name, result_port, params, span, lane2_workflow }`. But `src/v3/compiler/src/lens_apply.rs`'s reflected program view is explicitly lossy: Transform reflection drops `target` + `inputs` (`:859-868`); Branch drops `input` + `paths` (`:870-879`); Loop drops `source` + `init` + `body` + `bound` (`:881-890`); Bind drops everything except `name` (`:892-907`). **A user lens reading reflected `Behavior` cannot inspect many declared facts that v3.std.substrate says exist** — directly weakens the thesis claim that user-defined dimensions/lenses validate programs using the same structural mechanism as built-in dimensions (`THESIS.md:95-99`). **Dissolution trigger**: generate the `Behavior → FieldValue` reflection from `src/v3/std/substrate.dag` (or consume canonical .dag values directly). Until then, user-lens capability should be documented as "shallow behavior spine only," not full substrate self-inspection. Adjacent to T-LensAPI / T-PB-A but not explicitly tracked as a distinct lossy-reflection row. Surfaced by Exploratory Analysis 2026-04-25 (gpt-5-5-pro). P1 Modeling Faithfulness. Owner: unassigned; M scope.

- **Loop emission semantic invariant for Python/Go is comment-level, not structural** (NOVEL — risk-shaped): `src/v3/compiler/src/emit/python_target.rs` + `go_target.rs` Loop emission lands per PR `4dc0a6d1`. The current implementation is thesis-aligned IF every emitted Loop reaching those targets is specifically a recursive-user-function loop with declared cardinality/descent facts. The implementation comments name this as the construction-site invariant — but the representation is just `Loop`, so **a future PR introducing collection iteration or another loop form could accidentally inherit recursive-loop emission semantics** that don't apply. **Dissolution trigger**: either introduce a `LoopKind` / lowering marker that structurally distinguishes recursive-function-loop from other Loop sources, or add a structural invariant test proving every Loop reaching Python/Go emission belongs to the supported recursive-function lowering path. Surfaced by Reflective Analysis 2026-04-25 (gpt-5-5-pro Risk 2). P3 Fail-Closed (latent risk; comment-level invariant could degrade silently). Owner: unassigned; S scope.
- **Loop emission semantic invariant for Python/Go** (**RESOLVED 2026-04-27** via PR #953, W-B5): construction-closure audit found exactly two production `Behavior::Loop` construction sites in `src/v3/compiler/src/lower.rs` (`finalize_mutual_clusters` → `LoopBound::Descent`; `lower_fn_item_expr_body` → `LoopBound::Cardinality`); all other `push_loop` callers are `#[test]` code. Closure holds: every production Loop's output is the value port of some `Behavior::Bind` (recursive-function lowering signature). Receipt landed in `src/v3/compiler/tests/integration/m1_substrate_test.rs` as `every_loop_node_originates_from_recursive_function_lowering` (folded into existing file to satisfy the SG-0 census ratchet). Speculative `LoopKind` marker retired per `feedback_construction_over_ratchets`. See `docs/briefs/debt-paydown-synthesis-2026-04-25.md` Tier 2 §5.

- **`src/v3/std/` vs `dsl/std/` duplicate-modules checklist undercounts live duplications** (**CHECKLIST EXTENDED** — same `:368` rank-bridge tracking): the file-preference rank bridge at `dag.rs::declaration_name_preference_rank` + `lower.rs::collect_symbols` documents the convergence checklist (see doc comments at those sites for current line anchors). **2026-04-26:** extended the in-source checklist with `std.computation`, `std.induction`, and `std.termination` (`dsl/std/*` ↔ `src/v3/std/*`), closing the undercount left open by exploratory Finding 5 in the PR #809 debt wave (checklist previously listed only `std.effects`, `std.verification`, and the embedded `http_path` mirror). **Remaining dissolution trigger** is unchanged: when every listed duplicate pair converges to a single canonical home, delete the rank scaffold per the comments' shared trigger. Adjacent to `:394` compiler-std consolidation. Surfaced by Exploratory Analysis 2026-04-25 (gpt-5-5-pro Finding 5). P2 Boundary Discipline. Owner: R2 Release Manager B6 dispatch.

Expand Down
34 changes: 34 additions & 0 deletions docs/audit/w-c1-followup-harvest-2026-04-27.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# W-C1 Follow-up Harvest Table (2026-04-27)

**Lane:** Cleanup (W-C1)
**Owner:** session calm-ant-861 (R2-cleanup)
**Dispatch:** tidy-dove-734 inbox #941 → calm-ant-861 inbox #942
**Control surface:** No `ctrl#263` issue exists in repo (PR #263 is a closed/merged bootstrap PR, unrelated). Per dispatch fallback, this single docs/audit artifact is the agreed control surface for the W-C1 cleanup harvest. New rows append here; no per-row issues are opened unless a row's tracking authority demands it.

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.

BLOCKING: This makes a live cleanup-debt control surface authoritative without any ROADMAP entry or ROADMAP link, bypassing ROADMAP.md's tracker rule that internal follow-up state belongs in ROADMAP or docs it links to.


## Disposition legend

- **closed** — finding addressed pre-merge or dissolved by a later landed change.
- **tracked** — finding stands; tracked by an existing ROADMAP row or peer worker; no new authority needed.
- **needs worker** — finding stands; no existing tracker; row below is the authority.

Coordination: bright-wolf-465 owns deeper archaeology for #897/#824/#825. Rows below are kept narrow so they can be dropped/merged when bright-wolf-465 reports.

## Rows

| # | Source PR | Gap | File / Invariant | Owner lane | Dissolution trigger | Acceptance check | Tracking authority | Disposition |
|---|---|---|---|---|---|---|---|---|
| 1 | #900 | NominalOpacity carrier landed as opt-in field, not yet enforced | `src/v3/compiler/src/dag.rs:222` (`pub nominal_opacity: Option<NominalOpacity>`); walker has no fail-closed read | Modeling (#858) | Walker enforces NominalOpacity at every consumer; promote `Option<NominalOpacity>` to non-optional once Secret<T> graduates | `nominal_opacity: None` initialiser at `dag.rs:3689` is gone; walker raises Diagnostic on opacity violation; Secret<T> is the canonical user surface | control-table-only; cross-post to Modeling #858 | needs worker |
| 2 | #900 | Diagnostic for opacity violations is hand-Rust, not authored in `.dag` | (no `.dag` source yet) | Modeling (#858) | Author opacity Diagnostic in `dsl/std/` once walker enforcement lands | Diagnostic emitted from compiled `.dag`, not `src/v3/compiler/src/*.rs` | control-table-only | needs worker |
| 3 | #900 | Test fixture seeded `Some(NominalOpacity{..})` then re-set `nominal_opacity: None`, so the carrier path is not exercised — original BLOCKING (sha 42d4ef41) | `src/v3/compiler/src/dag.rs:3689` trailing `nominal_opacity: None` initialiser still present at HEAD (3a18fa80b) | R2-cleanup | Drop the trailing `None` so the Some-branch is compiled & tested | `grep -n nominal_opacity src/v3/compiler/src/dag.rs` shows no shadowing initialiser; test exercises the Some path | control-table-only | needs worker |
| 4 | #901 | `rest_request_wire_serde_alignment` not closed; opaque-Json removal landed but provider-specific wire shapes still missing — original BLOCKING (sha 6f494af6, 6 findings) | `dsl/extdeps/github/auth.dag` (no scope/expiry evidence on Secret-Manager token); `dsl/extdeps/llm/anthropic.dag` (role/content-block variants collapsed to product); `dsl/extdeps/llm/openai.dag` (role-keyed union flattened) | R2-cleanup or B4-substrate | Model role-discriminated wire carriers (anthropic/openai); model token scope+expiry as typed evidence (auth.dag) before any caller relies on typed-body 200s | Round-trip tests for each provider's wire shape pass; no caller pattern-matches on `Json` for these endpoints | ROADMAP row required (gates typed-body 200 callers) | needs worker |
| 5 | #920 | Bot review absent on merge commit; UCD citation missing from PR body | n/a (process gap) | R1-process / Cleanup | Re-run codex review on merge SHA `40740a6b`; add UCD citation pointer (or back-fill in next docs sweep) | PR #920 has a non-environmental codex review; UCD line present in either PR description or a follow-up docs commit | control-table-only | needs worker |
| 6 | #897 | ~~Annotated-let literal narrowing skips diagnostic-producing range/refinement check~~ | `src/v3/compiler/src/infer.rs` annotated-let literal seed path | R2-cleanup | — | bright-wolf-465 audit (inbox #945, 2026-04-27): annotated-let retry gated with diagnostic path + Diagnostic emission landed pre-merge; later codex re-review approved | — | closed (bright-wolf-465) |
| 7 | #824 | ~~Latest scheduled review env-failed; merge-SHA re-review needed~~ | n/a (review-coverage gap) | R1-process | — | bright-wolf-465 audit (#945): bootstrap snapshots refreshed pre-merge; serializer/tests fixed to Python literals; later codex approved/no findings | — | closed (bright-wolf-465) |
| 8 | #825 | ~~B4.4 carrier wired into fresh-regen but committed bootstrap snapshot + parity loop missing~~ | `src/v3/compiler/src/bootstrap.rs`; `bootstrap_generated.rs` / `bootstrap_generated_without_parse_surface.rs` | R2-cleanup | — | bright-wolf-465 audit (#945): committed snapshots regenerated pre-merge; parity test added; accessor/assert semantics tightened; later codex approved | — | closed (bright-wolf-465) |

## Notes

- Rows 1–3 (#900) are kept distinct because the dissolution triggers are independent (walker, `.dag` Diagnostic authoring, and the fixture compile-shadow bug). Folding them risks losing the fixture row, which is a concrete pre-merge BLOCKING that the env-failed re-review never re-checked.
- Row 5 (#920) is process-only; if R1-process surfaces a recurring bot-review-on-merge gap, promote to ROADMAP rather than expanding rows here.
- Rows 6–8 are `closed (bright-wolf-465)` per audit reported on inbox #945 (sha-cited evidence: #897 fixed by `923c3ccfb`/`f7e334824`/`936ac7cdd`; #824 by `37a8d2033`/`5a08f9e15`/`e0a623a63`/`fb03411df`; #825 by `7fab462e8`/`f035183be`/`9927c14ba`).
- This file is the W-C1 control surface. Future cleanup-lane harvest entries append below the existing rows; do not split into per-PR files.
36 changes: 20 additions & 16 deletions docs/briefs/debt-paydown-synthesis-2026-04-25.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ to PB-* lane.
Summary citations to existing tracking:

- File-preference rank (`dag.rs::declaration_name_preference_rank` + `lower.rs::collect_symbols` — line cites drift on `main`) — ROADMAP `:368`. Trigger: convergence of every duplicated `src/v3/std/` ↔ `dsl/std/` module listed in those doc comments. **PR #809 undercount (computation + induction + termination) closed 2026-04-26** — checklist extended in source + ROADMAP exploratory row.
- Loop emission semantic invariant (Python/Go) — PR #809 row. **Risk-shaped:** comment-level invariant, not structural.
- Loop emission semantic invariant (Python/Go) — PR #809 row. **RESOLVED 2026-04-27:** structural integration test landed in `src/v3/compiler/tests/integration/m1_substrate_test.rs` (`every_loop_node_originates_from_recursive_function_lowering`); audit found closure already holds in production, marker retired. See Tier 2 §5.
- `bootstrap.rs::patch_kernel_bool_boolean_algebra_inhabits` Rust patching (`bootstrap.rs:211-291`) — ROADMAP `:364` (Class 5 Gap 1). Trigger: structural `inhabits` edge.
- `EXTDEPS_BOOTSTRAP_FIXTURES` manual list — ROADMAP `:365` (Class 5 Gap 3 `std.unicode` bootstrap/load-set decision is the parent).

Expand Down Expand Up @@ -297,21 +297,25 @@ dispatch in parallel. Each PR is small.

### Tier 2 — risk-shaped + R2-coupled (S-scope each, dispatch with R2 lanes)

5. **Loop emission semantic invariant** (PR #809 entry). Currently
comment-level; degrades silently if any future PR adds another Loop
source. R2 demos depend on Python/Go emission, so this is R2-coupled.
**Brief MUST start with a construction-closure audit, NOT with a
marker design.** Step 1: enumerate every `Behavior::Loop`
construction site in `lower.rs` (and anywhere else); confirm or
refute that all paths route through recursive-function lowering.
Step 2 (conditional on the audit): if construction-closure holds, the
brief becomes "document the closure invariant as a structural
integration test; retire the speculative `LoopKind` marker idea" —
no new substrate. If it does NOT hold, the marker/test framing
applies and the brief turns into a `LoopKind` lowering-marker spec.
Both proposed paths in the original PR #809 row are bridges; do not
author the marker brief blind. Per `feedback_construction_over_ratchets`,
prefer the structural-closure outcome.
5. **Loop emission semantic invariant** (PR #809 entry). **RESOLVED
(2026-04-27):** construction-closure audit by W-B5 (PR #953) found
exactly two production `Behavior::Loop` construction sites — both in
`src/v3/compiler/src/lower.rs`: `finalize_mutual_clusters` (line 391,
`LoopBound::Descent`, mutual-recursion cluster) and
`lower_fn_item_expr_body` (line 4236, `LoopBound::Cardinality`,
single recursive function). All other `push_loop` callers
(`lib.rs`, `emit.rs`, `dag/builder.rs`) are inside `#[test]` blocks.
**Closure holds**: every production Loop carries provenance traceable
to recursive-function lowering, structurally observable as
"loop.output is the value port of some Behavior::Bind". Receipt
landed in
`src/v3/compiler/tests/integration/m1_substrate_test.rs` as
`every_loop_node_originates_from_recursive_function_lowering` (folded
in alongside the existing substrate receipts to satisfy the SG-0
census ratchet on hand-authored .rs test files). The
speculative `LoopKind` lowering-marker idea is **retired** as a
ratchet-against-not-yet-real-violations per
`feedback_construction_over_ratchets`.
6. **`src/v3/std` vs `dsl/std` checklist undercount fix** (PR #809
entry). **RESOLVED (2026-04-26):** convergence checklist in
`dag.rs::declaration_name_preference_rank` + `lower.rs::collect_symbols`
Expand Down
95 changes: 93 additions & 2 deletions src/v3/compiler/tests/integration/m1_substrate_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use v3_compiler::compile_to_dag;
use v3_compiler::dag::{
ArrowBody, AtomPayload, Behavior, BranchPattern, Dag, DeclarationId, PortState,
TransformTarget, TypeConnective,
ArrowBody, AtomPayload, Behavior, BranchPattern, Dag, DeclarationId, LoopBound, LoopNode,
PortState, TransformTarget, TypeConnective,
};
use v3_compiler::operators::{ArithmeticOp, ComparisonOp, LogicalOp, OperatorKind};
use v3_compiler::Diagnostic;
Expand Down Expand Up @@ -3204,3 +3204,94 @@ fn behavior_port(behavior: Behavior) -> PortId =
dag.diagnostics()
);
}

// ---------------------------------------------------------------------------
// B5 — Loop construction-closure structural receipt.
//
// Audit (W-B5, 2026-04-27): every `Behavior::Loop` in a lowered Dag originates
// from recursive-function lowering. Two production construction sites in
// `src/v3/compiler/src/lower.rs`: `finalize_mutual_clusters` (mutual cluster,
// `LoopBound::Descent`) and `lower_fn_item_expr_body` (single recursion,
// `LoopBound::Cardinality`). All other `push_loop` callers are `#[test]` code.
// Structural signature of recursive-function lowering: the loop's `output`
// port is the `value` port of some `Behavior::Bind` node.
//
// This receipt is the closure-holds proof that retires the speculative
// `LoopKind` marker — closure is structurally observable, no marker needed.
// ---------------------------------------------------------------------------

fn loops_in(dag: &Dag) -> Vec<&LoopNode> {
dag.nodes().iter().filter_map(Behavior::as_loop).collect()
}

fn loop_output_is_a_bind_value(dag: &Dag, loop_node: &LoopNode) -> bool {
dag.nodes()
.iter()
.filter_map(Behavior::as_bind)
.any(|bind| bind.value == loop_node.output)
}

#[test]
fn every_loop_node_originates_from_recursive_function_lowering() {
let src = "\
type IntList = Empty | Cons { head: Int, tail: IntList }

fn count(list: IntList) -> Int = match list {
Empty => 0,
Cons(payload) => 1 + count(payload.tail),
}

fn even(list: IntList) -> Bool = match list {
Empty => true,
Cons(payload) => odd(payload.tail),
}

fn odd(list: IntList) -> Bool = match list {
Empty => false,
Cons(payload) => even(payload.tail),
}
";
let dag = cached_compile_to_dag(src, "loop_construction_closure_receipt.v3");
assert!(
dag.diagnostics().is_empty(),
"fixture should compile cleanly: {:?}",
dag.diagnostics()
);

let loop_nodes = loops_in(&dag);

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.

BLOCKING: The B5 receipt gathers every Loop in the bootstrap-loaded Dag, so the fixture non-vacuity and LoopBound assertions can be satisfied by preexisting std loops rather than the count/even/odd fixture; this leaves the ROADMAP loop-emission closure unproven under P5.

assert!(
!loop_nodes.is_empty(),
"fixture must produce at least one Behavior::Loop, otherwise the closure assertion is vacuous"
);

let mut saw_cardinality = false;
let mut saw_descent = false;
for loop_node in &loop_nodes {
assert!(
loop_output_is_a_bind_value(&dag, loop_node),
"Behavior::Loop {:?} output port {:?} is not the value of any Behavior::Bind \
— would indicate a construction site outside recursive-function lowering",
loop_node.id,
loop_node.output
);
match loop_node.bound {
LoopBound::Cardinality { .. } => saw_cardinality = true,
LoopBound::Descent { cluster } => {
saw_descent = true;
assert!(
(cluster.raw() as usize) < dag.clusters().len(),
"LoopBound::Descent cluster id {:?} must reference a real cluster",
cluster
);
}
}
}
assert!(
saw_cardinality,
"fixture's single-recursive `count` should produce a LoopBound::Cardinality"
);
assert!(
saw_descent,
"fixture's mutual-recursive `even`/`odd` should produce a LoopBound::Descent"
);
}
Loading