Skip to content

docs: design interprocedural cost (complexity-gate S3) — binding_id-keyed callee summaries, fail-closed recursion, substrate-gated activation - #4675

Merged
briansrls merged 6 commits into
mainfrom
session/swift-bat-315
Jun 11, 2026
Merged

briansrls merged 6 commits into
mainfrom
session/swift-bat-315

Conversation

@briansrls

@briansrls briansrls commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Worker attestation

  • Title describes the change (not the session id or branch).
  • PR body summarises what and why.
  • Tests run: docs-only change (one new markdown file); no tests changed — relied on CI.
  • No work item issue to close (design doc under the complexity-gate planning lane).
  • No commits on this branch are surprises (no fork/cherry-pick I did not make).
  • No secrets / credentials / large binaries staged.

Summary

Design-only doc for complexity-gate S3: closing the soundness gap where a call site costs unit_cost() regardless of the callee's body (src/v4/lens/cost.dag:206), so a superlinear helper hides behind every caller as O(1). Follows the merged S1 (#4668/#4669, design-lens-subject-supply.md) and S2 (#4673) rungs; no code lands here.

Key decisions pinned by the doc:

  • One fold, one algebra: S3 is an additive lens module composing existing pieces — per-declaration cost_lens summaries keyed by binding_id (Implement brand-identity side-channel phase plan for A3/PD-3: equivalence-first ident channel + honest ident_span gates #4581 callee channel, never name strings), call edges via the canonical Transform-callee accessor, substitution via the existing symbolic_sequential/symbolic_product algebra. The single consult hook in cost.dag's fold is explicitly flagged as an operator-STOP escalation, preferred over a shadow fold.
  • Recursion is not an S3 problem (reworked per operator feedback): recursive surface forms lower via CallPattern classification onto the closed iteration primitives (INVARIANTS "Recursive Syntax Is Sugar", DB-9), so a well-formed lowered call graph is acyclic by construction and recursion is priced by the existing Loop treatment. SCC/self-edge fail-closure survives only as an integrity backstop against lowering defects (ClassUnknown → red, never silently green). The earlier draft's "P2" (witness-refined SCC summaries at the lens level) is now an explicitly rejected alternative — it would re-derive at analysis time what the lowering establishes structurally (second-path ban). §3.1 additionally pins the operator's no-steady-state-unknowns rule: the CallPattern taxonomy is closed and exhaustive (same-argument "forever" loops lower to repeat(Forever), a named finite bound — not unknown; mutual recursion via DB-9 cluster facts), so every ClassUnknown over lowered code is a defect or modeling-gap work item, never a tolerated category.
  • Substrate-gated activation: nothing implements until the COMPREP callee-dispatch wave admits a call-containing subject; S3 must land no later than the first call-containing roster row, with consult/cycle-backstop/missing-summary perturb reds specified up front.

Test plan

  • Docs-only; no tests changed — relied on CI.
  • Spot-checked the doc's code anchors: base_cost_for_behavior Transform→unit_cost() at src/v4/lens/cost.dag:206, interim eval_transform_callee_edge at src/v4/compiler/05_eval.dag:1371, CallPattern lowering table at dsl/std/computation.dag:192, iteration-primitive closure at dsl/std/iteration.dag:1.

Brian Searls and others added 3 commits June 11, 2026 12:50
…ss subjects via the COMPREP source-bridge (no reflection)

The handoff seam between the landed COMPREP body producer and the landed
cost/complexity lens stack: subjects come from source-as-data through the
compiler's own pipeline (the post-ban-sanctioned COMPREP pattern), extracted
via the canonical arrow_body_target_lookup accessor, folded through cost_lens
and projected via complexity.dag, gated by complexity_bound_dominates with
fail-closed Rejected→false. Rejects host-boundary supply (bootstrap-seed
growth + second body-access path) and body_of sugar (operator-STOP surface,
unneeded). Subject coverage rides the COMPREP wave ladder, honest-labeled.
First consumer: complexity-gate exemplar row (S1a, adhoc-4e07f6f5-ebc).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@briansrls
briansrls marked this pull request as ready for review June 11, 2026 15:57
@briansrls briansrls changed the title fable (planning) docs: design interprocedural cost (complexity-gate S3) — binding_id-keyed callee summaries, fail-closed recursion, substrate-gated activation Jun 11, 2026
Brian Searls and others added 3 commits June 11, 2026 16:43
… cycles demoted to a defect backstop, witness-refined SCC phase (P2) rejected as a second path

Recursive surface forms lower via CallPattern classification onto the closed
iteration primitives (DB-9, dsl/std/iteration.dag), so a well-formed lowered
call graph is acyclic by construction and recursion is priced by the existing
Loop treatment. The prior draft treated recursion as a lens-level SCC problem
with a later termination-witness refinement phase — that re-derives what the
lowering establishes structurally (second-path ban). SCC fail-closure survives
only as an integrity backstop against lowering defects.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@briansrls
briansrls merged commit 20f9acc into main Jun 11, 2026
10 checks passed
@briansrls
briansrls deleted the session/swift-bat-315 branch June 11, 2026 17:00
briansrls pushed a commit that referenced this pull request Jun 11, 2026
…sUnknown-budgets-are-errors amendment over the pre-amendment text from squash-merged #4675)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.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