Skip to content

Fix: Count the fixed_restore copy in the saved figure (#481) - #1067

Merged
amiddavid merged 2 commits into
mainfrom
fix/481-fixed-restore-ops
Nov 11, 2026
Merged

amiddavid merged 2 commits into
mainfrom
fix/481-fixed-restore-ops

Conversation

@boazdavid

@boazdavid boazdavid commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • With expand.fixed_restore, every later turn sends a restored copy of the output the model asked for.
  • The dashboard still credited the full compaction on those turns.
  • This PR reports the copy to the accountant, counts it in TokensAfter, and stores its size per request.

Fixes #481.

What we found

Reproduced on origin/main with a real recorder: one in-band expand, then three later turns.

Before After
Saved credited on each later turn 2,167 tokens 0
Overview saved_gross 8,668 2,167
Accountant on later turns ops_dropped (books nothing) prices the turn
SafetyCost.RestoredTokens 2,200 (the expand turn only) adds the copies the later turns carried

Why it happens

  • finishRestore inserts the copy after the pipeline ran. The pipeline's TokensAfter did not include it.
  • finishRestore also dropped every accountant operation, because the insert shifts wire indexes. So the accountant booked no saving at all on those turns, and the token figures kept the old credit.
  • The proxy knew the copy's size (Result.RestoredTokens) and only wrote it to the log.

What changed

  1. finishRestore keeps the pipeline's operations. It adds one context-guru.expand_restore operation for each copy: a message splice, the wire size of the copy, and a ChangeID from the marker id. The accountant library already prices this shape (case rewrite/fixed-restore-cost/hot/5m), so the library is not changed.
  2. finishRestore adds the copy's tokens to the run's TokensAfter.
  3. expand_restore is an envelope component in dash. Without it the accountant falls back with figure_without_row.
  4. New requests.restored_tokens column (additive, default 0). SafetyCost.RestoredTokens is ExpandTokens plus the stored copies.

How it was tested

  • New proxy/restore_savings_test.go: three tests through a real recorder. The control with fixed_restore off passes before and after. The other two fail before this change.
  • apply/ops_restore_test.go: the old test that pinned the drop is replaced by tests for the kept operations, the restore operation, TokensAfter, and the order of several copies.
  • go test passes for dash, apply, proxy and expand. go vet and gofmt are clean.
  • config has one failure, TestStrategyTableMatchesPlugin (python3 -I cannot read settings.py). This PR does not touch that file. I did not run it on a clean main.

Open questions

  • SavedAdjusted is unchanged (SavedUnique - ExpandTokens). SavedUnique is counted once per content and the copies are counted once per turn, so netting them would make it negative. Should it change?

  • No test asserts a priced dollar saving on a restore turn. Logs show later turns no longer fall back.

  • With fixed_restore off, the original goes back in place. The control test shows the figure is already right there.

  • Data dependence: requests.restored_tokens is metadata only. It is a token count per request. It stores no content, and no component depends on it.

Technical notes

  • The restore operation is the last one in pipeline order. The library maps the earlier operations through its splice (accountant design 4.3), so the pipeline's operations need no index shift.
  • When insert appends the copy at the end (a count-changing pipeline whose anchor cannot be proven), the position is the end of the pipeline's body. The operation uses that position.
  • If a copy cannot be placed in the final body, all operations are dropped, as before.
  • The test's fake upstream bills len(body)/5 tokens. At /4 the accountant's plausibility check rejects the request, because the fake usage disagrees with the host's estimate.

Assisted-By: Claude (Anthropic AI) [email protected]

… it in the saved figure (#481)

With expand.fixed_restore, a later turn sends a restored copy of the
output the model asked for. The dashboard still credited the full
compaction on every one of those turns.

- finishRestore no longer drops every accountant operation. It keeps
  the pipeline's operations and adds one context-guru.expand_restore
  operation for each copy: a message splice with the wire size of the
  copy and a ChangeID from the marker id. The accountant library
  already prices this shape (case rewrite/fixed-restore-cost/hot/5m).
  A later turn no longer falls back with ops_dropped.
- finishRestore adds the copy's tokens to the run's TokensAfter, so a
  turn that carries the copy is not credited a saving.
- expand_restore is an envelope component in dash. Without it the
  accountant falls back with figure_without_row.
- New requests.restored_tokens column. SafetyCost.RestoredTokens is
  ExpandTokens plus the stored copies.

SavedAdjusted is unchanged: SavedUnique is counted once per content,
and the copies are counted once per turn.

Tests: restore_savings_test.go drives an in-band expand and three
later turns through a real recorder. The control with fixed_restore
off passes before and after. Two tests fail before this change.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: DAVID BOAZ <[email protected]>

@boazdavid boazdavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @boazdavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.241 offload-review skill, @boazdavid's session fresh 2 of 2 1 of 2 5373859e9999 blocking

Verdict: blocking

Findings

  1. apply/restore.go:150-158 — the restore operation never sets DryRun, so an observe-mode report claims a wire change that was never sent
    • What fails: BodyOpts with Mode: observe runs the full path, including finishRestore (apply/apply.go:876, apply/apply.go:1075). opsFromRun marks every pipeline operation DryRun for observe mode (apply/ops.go:69, contract at apply/ops.go:27-29: "a report that ran in observe mode is DryRun too ... its operations are computed but never sent"). The new expand_restore operation sets no DryRun field. A library host that runs observe mode and passes Trace.Ops to the accountant books the copy's cost as real, although the observe body is never forwarded.
    • Proof: restorePlan.ops (apply/restore.go:150-158) builds the accountant.Operation with Kind, Operator, At, sizes, ChangeID and MessageSplice only. The observe entry point is proxy/modes.go:160-176 (Mode: components.ModeObserve), which calls BodyOpts and reaches finishRestore. The in-repo proxy discards the observe trace (proxy/modes.go:41-44), so no in-repo host mis-books today. apply is an importable library by design (CLAUDE.md), so the contract break is live for external hosts. Severity is low for this repo, but the fix is one line.
    • Fix: pass applied (or the mode) into finishRestore and set DryRun: !applied on the restore operation, as opsFromRun does. Add a test that an observe-mode run's restore op carries DryRun.

Non-blocking

  • finishRestore computes the copy positions twice and walks the body three extra times: pre (apply/apply.go:2306), outMsgs inside insert (apply/restore.go:98), and nb (apply/apply.go:2323). Each is a full gjson walk of a body that can be 600 KB. Only requests with a restore plan pay it, but every later turn of a fixed_restore session is such a request. insert could return the positions it already computed.
  • The /stats aggregator still credits the compaction on fixed_restore later turns: its saved_tokens comes from the component reports inside pipe.Run, which run before the copy is inserted. The dashboard row now shows no saving on those turns. The two figures disagree for the same request. Changing the aggregator touches the append-only /stats contract, so it needs the owner's decision; the PR's open questions do not name it.
  • restoredCopies in dash/overview.go:589 holds a token sum, not a copy count. The name misleads.
  • The PR stores restored_tokens, a token count. That is metadata only. The PR description says what it stores but does not use the data-dependence vocabulary of docs/data-dependence.md. No doc row is needed (no new component), but the PR should state "metadata only" in the data-dependence terms.

What I checked

  • Read the full diff (10 files) and the code around each change: finishRestore, restorePlan.positions/insert/ops, opsFromRun, wireSizes, tailOp, the tail-breakpoint defer, and both finishRestore call sites on the Messages and Responses wires.
  • Verified the new operation's shape against the accountant library pinned in go.mod (rewrite/fixed-restore-cost/hot/5m): kind, operator context-guru.expand_restore, At.Index == messageSplice.at, SizeBefore 0, SizeAfter = the copy's wire bytes, ChangeID cg:restore:<id>. Read the library's items, toFwd, undo, apply, sawOriginal, checks and nextState to confirm the position mapping and the sum check reconcile with the copy on the wire.
  • Verified the rank math in ops against expand.InsertRestored's ordering (same-index insertions keep plan order; ascending positions; append-at-end) for mixed, duplicate and unsorted plans.
  • Verified envelopeComponents["expand_restore"] is required: without it FallbackFigureWithoutRow fires (dash/accountant_price.go:351-355) and the request books no saving.
  • Verified the dash SQL: insert column count equals the placeholder count (106 fixed + token columns); requestCols/scanRequest and the Overview SELECT/Scan pairs stay aligned; the new column is additive with default 0.
  • Verified the Responses wire never feeds the accountant (accUnsupportedWire, proxy/proxy.go:1521), so the restore ops appended there cannot fail the sum check.
  • Verified anchors are deduped by id (expand.RecordAnchor), so no duplicate ChangeID can fire unique_change.
  • Read the new tests in apply/ops_restore_test.go and proxy/restore_savings_test.go, and checked their helpers and config keys exist (fixedPricer, waitForRows, expand.fixed_restore).
  • Did not run Go builds or tests: live tests are not approved for this review.

@boazdavid boazdavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @boazdavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.241 offload-review skill, @boazdavid's session fresh 1 of 2 1 of 2 5373859e9999 approve

Verdict: approve

Findings

None. The change is correct on every path I could trace. Details below.

Non-blocking

  1. /stats and the prom cg_saved_tokens_total / cg_tokens_after_total lines still over-credit a fixed_restore session. The pipeline emits the run report inside Pipeline.Run (components/pipeline.go:122), before finishRestore adds the copy's tokens to TokensAfter (apply/apply.go:2321). So the dash row is corrected, but the aggregator's saved figure still credits the full compaction on every later turn. The issue scopes itself to the dash ("dash: the saved figure..."), and the gross figures are documented as re-counted per turn (promexport.go:423), so this is a known surface left as it was. If #481's rule is meant to hold on /stats too, that needs a separate change (emit after restore, or re-emit).

  2. The fallback path still credits the token figure. When plan.insert fails, finishRestore forwards the pre-pipeline body (apply/apply.go:2309-2314) and drops the ops, but leaves Run.TokensAfter at the compacted value. The dash then credits a compaction for a request whose originals went out in full. This is the same wrong figure #481 describes, on the one branch the fix does not reach. It is pre-existing and near-unreachable: positions clamps every At into [1, len(outMsgs)], so InsertRestored can only fail on an sjson error. Worth a follow-up line res.Trace.Run.TokensAfter = res.Trace.Run.TokensBefore (or the equivalent) in that branch.

  3. Mixed report after a count-changed give-up. In the count-changed path, wireSizes can drop the pipeline ops (apply/apply.go:864-866) and finishRestore then appends the restore ops anyway, so Trace.Ops is non-empty while OpsDropped > 0. No wrong figure can come out: PriceMode returns FallbackOpsDropped (dash/accountant_price.go:305) and the tail-op gate skips (apply/apply.go:420). Only the state is odd. No action needed.

  4. The token figure and the dollar figure now treat the copy differently, by design. TokensAfter += tokens subtracts the copy at full text-token weight on every later turn, while the accountant op prices it by tier (written once, read later). The two figures already had this split (gross wire tokens vs tiered dollars), and the issue asked for both. Stating it here so a later reader does not report it as a bug.

What I checked

  • Read CLAUDE.md, docs/design.md, the full diff, and the code around every change.
  • The op math. InsertRestored (expand/anchor.go:376-417) places every insertion in pre-splice coordinates, ties in plan order, emission ordered by At. ops sorts the plan stable by at, ties in plan order, and reports pos = at + rank. I traced both orderings by hand for the tie case, the all-fallback case, and the mixed case: the emission order and the sorted order are the same list, so pos is the copy's true index in nb. Removed == 0 makes the splice's At valid in both pre- and post-splice coordinates, so it composes with the pipeline's own ops, which are stated in input coordinates. The sizes come from nb[pos].Raw, the bytes the provider actually bills. The unreachable-position guard fails closed (drops all ops).
  • The library contract. The shared accountant case rewrite/fixed-restore-cost/hot/5m (test/cases in the accountant module) uses exactly this shape: operator context-guru.expand_restore, at = the copy's index in the final forwarded body, messageSplice {removed: 0, inserted: 1}, sizeBefore 0, ChangeID cg:restore:<marker id>, cost applied once per ChangeID. The engine's apply/undo (internal/engine/compute.go:405-430) maps earlier ops' positions past such a splice.
  • Both wire paths. finishRestore runs on the chat path (apply/apply.go:876, 1075) and the Responses path (apply/responses.go:601, 625). Observe mode never reaches it: the enforced path does not call BodyOpts, and the off-path run discards the result (proxy/modes.go:162-197). So no DryRun inconsistency.
  • The token correction. Run.TokensAfter is read after finishRestore only by the dash capture (dash/event.go:806), the proxy log (proxy/proxy.go:1703) and the control rows, all of which should see the corrected figure. The aggregator's copy was emitted earlier and is unchanged. Saved() clamps at zero. Per-component Report.Saved() uses the component's own counts, not the run's.
  • The dash plumbing end to end. Event.RestoredTokens from Trace.RestoredTokens (dash/event.go:799); the requests.restored_tokens column is in the insert list, the value list, requestCols and scanRequest at the same position (I counted the insert columns against the placeholders: 146 = 106 + 40 token columns). The overview SELECT and its Scan stay aligned (restoredCopies after Reverts). The additive-column entry matches the existing pattern. The envelopeComponents entry is required and present; the restore op is correctly absent from toolSectionOperators (it acts on messages), and it adds nothing to countedSavedTokens (Saved is zero on that op), so the plausibility bound holds.
  • The tests. TestRestoreOpsRankByPosition matches the real InsertRestored emission order (I derived it by hand). The proxy test drives a real recorder through an in-band expand and three later turns; the control (fixed_restore off) answers the issue's open question, and the assertions would fail on the pre-fix code, as the commit message claims.
  • Fail-open. No request-path behavior changes: positions is a pure refactor of the old inline loop, the forwarded bytes are the same as before, and every new failure mode (a copy that cannot be placed) drops the figure only, never the rewrite.
  • Did not run Go builds or tests (not approved). Read the accountant library v0.1.1-0.20261108152158 from the module cache instead.

…481)

Review round 1 of #1067.

- The expand_restore operation is a dry run in observe mode, like the
  pipeline's own operations. The body is never forwarded there.
- When the insert fails and the pre-pipeline body is forwarded, the
  run reports no saving: TokensAfter is set back to TokensBefore.
- finishRestore resolves the copy positions once (insertAt).
- Rename restoredCopies to restoredTok in dash/overview.go.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: DAVID BOAZ <[email protected]>
@boazdavid

Copy link
Copy Markdown
Collaborator Author

Round 1 replies

Reviewer 2, finding 1 (restore op not a dry run in observe mode). Fixed in 7bb2c6f.

  • finishRestore now takes the mode. The restore operation is DryRun in observe mode, as opsFromRun does for the pipeline's operations.
  • Test: TestRestoreOpIsADryRunInObserveMode. It also checks that an enforced run is not a dry run.

Reviewer 1, non-blocking 2 (fallback path still credits a saving). Fixed in 7bb2c6f.

  • When the insert fails and the pre-pipeline body is forwarded, TokensAfter is now set to TokensBefore.
  • Test: TestRestoreFallbackReportsNoSaving.

Reviewer 2, non-blocking (positions computed twice). Fixed in 7bb2c6f. finishRestore resolves the positions once and passes them to insertAt. insert keeps its signature.

Reviewer 2, non-blocking (restoredCopies name). Fixed in 7bb2c6f. It is restoredTok now.

Both reviewers: /stats and the Prometheus cg_saved_tokens_total / cg_tokens_after_total still credit the compaction on restore turns. Not changed in this PR.

  • The aggregator reads the run report inside Pipeline.Run, before the copy is inserted.
  • Changing it touches the append-only /stats contract. That needs the owner's decision.
  • Open question for the owner: should /stats be corrected too? If yes, emit the report after finishRestore, or re-emit it.

Reviewer 1, non-blocking 1, 3 and 4. No action.

  • 3 (ops non-empty while OpsDropped > 0): PriceMode returns ops_dropped in that state, so no figure is wrong.
  • 4 (token figure and dollar figure treat the copy differently): by design. Tokens count the copy at full weight. The accountant prices it by tier.

Reviewer 2, data-dependence. restored_tokens is metadata only: a token count per request. No content is stored and no document depends on it.

Tests: go test passes for dash, apply, proxy and expand.

@boazdavid boazdavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @boazdavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.241 offload-review skill, @boazdavid's session resumed 2 of 2 2 of 2 7bb2c6f4ea0e approve

Verdict: approve

Findings

None. My round-1 finding is fixed correctly, and the new commit introduces no defect I can show.

Status of the earlier findings

  1. Mine, finding 1 (restore op not a dry run in observe mode) — fixed. finishRestore takes dryRun and sets it on the operation (apply/restore.go:161). All four call sites pass mode == components.ModeObserve (apply/apply.go:876, apply/apply.go:1075, apply/responses.go:601, apply/responses.go:625); mode is resolved to sync before each, so an empty Opts.Mode stays enforced. The condition equals !applied (apply/apply.go:829), the same rule opsFromRun uses. TestRestoreOpIsADryRunInObserveMode covers observe and the enforced control.
  2. Reviewer 1, non-blocking 2 (fallback still credited a saving) — fixed, and I checked it myself. The failed-insert branch now sets Run.TokensAfter = TokensBefore (apply/apply.go:2312-2314). That is right: the branch forwards the pre-pipeline body, so nothing was compacted on the wire. TokensBefore counts the same messages the fallback carries (the envelope rewrites before the pipeline touch no message content). TestRestoreFallbackReportsNoSaving drives the branch through a body with no messages array (MessagesField("bogus") returns messages, so InsertRestored fails).
  3. Mine, non-blocking (positions computed twice) — fixed. finishRestore resolves the positions once and calls insertAt; insert keeps its signature for the tests. The semantics are identical: insertAt receives the same at slice insert computed internally.
  4. Mine, non-blocking (restoredCopies name) — fixed. It is restoredTok now.
  5. Both reviewers (/stats and the prom lines still over-credit restore turns) — rejected by the author, and the reason is right. The aggregator reads the run report inside Pipeline.Run, before the copies are inserted. Correcting it touches the append-only /stats contract, which needs the owner's yes (CLAUDE.md, RELEASING.md). The author left it as an open question on the PR. I accept this. The dashboard and the accountant now agree; /stats keeps the old semantics until the owner decides.
  6. Mine, non-blocking (data-dependence wording) — answered. The author states restored_tokens is metadata only. That matches what the code stores: a token count per request, no content.
  7. Reviewer 1, non-blocking 3 (mixed ops after a count-changed give-up) — no action, reason verified. accOverride returns FallbackOpsDropped when accOpsDropped != 0 (dash/accountant_price.go:304-305), so the mixed state books no figure. Only the state is odd.
  8. Reviewer 1, non-blocking 4 (token figure vs dollar figure weight the copy differently) — by design. I agree. The token figure is gross wire tokens; the accountant prices by tier. Both were asked for by #481.

Non-blocking

  • The fallback fix zeroes the run-level figure only. On that branch the per-component rows (CompRow.SavedGross), SavedUnique and Trace.Changes still describe rewrites that were not forwarded. A reader of the row sees component savings beside tokens_before == tokens_after. The path is rare (the insert fails only on a body shape InsertRestored refuses), and Changes on a discarded rewrite predates this PR. A follow-up could clear the component figures there too.
  • The /stats open question should stay visible until the owner answers it, so it is not lost at merge.

What I checked

  • Last review: round 1, 5373859, 2026-11-11T07:05:55Z
  • New commits read: 1 — 7bb2c6f4 fix(apply): Mark the restore operation as a dry run in observe mode (#481)
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files in my folder; the inline file is empty)
  • New items since my last review, and what I did about each:
    • Reviewer 1's round-1 review (approve, 4 non-blocking notes): read in full. Its claim that observe mode never reaches finishRestore was wrong (the off-path observe run calls BodyOpts, proxy/modes.go:160-176), but its other notes were sound; note 2 became a fix I verified myself (item 2 above).
    • The author's round-1 replies: read in full. Each reply checked against the code (items 1-8 above).
    • Commit 7bb2c6f4: read the full diff and the code around each change. Verified the dryRun threading at all four call sites, the fallback TokensAfter reset, the insertAt refactor against the old insert (identical semantics), the rename in dash/overview.go, and both new tests.
  • Confirmed FallbackOpsDropped gates the mixed-ops state (dash/accountant_price.go:304-305) and FallbackObserve gates observe rows, so the dry-run fix is defense in depth for hosts outside this repo.
  • Confirmed the new commit changes no forwarded bytes: the dry run is a flag on a report, the fallback already forwarded the pre-pipeline body, and insertAt is a refactor.
  • Did not run Go builds or tests: live tests are not approved for this review.

@boazdavid boazdavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @boazdavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.241 offload-review skill, @boazdavid's session resumed 2 of 2 2 of 2 7bb2c6f4ea0e approve

Verdict: approve

What I checked

  • Last review: round 1, 5373859e99992da495c50dff662bdd7a00080704, 2026-11-11T07:06:56Z.
  • New commits read: 1 — 7bb2c6f4ea0e "fix(apply): Mark the restore operation as a dry run in observe mode (#481)". I read the full diff and the code around each change.
  • Conversation read since then: 2 reviews (reviewer 2 round 1, mine round 1), 1 issue comment (the author's round-1 replies, 2026-11-11T07:12:11Z), 0 inline comments.
  • I verified each fix by hand, on the code only. Live tests are not approved.

Dispositions

Reviewer 2, finding 1 (the restore operation was not a dry run in observe mode). Fixed. Reviewer 2 was right, and my round-1 statement "observe mode never reaches it" was wrong. It holds only for the in-repo proxy, which discards the observe trace. BodyOpts is an exported library entry point (CLAUDE.md: apply is importable), and a host that calls it with Mode: observe reaches finishRestore on both wires. The fix is correct:

  • finishRestore takes dryRun and sets it on the restore operation (apply/restore.go:161).
  • All four call sites pass mode == components.ModeObserve (apply/apply.go:876, apply/apply.go:1075, apply/responses.go:601, apply/responses.go:625). mode is in scope at each.
  • The new test holds. effMode stamps the mode on every report (components/pipeline.go:141, components/component.go:811), so the pipeline op is DryRun via opsFromRun (apply/ops.go:69) and the restore op via the new parameter. Both operations in the observe run carry DryRun. The control normalizes mode "" to ModeSync (apply/apply.go:393), so the enforced run's restore op does not.

My round-1 non-blocking 2 (the fallback path still credited a saving). Fixed. TokensAfter is set back to TokensBefore on the insert failure (apply/apply.go:2314-2316), with a nil guard on Run. I checked the consumers: Saved() clamps at zero (dash/event.go:666-669), and PriceMode books no dollar saving while OpsDropped > 0. The test setup is valid: the pipeline body has no messages array, so InsertRestored fails closed (expand/anchor.go:382).

Reviewer 2, non-blocking (positions computed twice). Fixed. finishRestore resolves the positions once and passes them to insertAt (apply/apply.go:2307-2308). insert keeps its signature and delegates. The semantics are the same: pre is the same walk insert used to make.

Reviewer 2, non-blocking (restoredCopies name). Fixed. It is restoredTok now, at the scan and both uses.

Reviewer 2, non-blocking (data dependence). Addressed. The author states it in the round-1 reply: restored_tokens is metadata only, a token count per request, no content stored. No new component exists, so no doc row is required by components/all/datadep_test.go.

/stats and the Prometheus counters (my non-blocking 1, reviewer 2's non-blocking). Deferred, and I accept the reason. The aggregator reads the run report inside Pipeline.Run, before the copy is inserted. Changing it touches the append-only /stats contract, which needs the owner's decision. The author put the open question to the owner. No figure the issue names is wrong.

My non-blocking 3 (ops non-empty beside OpsDropped > 0). No action, agreed. PriceMode returns ops_dropped in that state, so no figure is wrong.

My non-blocking 4 (token figure vs dollar figure treat the copy differently). No action, agreed. By design, as the author says.

The new commit

I reviewed 7bb2c6f4 as a first review. No new findings.

  • The dryRun parameter changes the op's flag only. The enforced path is unchanged: the shared accountant case rewrite/fixed-restore-cost/hot/5m has no DryRun, and an enforced run sets none.
  • The fallback branch now reports no saving, which is the behavior #481 asks for: the pre-pipeline body was forwarded, so nothing was compacted on the wire.
  • restoredTok is a rename. The SELECT and the Scan stay aligned.

Non-blocking

  1. The pre-existing giveUp paths still credit a saving (apply/apply.go:943, 949, 963, 972, 1028). Each of those returns forwards the original messages but leaves Run.TokensAfter at the compacted value. That is the same wrong figure #481 names, on paths this PR does not touch, and the restore fallback is now more correct than they are. The same one-liner (TokensAfter = TokensBefore) would fit giveUp. These paths fire only on writeback failures (editOf, sjson, json.Marshal), so they are rare. Follow-up, not this PR.

  2. e.SavedUnique and the component SavedGross rows still describe the compaction on the restore-fallback path. noteTrace reads rep.Saved() before the fallback is known (proxy/dashcapture.go:232-236). The saved figure (saved_tokens) and the dollar figure are both zero there now, so the figure the issue names is right. DropUnbilledSavings zeroes SavedUnique on rejected requests for the same reason (dash/event.go:867-868). Follow-up with item 1, not this PR.

  3. The data-dependence statement lives in a review reply, not the PR description. The PR body says "stores its size per request" in plain words. The vocabulary statement ("metadata only") is in the author's comment. The rule asks the PR to state it; a comment on the PR satisfies it in substance. Moving the sentence into the description would make it easier to find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

dash: the saved figure does not subtract the restored copy from expand.fixed_restore

2 participants