Skip to content

v4 infer: remove v4.lens.cost / SymbolicCost (C1 cherry-pick from PR #3441) - #3445

Merged
briansrls merged 3 commits into
mainfrom
session/smart-boar-330-c1-infer-lens-cost
May 20, 2026
Merged

briansrls merged 3 commits into
mainfrom
session/smart-boar-330-c1-infer-lens-cost

Conversation

@briansrls

@briansrls briansrls commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Salvaged C1 from the Wave-1 Worker C PR (#3441 / tidy-eagle-109). The P3 commitment 4 violation removal is clean, self-contained, and worth landing on its own; the rest of #3441 needs re-doing under the post-Pass-B / post-Practice-11 framing and lands as Wave-2 corrections.

What

src/v4/compiler/04_infer.dag was importing v4.lens.cost { SymbolicCost } and carrying cost: SymbolicCost as a field on InferredFacts. That makes cost-lens a compile-core fact rather than a lens-side dimensional projection over InferredTree. Per the v4 design doc's P3 commitment 4 (no specific lens imports in compiler-core) and Q14b rejection (cost-lens cannot drive compile-core target selection), this import is a hard violation.

Changes

src/v4/compiler/04_infer.dag only — 4 hunks:

  • Header // Consumes: line — strip v4.lens.cost
  • Import block — remove import v4.lens.cost { SymbolicCost }
  • Type InferredFacts — remove cost: SymbolicCost field
  • RULING-1 comment — cost/inhabitance coordinates remain T-9/T-12 bridged → inhabitance coordinates remain T-9 bridged (T-12 was the cost-lens task; no longer referenced from infer)

What was kept (and why)

  • inhabits: AlgebraRef — algebra inhabitance is a real grounding fact required by T-9.
  • descent: TerminationProof — termination is a semantic validity witness for grounding, NOT a cost/complexity projection. Out-of-scope follow-up could rename to descent_witness for clarity, but the current name is not a P3 violation.

Where cost-lens still lives

Cost / complexity / SymbolicCost remains a legitimate concept — it lives lens-side per the lens framework. validate_then_compile can gate on complexity via a required lens (e.g. [ComplexityLens(max = Linear)]); coercion_fold cannot consult it. Per Ratified Q14b in the v4 design doc, cost-lens-driven compile-core target selection is explicitly rejected.

Wave-1 disposition context

This PR is the C1 cherry-pick from the larger Wave-1 disposition. The other parts of #3441 are NOT pulled here:

  • C2 (extdeps/file_system.dag with NodeFileBinding) — concept-home boundary violation (extdeps shouldn't know about Node); needs re-do under Practice 11 companion discipline.
  • C3 (std/outcome.dag + NodeOutcomeFold) — uses legacy Produced/Rejected{diagnostic} Outcome shape + algebra signature gives policy authority to the algebra instead of the combinator; needs re-do against ratified Outcome shape + combinator-owns-policy discipline.

Both C2 and C3 will be dispatched as Wave-2 corrections under a corrected brief; PR #3441 will be closed after this one lands.

Test plan

  • Manual review confirms only 04_infer.dag touched
  • grep confirms no other file references cost: SymbolicCost or SymbolicCost from 04_infer.dag's context (cost-lens-side SymbolicCost is fine and stays)
  • CI green

🤖 Generated with Claude Code

briansrls and others added 2 commits May 20, 2026 15:43
…ommitment 4)

P3 commitment 4 (per docs/design-v4-compiler-homomorphism.md): compiler
core must not import specific lens names. 04_infer.dag was importing
v4.lens.cost { SymbolicCost } and carrying cost: SymbolicCost as a
field on InferredFacts. That makes cost-lens a compile-core fact
rather than a lens-side dimensional projection over InferredTree.

Salvaged from PR #3441 (Worker C / tidy-eagle-109, Wave-1) which
authored this fix correctly. The rest of #3441 carried changes that
need re-doing under the post-Pass-B / post-Practice-11 framing
(extdeps/file_system.dag NodeFileBinding boundary violation;
std/outcome.dag using legacy Outcome shape; NodeOutcomeFold.step
seeing Outcome<R> instead of R). Those land in a separate Wave-2
correction; this PR pulls out the one piece that's clean,
self-contained, and a real P3-violation removal worth landing on
its own.

Changes (4 hunks, src/v4/compiler/04_infer.dag only):
- Header // Consumes: line — strip v4.lens.cost
- Import block — remove import v4.lens.cost { SymbolicCost }
- Type InferredFacts — remove cost: SymbolicCost field
- RULING-1 comment — update 'cost/inhabitance coordinates remain T-9/T-12 bridged' → 'inhabitance coordinates remain T-9 bridged' (T-12 was the cost-lens task; no longer referenced from infer)

Other fields kept:
- inhabits: AlgebraRef — algebra inhabitance is a real grounding fact
- descent: TerminationProof — termination is a semantic validity
  witness for grounding, NOT a cost/complexity projection (would
  potentially be renamed descent_witness for clarity in a follow-up,
  but the existing name is not a P3 violation; out of scope here)

Cost / complexity / SymbolicCost remains a legitimate concept; it
lives lens-side per the lens framework (P3 commitment 4 + Q14b
rejection of cost-lens-driven compile-core selection in the v4 design
doc). validate_then_compile can gate on complexity via a required
lens; coercion_fold cannot consult it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@briansrls briansrls changed the title V4 work v4 infer: remove v4.lens.cost / SymbolicCost (C1 cherry-pick from PR #3441) May 20, 2026
@briansrls
briansrls marked this pull request as ready for review May 20, 2026 19:48
…sor exploratory)

cursor flagged on PR #3445 that the InferredFacts cost-field removal
in 04_infer.dag leaves two claim scaffolds constructing
InferredFacts { cost: ... } and assumed they were inert. They are
not — both are scaffold-data files that construct InferredFacts
values; v2-compile would fail without this cleanup.

FIX (same PR, atomic with the 04_infer.dag change):

src/v4/test/claim/manual/infer_emit_compile_anchor.dag:
- Header // Owns: drop anchor_stub_cost
- Header // Consumes: drop lens/cost.dag
- import v4.lens.cost { SymbolicCost, UnknownCost } removed (now unused)
- data anchor_stub_cost: SymbolicCost = UnknownCost { ... } removed
- anchor_stub_inferred_facts: cost: anchor_stub_cost field removed

src/v4/test/claim/workflow/pipeline_rejections.dag:
- import v4.lens.cost { UnknownCost } removed (now unused)
- workflow_inferred_facts(): cost: UnknownCost { ... } field removed

Final sweep verified (grep across src/v4/):
- Zero remaining 'import v4.lens.cost' statements
- Zero remaining 'cost: SymbolicCost' field constructions
- All InferredFacts {} construction sites use the new field shape

Other 'cost:' matches in src/v4/ are unrelated:
- src/v4/lens/registry.dag — lens registry entry (lens-side, fine)
- src/v4/extdeps/languages/*.dag — per-target language model
  declared costs (operation_cost, instruction_cost, etc.), unrelated
  to compiler-core InferredFacts

cursor's APPROVE on PR #3445 stands; this fix is the hidden-blocker
the exploratory observation surfaced. PR now atomic + CI-safe.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@briansrls

Copy link
Copy Markdown
Contributor Author

@cursor exploratory observation upgraded to in-PR fix in commit a12d49559.

You were right that two claim scaffolds construct InferredFacts { cost: ... }, and on second look those files are NOT inert — they are scaffold-data files that v2-compile would fail on after the cost: field removal. Treated as a hidden BLOCKING rather than an out-of-PR follow-up since merging without them would break CI.

Cleanup (same PR, atomic):

src/v4/test/claim/manual/infer_emit_compile_anchor.dag:

  • Header // Owns: drops anchor_stub_cost
  • Header // Consumes: drops lens/cost.dag
  • import v4.lens.cost { SymbolicCost, UnknownCost } removed (now unused)
  • data anchor_stub_cost: SymbolicCost = UnknownCost { ... } declaration removed
  • anchor_stub_inferred_facts: cost: anchor_stub_cost field removed

src/v4/test/claim/workflow/pipeline_rejections.dag:

  • import v4.lens.cost { UnknownCost } removed (now unused)
  • workflow_inferred_facts(): cost: UnknownCost { ... } field removed

Final sweep:

  • grep -rn "import v4.lens.cost" src/v4/ → zero hits
  • grep -rn "cost: SymbolicCost" src/v4/ → zero hits
  • All InferredFacts {} construction sites match the new field shape

Other cost: matches in src/v4/ are unrelated lens-side / per-target-language declared costs (operation_cost, instruction_cost, etc. in extdeps/languages/*.dag; lens_registry_v0_cost in lens/registry.dag) — those are correctly lens-side, not compiler-core, and stay.

PR now atomic and CI-safe. Your APPROVE on the 04_infer.dag change stands.

@cursor

cursor Bot commented May 20, 2026 •

Copy link
Copy Markdown

I validated that PR comment end-to-end, and it is already fully applied in this branch (including commit a12d49559).

  • Confirmed cleanup is present in all three files:
    • src/v4/compiler/04_infer.dag no longer imports v4.lens.cost, and InferredFacts no longer has cost.
    • src/v4/test/claim/manual/infer_emit_compile_anchor.dag no longer carries anchor_stub_cost/cost import, and anchor_stub_inferred_facts has no cost field.
    • src/v4/test/claim/workflow/pipeline_rejections.dag no longer imports UnknownCost, and workflow_inferred_facts() has no cost field.
  • Final sweep checks:
    • import v4.lens.cost in src/v4 → no matches
    • cost: SymbolicCost in src/v4 → no matches
    • InferredFacts { ... } constructors found only in expected locations and all match new shape.

I also ran the v4 compile gate to ensure CI-safety posture is intact:

  • target/debug/v2-compiler compile --output-dir /tmp/v4-compile-out --source-root src/v4
  • Result: compiled: 85 files emitted, 0 diagnostics

No additional code changes were needed.

Open in Web Open in Cursor 

@briansrls
briansrls merged commit f4a3830 into main May 20, 2026
6 checks passed

@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: a12d4955 · Trigger: schedule
  • Thinking: 96s wall

Non-blocking — Strengths

  • src/v4/compiler/04_infer.dag Removing SymbolicCost from InferredFacts keeps cost authority in v4.lens.cost instead of carrying a parallel infer-stage fact.

ROADMAP — Verified

  • T-12 cost lens authority: src/v4/TASKS.md makes cost/complexity a lens task depending on T-9, so this PR preserves the intended infer-to-lens direction.

✅ No blocking concerns.

@briansrls
briansrls deleted the session/smart-boar-330-c1-infer-lens-cost branch June 1, 2026 18:43
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