Skip to content

Ground #5 per-row costs on ObservationEvent (N+1 join projection) - #7290

Merged
briansrls merged 22 commits into
mainfrom
per-row-cost-receipts-reconciliation
Jul 27, 2026
Merged

briansrls merged 22 commits into
mainfrom
per-row-cost-receipts-reconciliation

Conversation

@briansrls

@briansrls briansrls commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-on to #7284: #5 per-witness cost receipts now ground on std.observation.ObservationEvent as the single record (progress-observation-design §2/§3c). Adds DeclarationSegment/DeclarationGrain (via DeclarationRef), models N+1 events per entry (one shared resolve-phase event + one declaration-grain Concluded per witness), and makes the TSV a complete join projection that refuses missing/multiple parents. WitnessTimingRow is a seed materialized-view Scaffold only. W2 filters the same events (Ambient suppress ≠ receipt deletion).

Preserved from #7284: BasisAbsent typed/counted, both drift directions, arm64 run_ref/host_class=srv_fleet_arm64, executing drift reader, task #20 OpenUnknown.

Test plan

Executed against tip 8b5059cd44 with branch-matched binaries:

./target/release/claim_batch --source-root dag --source-root src/v2 \
  --entry dag/test/claim/observation_model_witness_test.dag \
  --function observation_model_witnesses
# PASS

./target/debug/claim_batch --source-root dag --source-root src/v2 \
  --entry dag/test/claim/witness_row_cost_projection_witness_test.dag \
  --function witness_row_cost_projection_holds
# PASS (N+1 join, missing/multiple parent refuse, shared resolve wall, Refused≠Failed, Ambient retain)

./target/debug/claim_batch --source-root dag --source-root src/v2 \
  --entry dag/test/claim/witness_row_cost_drift_witness_test.dag \
  --function witness_row_cost_drift_comparator_holds
# PASS

Binary provenance (branch-matched)

path target/release/claim_batch
HEAD 8b5059cd4449c83b43c3a10a69457c6189bdcdc6
built 2026-07-26 16:24:06 UTC
size 20615376
sha256 c7a4fc3dca026846d3ceb3284075c851361c6be0782fb75d2f9e83a84415c485

Worker attestation

@gunbai-bot
gunbai-bot Bot force-pushed the per-row-cost-receipts-reconciliation branch from 7b2005e to 8b5059c Compare July 26, 2026 16:01
@gunbai-bot gunbai-bot Bot changed the title PR "per-row cost receipts + decision reconciliation" Ground #5 per-row costs on ObservationEvent (N+1 join projection) Jul 26, 2026
@gunbai-bot
gunbai-bot Bot marked this pull request as ready for review July 26, 2026 16:27
@gunbai-bot

gunbai-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

review 43361 + CI

Verified both findings against current tip (3c77323334).

Finding 1 — *_has_* ObservationSegment walker

Fixed. Segment field reads now go through canonical std accessors in dag/std/observation.dag:

  • observation_subject_entry_path
  • observation_subject_declaration
  • observation_subject_phase_name

witness_cost_subject_has_resolve_phase (and the entry/declaration helpers) consume those accessors; they no longer hand-walk ObservationSegment. Terminal contract text updated; accessors exercised in observation_model_witness_test.

Finding 2 — hand-Rust expansion without checkable receipts

Fixed. WitnessTimingRow scaffold now carries the hand-Rust gate receipts (same shape as the workspace-root interim):

  • dissolve trigger (site + ROADMAP 5-dissolve-patches)
  • explicit deferral naming lane placement-workstream-#5-per-row-cost + ROADMAP row
  • scaffold deletion path (rg WitnessTimingRow src/v1/stage0 == 0)
  • loc_delta_net, discriminating unit test, plan anchor

Authority: docs/plans/progress-observation-design.md#interim-witness-timing-row-scaffold. Floor check: hand_rust_scaffold_receipts_are_checkable_holds in the projection witness.

CI at a689f74 (2 failing)

Root cause was parse/runtime failure in dag/gunbc/witness_row_cost.dag / subject accessors (expected RParen, found Colon on the broken dissolve rewrite; later none→Null non-exhaustive match). Tip fixes both; local green:

  • witness_row_cost_projection_holds PASS
  • observation_model_witnesses PASS
  • witness_timing_rows_refuse_duplicate_entry_resolve PASS

Also addressed prior review 43351: transition→Bool predicates route through witness_cost_concluded_outcome; seed HashMap duplicate overwrite refuses.

@gunbai-bot

gunbai-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

review 43373 — not a deletion on this PR; fixed by rebase

Verified against the tree before and after.

This branch never deleted orch_if_arm_body_or_noop, the empty-arm regression tests, or pipeline_steps_empty_arm_note. Those landed on main in #7282 (b9d51216f3) after this branch diverged (merge-base afd33913ba). Relative to current main the three-dot review view looked like a drop; two-dot / file history shows zero edits to those paths in this PR’s own commits.

Fix: rebased onto current origin/main. Tip now carries #7282 intact:

  • orch_if_arm_body_or_noop at 05_emit_orchestration.dag:473 (wired at :494 / :515)
  • four orch_if_*_noop_holds witnesses at orchestration_emit_test.dag:218–260
  • pipeline_steps_empty_arm_note at orchestration.dag:94

git diff origin/main...HEAD for those three files is empty. ObservationEvent / #5 cost work unchanged on tip.

@gunbai-bot
gunbai-bot Bot force-pushed the per-row-cost-receipts-reconciliation branch from 3c77323 to 475c001 Compare July 26, 2026 17:13
@gunbai-bot

gunbai-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

review 43383 — addressed

Verified: witness_cost_is_entry_resolve_event / witness_cost_is_declaration_witness_event still Bool-filter over witness_cost_concluded_outcome Optional (lines cited). Finding text allows canonical extract or a valid disposition receipt; prose alone does not discharge.

Disposition: witness_cost_role_bool_filter_disposition = Scaffold { dissolves_to: SingleAuthority, bind: witness_cost_concluded_outcome } plus dissolve-on note. Floor check: role_bool_filter_disposition_receipt_holds in the projection witness (green).

Why not full dissolve in this tip: rewriting the count/project folds to match the Optional Present/Absent inline (no Bool nickname) hits a live parser defect (expected RParen, found Colon on nested Present => match / fn-fold rewrites of those call sites). Transition→Bool matching stays dissolved via witness_cost_concluded_outcome (review 43351); the residual is subject×Optional→Bool role filters under the typed scaffold.

@gunbai-bot

gunbai-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

review 43399 — fixed

Verified: witness_cost_subject_has_resolve_phase was a has_* Optional→Bool predicate not named by the role-filter scaffold.

Fix: deleted it. Phase membership is read through canonical observation_subject_phase_name and inlined inside witness_cost_is_entry_resolve_event (still under witness_cost_role_bool_filter_disposition). Disposition note + projection witness assert the deletion (has_resolve_phase deleted / review 43399).

Tip: 657727305ba8.

Brian Searls and others added 8 commits July 26, 2026 17:59
Add DeclarationSegment/DeclarationGrain, project_witness_cost_receipt with
refuse-on missing/multiple parents, and mark WitnessTimingRow as a seed
materialized-view Scaffold. Rebased onto main after #7284 merge.

Co-authored-by: Cursor <cursoragent@cursor.com>
none materializes as Null and breaks Present/Absent matches in
witness_row_cost and observation_model witnesses (CI-blocking).

Co-authored-by: Cursor <cursoragent@cursor.com>
Finding allows canonical extract or a valid disposition receipt; prose was
insufficient. Bind the interim is_* filters to witness_cost_concluded_outcome
and assert the receipt in the projection witness. Nested Present=>match fold
rewrites that would fully dissolve the Bools currently fail to parse.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot
gunbai-bot Bot force-pushed the per-row-cost-receipts-reconciliation branch from 6577273 to c825ac6 Compare July 26, 2026 17:59
Brian Searls and others added 2 commits July 26, 2026 18:14
Require EntrySegment-only (no module/declaration) for the N+1 resolve parent, classify via Optional<WitnessCostEventRole> instead of is_* Bool filters, and add collision + role REDs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

review 43409 — addressed

Verified both findings against tip before the fix; both were real.

Finding Disposition
Any concluded PhaseSegment("resolve") counted as entry parent Fixed — EntryResolveParent requires entry-level subject shape: Entry present, Module Absent, Declaration Absent, phase=resolve, Concluded. Nested declaration/module resolve events are Absent in the role extract (not parents). Collision RED: nested_resolve_phases_do_not_count_as_entry_parent_holds
Unbounded is_* Bool-filter Scaffold Fixed — deleted witness_cost_is_* + witness_cost_role_bool_filter_*. Classification is witness_cost_event_role → Optional<WitnessCostEventRole>; folds match the extract. Canonical observation_subject_module_path added beside the other subject accessors

Local green: witness_row_cost_projection_holds, w_declaration_segment_key_and_grain_totality_holds.

— sent from bold-deer-322

@gunbai-bot

gunbai-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

review 43423 — addressed

Verified: the projection witness imported both std.types.String and v2.std.text.String (import-order-dependent bare String).

Fixed: dropped String from the std.types import; kept v2.std.text.String, matching gunbc.witness_row_cost and witness_row_cost_drift_witness_test.

Local green: witness_row_cost_projection_holds.

— sent from bold-deer-322

Brian Searls and others added 3 commits July 26, 2026 18:47
Bare `rustfmt` can ENOENT on srv fleet hosts that expose a cargo shim without CARGO_HOME/bin on PATH (CI #7290 regen on srv3-03); cargo fmt still worked. Prefer the absolute toolchain path from rustup.

Co-authored-by: Cursor <cursoragent@cursor.com>
…w 43429).

Duplicate entry-resolve parents now refuse via WitnessCostProjection from witness_cost_check_unique_resolve_parent inside project_witness_cost_receipt — no role→Bool walker.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

review 43429 — addressed

Verified: witness_cost_any_entry_has_multiple_resolves was a has_* → Bool fold over WitnessCostEventRole beside the typed projection path.

Fixed: deleted it. project_witness_cost_receipt now matches EntryResolveParent into witness_cost_check_unique_resolve_parent → WitnessCostProjection (Complete empty / Refused), same append path as declaration arms — no Bool nickname over the role.

Local green: witness_row_cost_projection_holds.

— sent from bold-deer-322

Review 43439: drop the hand-Rust resolve_rustfmt_bin expansion (out of scope for #5, no hand-Rust receipt). Keep bare rustfmt spawn and prepend a fail-closed PATH locate step to the regen job shell so cargo-shim hosts still find rustfmt.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

review 43439 — addressed

Verified: resolve_rustfmt_bin / rustup_bin_candidates (~70 LOC hand-Rust) had no hand-Rust gate receipts (only the WitnessTimingRow scaffold was receipted).

Disposition — removed from this PR (the review’s allowed alternative to receipts): reverted regen_stage0.rs to bare Command::new("rustfmt") as on main.

CI root fix (not hand-Rust): the srv3-03 failure was PATH anemia (cargo shim without $CARGO_HOME/bin). ci_regen_ensure_rustfmt_path_command now runs at the start of the regen job shell (authority gunbc.ci_spec, projected in ci.yml) and refuses if rustfmt cannot be located.

— sent from bold-deer-322

Brian Searls and others added 3 commits July 27, 2026 01:22
ci_spec cannot import ci_workflow_run_emit (materialization cycle); keep the
Pipeline + Scaffold + dissolve marker on a dedicated emit surface so review
43639's medium-as-string block stays fixed without reopening the cycle.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Disposition — review 43639 (codex REQUEST_CHANGES)

Verified against tip 2c070ad876.

Finding: ci_regen_ensure_rustfmt_path_command as a bare shell String in ci_spec (medium-as-string / missing Scaffold dissolve).

Fix: Replaced with a structural Pipeline of atomic PATH-probe Do steps + Comment dissolve marker, emitted through orch bash-emit:

  • src/v2/workflow/ci_regen_rustfmt_path_emit.dag — thin emit surface (kept out of ci_workflow_run_emit so gunbc.ci_spec can import it without the ci_materialization ↔ ci_spec cycle that module's sccache injection closes)
  • ci_regen_ensure_rustfmt_path_shell_emit_scaffold — typed Scaffold with dissolve-on through isolate+pin by construction / typed toolchain probe (#5828 / ROADMAP 6-shell-slice0)
  • .github/workflows/ci.yml regen step carries the # 🟡 dissolve-on: line (drift gate green: witness_committed_is_fixed_point)
  • RED/golden receipts in ci_regen_rustfmt_path_emit_test.dag (4/4 PASS locally)

Path behavior unchanged (CARGO_HOME → /opt/cargo → HOME/.cargo → rustup which → refuse).

Brian Searls and others added 2 commits July 27, 2026 02:16
review 43658: control flow must not live as bash-in-String wrapped by
orch_bash_do. Probes, PATH export, and refusal are orchestration nodes;
only atomic test/command/export/dirname leaves remain (FileExists PR2b).

Co-authored-by: Cursor <cursoragent@cursor.com>
@gunbai-bot

gunbai-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Disposition — review 43658 (codex REQUEST_CHANGES)

Verified against tip after this push.

Finding: PATH ensure still stored executable bash control flow as String values wrapped by orch_bash_do (medium-as-string).

Fix: Rewrote ci_regen_rustfmt_path_emit so control flow is structural orchestration:

  • If + And / Not / StrNonempty / ExitZero for probes
  • DiscardAll / DiscardErr + IgnoreFail on leaf Runs
  • Let + ExprCmdSubst for dirname
  • Exit { status: "1" } for the refusal arm
  • Leaf Strings remain only for irreducible kernel ops (test -x, command -v, export PATH=…, rustup-which assign) until FileExists + session-EnvExport (named PR2b / dissolve-on)

Golden + structural RED witnesses green; witness_committed_is_fixed_point green.

@briansrls
briansrls merged commit c629a4f into main Jul 27, 2026
5 checks passed
@briansrls
briansrls deleted the per-row-cost-receipts-reconciliation branch July 27, 2026 03:22
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