Skip to content

fix(review): unchanged items are re-reviewed and re-rated every scheduled pass - #1753

Merged
obviyus merged 3 commits into
openclaw:mainfrom
holgergruenhagen:fix/exact-review-prior-record
Oct 11, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
holgergruenhagen:fix/exact-review-prior-record

Conversation

@holgergruenhagen

@holgergruenhagen holgergruenhagen commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Related: #1752

What Problem This Solves

Fixes: unchanged issues and PRs are fully re-reviewed by Codex on every scheduled pass, and their rating and reproduction labels change between passes, when the hosted exact-review job reviews them.

User Impact

User impact: scheduled passes on unchanged items reuse the previous verdict again instead of running a new model review, so ratings and reproduction labels stay stable for identical evidence. Items with new reporter or maintainer activity are still reviewed again. The hourly cadence and the per-pass review lease comment are unchanged.

Why This Change Was Made

The review step reads the item's prior canonical record from records/<slug>/items/<number>.md. In event-review-apply, that record was hydrated only after generation, for publication. Every scheduled pass therefore started without a prior review, so the structural cache stopped at missing_review and the content cache had no verdict to compare.

This change hydrates only the selected item's record immediately before generation, with the review step's condition, no git state, and no blobs. The step is bounded to five minutes, so a stalled Worker cannot hold the review lease before generation starts. If hydration fails or times out, the step continues and the review falls back to today's full review.

The hourly cadence is not changed by this PR. Since #1007, hasActivitySinceReview (src/scheduler-policy.ts:85) treats any update after reviewed_at, including ClawSweeper's own comment, label, and lease writes, as activity and leaves suppression to the structural cache. Every pass still posts and deletes a lease comment, so followers still get a notification per pass. This PR only makes the cache able to reuse the verdict again.

OpenClaw Bay Impact

No Bay change. The change only adds a read of one canonical record before generation; queue, lifecycle, publication, and dashboard data contracts are unchanged. Fewer model reviews and fewer label changes are expected in the observed activity.

Documentation Impact

  • docs/review-cache.md (active): new "Prior Record" section describing the dependency and the fallback.
  • docs/scheduler.md (active): the "Review cadence" paragraph still described the sync-marker exemption that hasActivitySinceReview no longer applies; replaced with the current rule and a pointer to the review cache.
  • changelog.d/exact-review-prior-record.md: one-line fragment.

Evidence

Root cause in hosted runs (public logs):

  • https://github.com/openclaw/clawsweeper/actions/runs/37603325532 (clawhub 3921): the lease was posted at 09:50:52, the review ran 09:50:52–09:53:09 with structural_cache_checks=1 structural_cache_hits=0 structural_cache_revalidations=0 content_cache_hits=0 hydrations=1, and the record was hydrated afterwards at 09:53:15 (focused tuples hydrated repo=openclaw-clawhub items=1 records=1).
  • 40 scheduled-normal runs on 2026-10-07 between 10:28 and 11:02 UTC (32 openclaw/openclaw, 8 openclaw/clawhub): all report structural_cache_hits=0 structural_cache_revalidations=0 content_cache_hits=0 hydrations=1.
  • clawhub 3921: the durable comment was rewritten 12 times in 14 hours; its source_revision marker is identical in 11 of them, and the reviewed target commit did not change.

Tests:

  • New test/review-reliability-workflow.test.ts case requires the prior-record hydration before generation (item-scoped, no git state or blobs, same condition as the review, continue-on-error, timeout-minutes ≤ 5, Worker secret absent from the review step env). It fails on main with the exact review must hydrate its prior record before generation and passes with this change. The existing "enters finalization before state hydration" case now targets the post-review direct-setup-state step by id, so its ordering guarantee for the full hydration is unchanged.
  • New test/review-structural-cache.test.ts case uses the real 3921 timestamps: without a record missing_review; the lease release alone is activity_changed; the next pass's reservation yields hit; a human comment after the pass yields source_changed.
  • Current main replaced setup-state site-count inventories with per-site contract checks. The merge retains those checks; the new item-scoped step satisfies the same canonical-record contract.
  • pnpm run check: static checks, build, lint, and changed coverage pass; 7,215 tests with 1 failure, test/repair/process-env.test.ts "Codex subprocess prevents pnpm deploy from installing target Git hooks", which fails the same way on an unchanged main checkout in the same environment (git 2.43.0). After adding the step timeout: check:static, lint, build, and the four affected test files (review-reliability-workflow, state-writer-workflow, review-structural-cache, sweep-workflow: 208 tests) pass.
  • codex review --uncommitted before the commit and codex review --base main on the final commit: no actionable findings.

Real Behavior Proof

  • Claim: with the prior record hydrated by the new step's command, a scheduled review of an unchanged item reuses the verdict without a model run; without it, the model runs.
  • Surface: the real clawsweeper review command with the hosted step's arguments (minus lease and sandbox flags), and the real scripts/hydrate-state.ts --skip-git-state --skip-state-blobs --records-item-number <n>.
  • Scenario: live openclaw/clawhub items 3921 (issue), 3888 (issue with related-item search results), 3548 (PR); two consecutive passes; a control with a changed content digest.
  • Environment: local Linux, Node 24.18.0, blobless clone of openclaw/clawhub at c23e34ad; GitHub reads through a shim that blocks every non-read call (0 blocked calls); the Worker is a local stub serving the record; the Codex model and the secret scanner are stubs (codex sandbox checkout preflight runs for real).
  • Result:
    • 3921 before: 1 model call, content_cache_hits=0; after: cache-hit content-unchanged skip-model, 0 model calls.
    • 3888 before: 1 model call; after: cache hit, 0 model calls.
    • 3548 before: 1 model call; first pass with a record still misses because the previous digest came from a pass without a prior record; the following pass hits with 0 model calls.
    • Control (changed content digest): 1 model call, no reuse.
  • Limits: the GitHub Actions job itself was not run; publication after a cache hit was not exercised; Worker, model, and scanner were stubbed; the publication-owned record fields were reconstructed; passes were minutes apart.

Maintainer update (2026-10-12)

Merged current main into the contributor branch without rewriting contributor commits. The only conflict was the retired state-hydration test inventories; current main's per-site contract checks are retained. No overlap with Pash/Sarah changes.

Fresh main evidence, all at 530643f35556723ef86555ecf0c0bfd0010f601d:

Scheduled normal run Review complete (UTC) Canonical hydration (UTC) Counters
openclaw/openclaw 48709 rev 395 23:33:57 23:34:04 structural checks 1, structural hits 0, revalidations 0, content hits 0, hydrations 1
openclaw/openclaw 135512 rev 6 23:33:37 23:33:46 structural checks 1, structural hits 0, revalidations 0, content hits 0, hydrations 1
openclaw/clawsweeper 1770 rev 7 23:29:14 23:29:21 structural checks 1, structural hits 0, revalidations 0, content hits 0, hydrations 1

These traces confirm that main still hydrates after generation. They do not alone prove that all input fields were unchanged between passes. The original unchanged-item evidence and its limits remain above.

Canonical-record proof remains blocked on project access. The current public state repository has no records directory, the current public API exposes aggregates rather than canonical records, and the sampled 1770 run has no downloadable artifacts. The hydrator uses authenticated GET /internal/state/records/{slug}/{section}/{id} and validates the returned content digest. No production credential or production workflow was used for this update.

The cheapest next proof is a maintainer-provided export of one real canonical item record, with its revision and digest, consumed by the shipped review command in a read-only Crabbox run. Alternatively, authorize a maintainer to perform one item-scoped Worker hydration and the same read-only review. A proof override is a separate maintainer decision, not claimed here.

OpenClaw Bay is not affected: no public API, queue, lifecycle, publication, or dashboard contract changes. This is a two-way door: reverting removes the early read without a schema migration or stored-data conversion. The blast radius is exact-review cache eligibility and full-review fallback; lease notifications and scheduler cadence are unchanged.

…uled pass

The hosted exact-review step reads the item's prior canonical record from
records/<slug>/items, but the event-review-apply job hydrated that record only
after generation, for publication. Every scheduled pass therefore ran without a
prior review: the structural cache stopped at missing_review, the content cache
had no verdict to reuse, and Codex reviewed and re-rated unchanged items again.

Hydrate only the selected item's record (no git state, no blobs) immediately
before generation, with the same condition as the review step. Hydration
failure keeps today's full-review fallback. The setup-state site inventory and
the finalization-order test now name the post-review hydration explicitly.

Docs: describe the prior-record dependency in docs/review-cache.md and replace
the stale cadence paragraph in docs/scheduler.md, which still described the
sync-marker exemption removed from the planner.

Related: openclaw#1752
@holgergruenhagen
holgergruenhagen requested a review from a team as a code owner October 7, 2026 12:26
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR loads the selected item's canonical review record before hosted review generation so existing caches can reuse unchanged verdicts.

Example: A scheduled pass revisits openclaw/clawhub issue 3921 with unchanged review inputs.

  • Before: Generation starts without the previous record, misses both caches, and runs another model review.
  • After: Generation receives the previous record and can reuse its verdict when existing eligibility checks pass.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with useful partial CLI evidence and limited canonical-integration confidence.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Identical review evidence repeatedly receives new model judgments, causing unnecessary work and unstable public ratings.
Reason: The patch restores an existing documented capability through a narrow workflow seam; cadence and lease notifications are expressly outside the claimed repair.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: current main still generates reviews without the saved record needed for cache reuse, and this PR provides a focused repair. No introduced correctness defect was found.

Priority: P2
Reviewed head: 5867494d3981cf979889bd46817e93f1a74ba3c7

Before merge

  • Add real behavior proof - The supplied Linux/Node 24 runs exercise the real hydrator and review CLI against live GitHub inputs and report cache hits with zero model calls, but the changed canonical-record input is supplied by a stub Worker with reconstructed fields. The previous review's request for actual canonical-record reuse remains unresolved and is acknowledged in the current body. Provide a redacted current-head transcript using a maintainer-exported canonical record or an authorized item-scoped hydration; redact credentials and non-public endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Findings

None.

Tests

  • Low-value test test/review-structural-cache.test.ts: The added 67-line case exercises unchanged helpers and repeats existing missing-review, reservation-coverage and changed-source checks; remove it or fold the production timestamps into existing coverage.
  • Missing end-to-end proof: Show the current-head hydrator and shipped review CLI consuming an actual canonical record and reusing the unchanged verdict.
Agent review details

How this fits together

The hosted exact-review workflow supplies canonical Worker records and current GitHub evidence to the review CLI, which produces a report for subsequent publication.

flowchart TD
  A[Exact review queue] --> B[Claim and reserve lease]
  B --> C[Hydrate selected canonical record]
  C --> D[Review CLI and cache checks]
  D --> E[Reuse verdict or run model]
  E --> F[Finalize and publish report]
Loading

Technical review

Best possible solution:

Load the selected canonical record before generation while retaining existing cache validation, bounded hydration and full-review fallback.

Do we have a high-confidence way to reproduce the issue?

Yes at source level: main loads the canonical record after generation, while the review reads that record before cache probing and rejects its absence; no reproduction was executed during this read-only review.

Is this the best way to solve the issue?

The existing item-scoped hydrator is the appropriate owner for this prerequisite, and the patch restores the established cache contract without changing scheduler policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 530643f35556.

Provenance checked

  • Scheduled cache eligibility keeps the original intent (fix(review): let scheduled deliveries use the structural review cache #1067: Scheduled deliveries must validate and use their supplied lease so unchanged evidence can reuse structural reviews.)
  • Exact-input cache contract keeps the original intent (refactor(review): let Codex judge changed PR content #1328: Preserve structural and exact-content reuse for unchanged inputs while letting Codex judge changed content.)
  • Post-generation hydration ordering keeps the original intent (fix(review): stop lease cancellation storms #922: Enter finalization before potentially lengthy post-review state hydration to prevent lease recycling and cancellation storms.)
  • Scheduler documentation changes intended behavior with a stated reason (75e6c07: The old paragraph described owned label/comment synchronization markers; the PR updates it to match current scheduler source and the later structural-receipt design.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 56a9443 adds docs/review-cache.md:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 56a94433f14d; files: docs/review-cache.md)
  • Peter Steinberger: Raw commit ba95477 adds docs/review-cache.md:3 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ba954778d8bb; files: docs/review-cache.md)
  • Ayaan Zaidi: Raw commit 373cf3e adds .github/workflows/sweep.yml:1256 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 373cf3e3a1a7; files: .github/workflows/sweep.yml)

Review metrics

Metric Value Why it matters
Introduced scope Workflow +17; tests +104/-1; docs and changelog +19/-6 Production growth is one existing-action invocation; most added coverage checks workflow placement and cache assumptions.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repeated unchanged reviews consume model capacity and can churn public ratings, with a bounded workflow repair.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Remove the duplicated structural-helper case or fold its timestamps into existing tests.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-07T12:30:23.470Z sha 34fb89c :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-07T21:40:23.279Z sha 34fb89c :: needs real behavior proof before merge. :: none

Reviewed October 11, 2026, 7:42 PM ET / 23:42 UTC (Revision 3).

@holgergruenhagen

Copy link
Copy Markdown
Contributor Author

On the remaining proof item: hydrating an actual canonical record is not possible from outside the project.

That leaves two ways to close the item:

  1. A maintainer with Worker access runs the new step's command, node scripts/hydrate-state.ts --skip-git-state --skip-state-blobs --records-repo-slugs openclaw-clawhub --records-item-number 3921, and then the existing review command for openclaw/clawhub#3921. A cache-hit content-unchanged skip-model line in the review output would show the reuse against the real record.
  2. A proof: override decision, if the local proof in the PR body (real hydrator and review command against live GitHub inputs, stub Worker serving the prior report) is considered sufficient for a workflow-ordering change. Per CONTRIBUTING.md, that decision rests with the maintainers.

@obviyus

obviyus commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Merging on owner approval (@obviyus) with the current proof: the real hydrator and review command with a stub Worker, plus merged-main checks (5,817 tests, 0 failures). The real-record proof needs the Worker secret, so we confirm in production instead: after this lands, scheduled re-reviews of unchanged items should report structural_cache_hits or content_cache_hits above 0. Today every sampled run reported 0 (e.g. https://github.com/openclaw/clawsweeper/actions/runs/38184433410). Thanks @holgergruenhagen for the diagnosis and fix.

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

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants