feat(telemetry): IsAuthorized/Refine cost sidecar to guarantor layer (#974 Phase 1a)#1007
Merged
yu2C merged 3 commits intoJun 16, 2026
Conversation
…layer (#974 Phase 1a) PVM.Psi_I_ReturnType / PVM.RefineOutput gain an observability-only Cost field (zero until Phase 2a instrumentation). work_package.WorkReportCompute collects them into a WorkPackageTelemetryCost sidecar, index-aligned with Items, and Process stores it on the controller for the future event 95/101 bridge (#958). Cost never rides consensus types (pvmcost CI guard). Sentinel test plants distinct costs at the PVM leaf via a stub executor and asserts they reach the sidecar untouched, including for failed work items.
…c contract; fix refineOuput typo Review follow-up on the Phase 1a sidecar: - Failure paths discard cost by design: JIP-3 maps guarantor failures to event 92 (reason string, no cost field); cost-carrying events 95/101 fire on success only. Documented at the discard site, on the sidecar type, and on Controller.TelemetryCost. - TelemetryCost doc: not synchronized, read only from the Process caller goroutine (note for the #958 bridge). - Rename refineOuput -> refineOutput in I() (typo, lines already touched by this branch).
fe47843 to
251d9ec
Compare
yu2C
reviewed
Jun 16, 2026
Comment on lines
+86
to
93
| report, cost, err := WorkReportCompute(&workPackage, p.CoreIndex, pa, pc, extrinsicMap, importSegments, delta, workPackageBundle, workPackageHash, p.PVM) | ||
| if err != nil { | ||
| return types.WorkReport{}, err | ||
| } | ||
| p.TelemetryCost = cost | ||
| cs := blockchain.GetInstance() | ||
| newDict, err := cs.SetHashSegmentMapWithLimit(workPackageHash, types.OpaqueHash(report.PackageSpec.ExportsRoot)) | ||
| if err != nil { |
Contributor
There was a problem hiding this comment.
TelemetryCost assigned before post-compute steps that can still fail
Maybe move p.TelemetryCost = cost to just before the final return report, nil (after segment lookup is attached)?
…ss steps Review (yu2C): cost was stored before SetHashSegmentMapWithLimit, so a failure in that step left a stale cost on the controller. Move the assign to just before the successful return — upholds the sidecar invariant that cost present implies Process succeeded.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1 (guarantor half) of #974. Stacked on #978 — retarget to
mainafter it merges. Plumbing only: cost values stay zero until Phase 2a measures real numbers.Carries the cost summaries for events 95 (Authorized) and 101 (Refined) from the PVM leaf to the guarantor layer, as a sidecar — never on consensus types:
Design points (spec-driven)
Refineis per-item, index-aligned withItems— event 101's payload is one RefineCost per work item. Failed items keep their slot.Process()signature unchanged (sidecar lives on the controller) — auditing / CE134 callers untouched.Tests: sentinel test plants distinct marker costs at the PVM leaf via a stub executor and asserts they reach the sidecar untouched, including a BadExports item keeping its slot.
work_package/pvmcost/telemetry/auditingsuites green (WSL);PVMpackage failures are pre-existing — byte-identical on the base commit.Not included: event 47 (Accumulate) → Phase 1b (that chain crosses
ParallelizedAccumulation, under active refactor in #988 follow-ups). Actual emission → #958.