Skip to content

feat(resume): add trusted resume validation and transition lineage (#786) - #845

Merged
lizhengfeng101 merged 3 commits into
alibaba:mainfrom
Gongyl01:feat/trusted-resume
Aug 14, 2026
Merged

feat(resume): add trusted resume validation and transition lineage (#786)#845
lizhengfeng101 merged 3 commits into
alibaba:mainfrom
Gongyl01:feat/trusted-resume

Conversation

@Gongyl01

Copy link
Copy Markdown
Contributor

Summary

Closes #786.

Part of #368.

Makes ocr review --resume validate the complete resolved run identity before reusing checkpoints.

  • Compares the input mode, repository identity, selected source artifact, and review-rule identity before creating a child run.
  • Accepts equivalent ref spellings that resolve to the same commits, while rejecting changed input before any child session or manifest is persisted.
  • Reuses only readable checkpoints backed by completed or reused coverage in the parent manifest. Failed, missing, incomplete, or corrupted work is reviewed again, including fully failed parent runs.
  • Requires explicit --provider or --model flags for provider/model transitions and records accepted transitions in one ocr.resume-lineage/v1 session event.
  • Pins the admitted diff and file reads to resolved commits so a moving ref cannot change the input after validation.
  • Keeps the child RunManifest as the single source of coverage truth and does not change its schema or terminal-state rules.

Workspace, scan, manifest-less, aborted, legacy, and unknown-schema resume parents remain unsupported and are rejected with guidance to start a new review.

How to test

make test
make coverage
go vet ./...
git diff --check upstream/main...HEAD

Checklist

  • Full test suite passes locally
  • Coverage passes the 90% threshold
  • go vet, gofmt, go mod tidy, and license checks pass
  • Tests cover changed-input rejection, equivalent refs, fully failed parents, corrupted checkpoints, explicit provider/model transitions, lineage persistence, and unsupported parent sessions
  • CLI documentation has been updated

Related Issues

Closes #786

Part of #368

@github-actions

Copy link
Copy Markdown
Contributor

OpenCodeReview: Review partially complete: 0 finding(s); 1 of 9 selected item(s) failed.

@lizhengfeng101

Copy link
Copy Markdown
Collaborator

@Gongyl01 rebase main

`ocr review --resume` admitted a session whenever the ref text matched, which
is neither sufficient nor necessary evidence about the input: `abc1234` and
`abc1234def` name the same commit, while a branch name that did not change can
name a new one. Resuming then mixed comments computed from one input with
comments computed from another, and nothing in the report distinguished them.

Compare the resolved input identity instead. agent.ResolveIdentity replays the
run's own selection — the same diff load and the same two filter passes — and
returns the identity a real run would record, so the parent manifest and the
child candidate are directly comparable. Any mismatch on mode, repository,
source artifact or rule config rejects the whole resume rather than degrading
to partial reuse. A provider or model change must be asked for with --provider
or --model; one that arrived through config or the environment is rejected.

Two behaviour changes fall out of this. Ref text no longer decides admission,
so ValidateOptions only checks the review mode. A parent that completed zero
items is now admitted: its manifest is verifiable, so its selected set is
simply re-dispatched, which is the case resume exists for.

Reuse is then gated on the parent manifest rather than on the checkpoint lines:
only a fingerprint the manifest claims as completed or reused is reused, which
keeps the manifest the single source of coverage truth. That gate is also what
makes an unreadable checkpoint survivable, so review loads through
LoadReviewResumeState, which drops lines it cannot parse — the file such a line
described is simply reviewed again, instead of one truncated write costing every
other file its checkpoint. Scan keeps the strict LoadResumeState, because with
no manifest to arbitrate, a dropped line cannot be told apart from a checkpoint
that was never written.

Rejection happens strictly before agent.New, because session.New writes
session_start the moment it is called — validating any later would leave an
orphan session behind every rejection. Keeping it there needs the run to review
exactly what was admitted, so the pre-flight hands back the commit endpoints it
resolved that identity from, and a resumed run loads its diff from those instead
of from the refs the user typed; file_read reads at the same sealed head. Both
loads then see the same immutable objects, so a ref moving after admission can
no longer change what the run reviews, and no mid-run re-check is needed to
discover that it did. An accepted resume records one
resume_lineage event naming the parent run and the provider/model endpoints,
surfaced by `ocr session show`; it carries non-secret labels only.

Interrupted runs become unresumable, since session_end is the sole carrier of
run_manifest. That is deliberate: an unverifiable input is exactly what this
change refuses to build on, and the error says so rather than reporting the
parent as unproductive.

Refs alibaba#786
@Gongyl01
Gongyl01 force-pushed the feat/trusted-resume branch from 9c82d0b to 0413e7b Compare August 13, 2026 08:52
@Gongyl01

Copy link
Copy Markdown
Contributor Author

@Gongyl01 rebase main

I’ve rebased it, and CI is now green. It’s one commit behind again, but no further rebase should be necessary.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@lizhengfeng101
lizhengfeng101 merged commit c35ddd7 into alibaba:main Aug 14, 2026
13 checks passed
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.

Add trusted resume with explicit provider and model transition lineage

2 participants