Repository navigation
model(v4): ctrl#1533 phase-1 — value-carrier declarations (M-A) + identity laws (M-C) with executable witnesses - #4660
Conversation
Context-scoped MutationCounters on the copy-on-update primitives (map_insert/merge/list_push/concat/set ops: calls + entries copied — the triangular/quadratic receipt), thread-local flatten counters on the free_monoid_to_vec chokepoint (fires inside Value::eq, so no ctx; two fixed-size integers, not a cache), and a sharing-aware retained-value byte accounting walk (per-variant counts/bytes, visited-set dedup) on InterpContext. claim_batch prints the report under GUNBC_INTERP_STATS=1. Receipt on the real v4 gate workload (7 affected_testgen witnesses, all PASS): native mutation primitives 0 calls — v4 collections are closure chains + FreeMonoid trees, so the host copy cost rides the flatten chokepoint, confirming ctrl PR #1534's layer analysis. Retained: 21.8 MB / 219K allocations (Record 12.7MB with 48K sharing hits; 31K un-interned Strings) — the M-D interning/positional-record receipt baseline. Read-only tooling per ctrl#1533 phase 0; no semantic change to any evaluation path (counters + opt-in report only). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…latten in claim_batch Review #28288 (cursor/composer-2.5) on #4653: the copy-work counters mixed definitions across dispatch paths, breaking the single-receipt property (P2). - One definition per counter, by operation semantics, not dispatch path: add-one ops (map_insert/list_push/set_insert) count the receiver's pre-existing entries; merge ops (map_merge/list_concat/set_union) count both operands' entries. Method .concat/.append/.push buckets by what the arg IS (collection -> concat, atomic -> push); binop + and builtins agree. - set_union gets its own row (was folded into set_insert — same P2 class). - builtin map_merge instrumented (was counted on the method path only). - claim_batch fm_flatten row is now a delta sampled across the witness loop, matching the context-scoped counters next to it. Tests pin the unified semantics: concat counts both operands (9 for the 3⊕1 then 4⊕1 chain), atomic append lands in list_push with receiver-only copy-work, and neither bucket leaks into the other. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…arrier_laws; strengthen insert-order witness to 3 keys Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Re claude/opus-4-7 review (REQUEST_CHANGES): Finding 1 (missing Finding 2 (method-style Finding 3 (witnesses are structural restatements, advisory) — partially addressed, remainder is phase-2 scope by design. Strengthened the insert-order witness to 3 keys across 3 insertion orders in the same commit. On the broader point: these phase-1 witnesses pin the language-observable laws (equality/sharing/association semantics) before any host change exists — that's the model-first sequencing from ctrl#1533/#1534. A witness that could detect leaked reference identity or exercise large-n boundaries requires the phase-2 carrier swap to exist first; the phase-2 PR is required to extend this gate with swap-specific probes (and the phase-0 measurement harness from #4653 provides the allocation-level observability these Bool witnesses intentionally don't duplicate). All 7 witnesses pass post-fix via claim_batch. — sent from neat-ibex-297 |
Summary
Phase 1 (modeling) of ctrl#1533 (persistent-structures value representation), placed at the v4.std authority per the ctrl#1534 placement amendment (§3–4). Model-first: no host behavior changes — this PR declares the facts the phase-2 host carrier swap must implement and the laws it must preserve.
src/v4/std/value_carrier.dag, new):PersistenceKind(Ephemeral | Persistent — disambiguated fromstd.compute_fabric.PersistenceKind, which is storage durability),CarrierCost,CarrierDeclaration, and the two data valuesmap_carrier(HAMT, Bagwell 2001) andlist_carrier(RRB tree, Bagwell & Rompf 2011 — must realize the FreeMonoid algebra without per-site flattening). This is the "unified runtime representation" that theB-LIST-FREEMONOID-1/B-MAP-LOOKUP-OPTION-C-1interims dissolve against. The sharing law (sharing is unobservable) is declared as executable witnesses rather than a receipt type — a receipt type would have no constructor until phase 2 lands, and dead vocabulary is the Practice-4 failure mode.src/v4/std/runtime.dag):IdentityEvidence = ReferenceIdentical | StructurallyCompared { equal: Bool }plus theidentity_evidence_equalprojection. Variant-is-data shape makes Law 1 (reference-identical ⇒ structurally equal) hold by construction —ReferenceIdenticalhas noequal: falsearm to violate it. Law 2 (keyed-aggregate equality/hash are order-independent) is documented at the type and witnessed below.src/v4/test/claim/std_grounding/value_carrier_laws.dag, new): 7 Bool witnesses with co-locatedUnifiedTestClaimglob-discovery registrations — sharing unobservability (list + map), insert-order / overwrite-path independence of map equality, FreeMonoid association unobservability, Law-1 projection, and carrier-declaration resolution. These are the behavior-preservation gate the phase-2 carrier swap must keep green.Phase-0 receipts motivating the model (PR #4653, merged as c1cdc9b): v4 workloads make zero native mutation-builtin calls — copy cost rides the
free_monoid_to_vecflatten chokepoint (185 calls / 770 items on the 7-witness gate); 21.8 MB / 219K allocations retained; 31.8K un-interned Strings.Scope note: M-B (per-primitive cost facts on
PrimitiveContract) and M-D (interning facts) are deferred to a follow-up PR — thePrimitiveContractextension shape deserves its own review.Practice-4 disposition marks applied to both new coproducts (
PersistenceKind🟢 terminal, grounded in Driscoll–Sarnak–Sleator–Tarjan 1989;IdentityEvidence🟢 terminal, variant-is-data already applied).Test plan
claim_batch --entry src/v4/test/claim/std_grounding/value_carrier_laws.dag --functions <all 7> --claim-run— 7/7 PASS (post-merge of origin/main provenance wave-2).python3 scripts/check_v4_layering_imports.py— OK.scripts/v4-testclaim-smoke-roster.sh— run post-merge with rebuilt release binaries: 15/15 groups green at flip time, includingcomprep_eval_by_execution(a failure there observed mid-development was verified pre-existing at the merge base — reproduced with this branch's files absent — and is fixed by main's provenance wave-2: global SpanIndex coherence across memoized parse cells (F1 prov threading + F2 span_index_merge + F4 edit_locus off-tree consumer) #4654, now merged in). The run was still grinding through wave-2'sedit_locus_source_provenance_affected_set_wirewitness (15+ min at 100% CPU; untouched by this diff) when the PR flipped ready; CI is authoritative.scripts/v4-claim-corpus-execution-map.sh— running post-merge, 51+ witnesses executed with no failures at flip time.