v31: add fresh on-chain payout truth probe, Apply-review integrity gating, and diagnostics#1485
v31: add fresh on-chain payout truth probe, Apply-review integrity gating, and diagnostics#1485MontrealAI wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a429290ba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if(action === 'jobs') return scrollToId('jobsSection'); | ||
| if(action === 'activity') return scrollToId('activitySection'); | ||
| if(action === 'ops') return scrollToId('operationsDeckSection'); | ||
| if(action === 'toggle-auto-refresh') return setAutoRefreshEnabled(!autoRefreshEnabled); | ||
| if(action === 'command') return openCommandPalette(); | ||
| if(action === 'expand-terms') return document.querySelectorA |
There was a problem hiding this comment.
Preserve reviewed bond snapshot before confirm-time re-read
snap is captured from nowProbe inside the confirm handler, so the code no longer checks whether payout/bond inputs drifted between opening the review modal and pressing Apply. assertSnapshotMatch(...) now only compares post-approval state against this confirm-time snapshot, which means users can review one payout/bond in the modal but approve/send against a different on-chain snapshot without being forced to refresh and re-review.
Useful? React with 👍 / 👎.
Motivation
getJobCorepayout, apply preflight, and bond-trace by asserting a single fresh on-chain source of truth before review/send.Description
async function buildJobBondTruthProbe(jobId)which returnsjobId,cachedJob, fresh reads fromgetJobCore,getJobValidation,getJobSpecURI, live protocol bond params,tracefrom existingbuildAgentBondTrace(...),cachedPayoutRaw,freshPayoutRaw,tracePayoutRaw, boolean match flags,finalBondLeqPayout,payoutClampActive, and snapshotfetchedAtBlock/fetchedAtTimestampMs(usesweb3.eth.getBlockNumber()andDate.now()).window.__agijobBondProbe = async (jobId) => buildJobBondTruthProbe(jobId)with bigint fields JSON-stringified viatoJsonSafeBigIntto guarantee JSON-safe output.buildAgentBondTrace(...)math shape unchanged and reusing it for all traces.applyForJob(jobId)now callsbuildJobBondTruthProbe(jobId)before rendering review; the modal shows a top-priorityFresh on-chain proofsection listing cached table payout, freshgetJobCorepayout, trace payout, exact agent bond, MATCH/MISMATCH flags, payout-clamp flag, snapshot block, and snapshot time;Job payoutlabel was relabeled toFresh job payout (getJobCore)andagentBond minlabel toagentBond() live flooracross the formula audit and protocol panel.jobCache+latestJobsupdated viarefreshJobCachesFromFreshProbe(...)andrenderJobsFromCache()), a visible banner explains "Job state changed on-chain... the board was refreshed...", and the modal renders from the fresh snapshot only.applyForJob(...):trace.finalBondRaw <= trace.payoutRaw,trace.afterPayoutClampRaw === trace.finalBondRaw, andfreshPayoutRaw === tracePayoutRaw; if any invariant fails the modal shows a blocking banner, disables confirm (confirmDisabled), and the run path throws and aborts send.openActionReviewacceptsbodyHtmlandconfirmDisabled/confirmDisabledReason;confirmReviewedAction()respectsconfirmDisabledand refuses to proceed if set.window.__agijobBondSelfTests()returns Case A/B (the two specified scenarios) with JSON-safe bigint strings and the Operator Deck displaysAgent bond self-test A: PASS/FAILandAgent bond self-test B: PASS/FAILrows.data-job-idandrenderJobsFromCache()was added to re-renderlatestJobsafter cache refreshes;fetchAgentBondSnapshot(...)andbuildAgentBondTrace(...)remain used for preflight snapshot matching and assertions.Testing
buildJobBondTruthProbe,__agijobBondProbe,__agijobBondSelfTests,Fresh on-chain proof, and relabeled strings; all expected identifiers found (success).ui/agijobmanager_genesis_job_mainnet_2026-03-05-v31.htmland in-file replacements validated via script that updatedopenActionReviewand injected helper functions (patch applied successfully and file written to the requested path).applyForJobpath now builds a fresh probe, refreshes cache on mismatch, renders blocking banners and disables confirm when invariants fail, and re-checks invariants immediately before send; the preflight assertion and confirm-disabling behavior was exercised by the automated render/smoke checks (success).buildAgentBondTrace) was not altered and that approval sequencing remains fresh and sequential (success).Codex Task