Repository navigation
sync: ledger handlers take the page as a parameter - #1214
Conversation
Handlers staged the next page by reading ledgerInvocationKey from the context. The invocation is now a parameter, and handlers call stage directly. Co-authored-by: Cursor <cursoragent@cursor.com>
The commit callback reached the queue through a mutex-guarded field on the syncer. syncParallel now passes the queue transition in, and the commit carries ledgerTransitionCommit as a parameter. Co-authored-by: Cursor <cursoragent@cursor.com>
Page execution read the worker and its attempt counters from context values, including the rate-limit wait observer. Callers now pass both, and the observer closes over the counters for that goroutine. Co-authored-by: Cursor <cursoragent@cursor.com>
The invocation parameter pushed one test literal past 200 characters. Co-authored-by: Cursor <cursoragent@cursor.com>
Superseded — see the current review report for commit
|
Superseded — see the current review report for commit
|
There was a problem hiding this comment.
No blocking issues found — see the full review report
Handlers reached the open page through ledgerInvocation. The page now carries the staged children, commit hooks, and connector observations, and handlers receive it directly. Co-authored-by: Cursor <cursoragent@cursor.com>
Handlers assigned page duration, the type-scoped flag, and merged observation counters on the row directly. Those writes now go through methods on ledgerPage. Co-authored-by: Cursor <cursoragent@cursor.com>
Superseded — see the current review report for commit
|
Superseded — see the current review report for commit
|
There was a problem hiding this comment.
No blocking issues found — see the full review report
Co-authored-by: Cursor <cursoragent@cursor.com>
Superseded — see the current review report for commit
|
Superseded — see the current review report for commit
|
There was a problem hiding this comment.
No blocking issues found — see the full review report
…riter Co-authored-by: Cursor <cursoragent@cursor.com>
Superseded — see the current review report for commit
|
Superseded — see the current review report for commit
|
There was a problem hiding this comment.
No blocking issues found — see the full review report
|
|
||
| func (p *ledgerPage) stage(action *Action, next string, children []Action) error { | ||
| if action.ID != p.action.ID { | ||
| return errors.New("ledger page transitioned a different action") |
There was a problem hiding this comment.
It might be nice to have the actions in this error.
There was a problem hiding this comment.
Done in the next commit: ledger page for <op> <id> transitioned <op> <id>.
Co-authored-by: Cursor <cursoragent@cursor.com>
Superseded — see the current review report for commit
|
General PR Review: sync: ledger handlers take the page as a parameterBlocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0 Review SummaryWhat the new commit changes: one line. Full-PR pass: I scanned the whole diff for security and correctness and read every non-test hunk. The refactor matches the PR description:
Repo-local criteria (applied): I scored the risk triage as LOW:
No exported API, wire format, serialized state, default or dependency surface changes, so no escalation instrument is needed. There were no prior findings to audit. Security IssuesNone found. Correctness IssuesNone found. SuggestionsNone. Reviewed commit: |
There was a problem hiding this comment.
No blocking issues found — see the full review report
Ledger handlers receive the
*ledgerPagethey write into as a parameter. The fourcontext.Contextkeys that carried ledger state (ledgerInvocationKey,ledgerCommitKey,ledgerAttemptsKey,ledgerWorkerKey), the code that dispatched on them, and theledgerInvocationtype are deleted. -841 / +530, all inpkg/sync.Before:
nextPageOrFinishActionstaged if ctx carried an invocation, else called a mutex-guardedparallelActionTransitionerfield thatsyncParallelinstalled for its lifetime, else committed.transitionActionStatefailed at runtime if ctx lacked a commit key. Handlers reachedinvocation.page.writer.PutX.After: handler type is
func(ctx, page *ledgerPage, action *Action) error.ledgerPageowns everything scoped to one page: the writer, the row,stage, staged children, after-commit hooks, connector observations, the restart request, and the worker's*ledgerAttempts. Handlers callpage.PutX(...)(six forwarders; the lifecycle half ofPageWriterstays private to the page and scheduler),page.stage(...),page.recordDuration(start),page.markTypeScopedPlanned(),page.addObservations(...).invokeActionPagetakes worker, attempts, and the queue transition func as parameters;syncParallelpasses them instead of mutating the syncer.transitionActionStatetakesledgerTransitionCommitas a parameter.Deleted:
nextPageOrFinishAction,ledgerInvocation,setParallelActionTransitioner/parallelTransitionMu, the four key types, and the two pin tests from #1203 that guarded the ctx-key shape (TestNextPageCallersAreLedgerHandlers,TestTransitionActionStateRejectsContextWithoutCommitKey).Behaviour: none intended. Stage/commit semantics, retry, and queue logic are untouched. Nothing persisted changes (no
pkg/dotc1z,pb, orprotofiles in the diff; ledger row fields are written at the same points); a sync started on the previous version resumes on this one. The rate-limit wait observer closes over the worker's*ledgerAttemptsinstead of reading it from ctx;ObserveWaitreads only the innermost observer, so retry-wait stats are recorded once as before.Tests: parameter swaps except
TestLedgerWaitObservationsStayWithWorker, which now allocates the coordinator accumulator and passes it in; assertions unchanged.Acceptance:
rg 'ctx\.Value\(' pkg/sync --glob '!*_test.go'is empty; handlers never namewriter:rg '\.writer\.' pkg/synchits onlyledger_page.go, the scheduler, the restart path, and theskipLedgerSyncseed. Build, vet, lint clean;go test ./pkg/sync/... -count=1andmake chaos-checkok.