Repository navigation
fix(content): keep Next's Fix open rules passed while the page comes within its Length, wait only for what a pass reads (#1556 review) - #1560
Merged
Conversation
…within its Length, wait only for what a pass reads, and read a kept attempt's run by that attempt alone (ansvisor#1556 review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 27, 2026
gkhngyk
approved these changes
Oct 27, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good.
The #1556 review's four follow-ups:
- The Fix open rules pass dropped when the Length's state changed: Done.
thirdStepPassesnow skips a pass on a Length change only for the Length's own pass, or when the Length is far off now (next-step.ts:221). So a Fix open rules pass taken atshortorlongholds once the page comes within 30% (''), and still drops when the page goes far off the other way, or far off from a pass taken within.- The rule check is unchanged (
:222): a rule opened since still brings the step back. - Accepting a rewrite's page clears the passes and keeps the rewrite's attempt (
_draft-editor.tsx:2346-2350). The attempt then passes the Length step on the new page. For a rewrite, the card offers only its own Accept, Reject and Undo and the compare dialog, not Accept all (_agent-card.tsx:622-657,:701-709). SodecidePageis the only place a rewrite is accepted.
- The pass waited on every Quality read, but not the last rewrite's read: Done.
- The pass and the stale drop wait for
thirdRead = rulesSettled && citedRead && lastRewriteRead(:3291,:3297,:3313). That covers everythingthirdPassOfreads:- the rules: My rules, the sources, the brief and the catalog;
- the quoted passages, which hold the Sentence rule;
reach, which moves the Length's state.
- The rules read only the brief and the sources (
_use-draft-rules.ts), so leaving Quality's reads out doesn't let a pass be written before a rule can change. - The last rewrite's read is tracked per rewrite shown (
lastRewriteReadFor, set infinallyunless cancelled,:2018-2029). A failed read still counts as read. A catalog read that fails setsnull, notundefined, sorulesSettledcan't hang on it. staleSkipsstill waits fornextRead, as it should: a proof skip reads Trust.
- The pass and the stale drop wait for
- When the page opens: Done.
- The read changes only the attempt it read (
:3356). A Fix begun meanwhile keeps its own. - Beyond what the review asked,
attemptRead(:456,:3355) lets that newer Fix'suntriedput back the earlier attempt as the read found it (:2465-2469). An attempt found failed stays gone, and one found ended comes back ended. The identity check holds: the effect,beginThirdTry'sprevanduntriedall pass the same object. - A Fix found done with nothing written is marked
ended(:3352), asagentOutcomereads it (:349).
- The read changes only the attempt it read (
- Tests: Done.
- The Remove AI traces case checks
stored()is null before and aftersettle()(page.test.tsx:6627-6631). - The rewrite cases take
step: 'length', and twofixcases are added (:6680-6735). The stored attempt being null is what guards a rewrite case now: with the Length off in this fixture, a kept rewrite attempt wouldn't move Next anyway.
- The Remove AI traces case checks
What I checked:
- Whether a pass now holds when it shouldn't.
- A rule the agent never saw still drops the pass, whatever the Length does.
- A page that goes far off since the pass, in either direction, drops it. Say the pass was taken at
shortand the person writes far past the Length:longdrops it (unit test,next-step.test.ts:311). - A page that comes back to the same far-off state as the pass (
short, then within, thenshortagain) keeps the Fix pass. That doesn't hide anything: the Length's own pass was already dropped for good when the page came within, so Next shows the Length step first. Its accepted rewrite then clears the Fix pass. - Accept, then Undo, of a rewrite leaves the earlier Fix pass cleared, so Fix open rules can come back on the page from before. That costs one Skip, and it's rare. No change needed.
- No loop. The stale drop only removes passes, and each attempt writes its pass once (the attempt goes to null). The accept clear runs once per decision. While the rewrite's page is open,
thirdTakenis false, so no older timer can write over the clear.
- Stored state. The format is unchanged:
aeo:next-step-third-try:{draftId}holds{ attempt, passes }, andThirdPassis{ rules, length }.- A pass #1556 wrote reads the same way, and now holds in more cases. A #1556 tab that has already dropped such a pass for good doesn't bring it back.
- A Fix attempt that #1556 stored and that found nothing while the tab was closed passes on the first open with this build.
attemptReadis a ref and isn't stored.- A tab still on #1556's build reads this build's store without trouble. It drops a Fix pass on a Length change that this build keeps. That's harmless.
- What the person sees. This is only visible with Quality phase 1 or later, where the basket shows.
- Brings the page within its Length by hand after the agent took Fix open rules: Next stays on the step after it.
- Accepts a whole-page rewrite: a Fix open rules pass from the page before is gone, so Fix open rules comes back if rules are still open.
- The authors or another Quality read fails: Next still moves on once the run is decided.
- A Fix that found nothing while the tab was closed: Next moves on when the page opens.
- The deploy gap. None. Web only, with no new API field.
- The reads are on main and prod already:
getLastPageRewrite(00285) andreadAgentRun'ssteps,outcomeandstopped_at(00249). - The API on prod already writes a Fix run's write count at
steps[2], whichagentOutcomereads too.
- The reads are on main and prod already:
- Speed. No regex. The loops run over at most two passes and the open rules' keys.
- Tests.
- The unit test fails on main: there, the Fix pass taken at
shortdrops at''. - These page tests fail without their part of the change:
- Remove AI traces, without the
onlycheck; - the Fix that found nothing: on main, its attempt stays unended;
- the Fix begun while the read was out: main drops it;
- the attempt not put back: without
attemptRead, the failed attempt comes back; - both waits for the last rewrite: main writes the pass first;
- the failed authors read:
nextReadnever turns true on main; - the accept clear.
- Remove AI traces, without the
- The two
fixdropped-attempt cases pass on main too. They're the cover the review asked for. - I read the tests but didn't run them.
- The unit test fails on main: there, the Fix pass taken at
- Merge.
- One commit (d188b1d) on c00e0f0, #1556's squash. Main's 3b650fb adds #1544 on top, server only.
git merge-treewith main is clean (7b1fd25d). - It merges cleanly with #1566 (
_next-step.tsx, tree 438cdb18). #1566 adds aline-throughspan around the step's name, and the text the tests read stays the same. - It also merges cleanly with #1558 (
page.test.tsx, tree 5411e202). #1558's hunk is in the Fix run's Length hint test, apart from these.
- One commit (d188b1d) on c00e0f0, #1556's squash. Main's 3b650fb adds #1544 on top, server only.
Still open from #1556, as the PR says: the pass is kept per browser (round 34's item 4).
4 of 12 tasks
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.
Summary
Follow-ups to #1556's review: how the Next step basket's third step (Fix open rules, or the Length) stays passed once the agent took it.
1. Fix open rules holds while the person brings the page within its Length (
next-step.ts,thirdStepPasses).decidePage). The rewrite's own attempt stays, so it still passes its step.2. The pass waits only for what it compares (
_draft-editor.tsx).nextRead: the authors, the site's trust, the links, the facts and the page's read. If one of these failed (the authors, say), E-E-A-T never read,nextReadnever turned true, and a decided run never passed the step.thirdRead: the rules settled, the quoted passages (which hold some rules), and the page's last rewrite. The last rewrite moves the Length's state through its reach, andnextReaddidn't wait for it.lastRewriteReadFor, set in its read'sfinally). When a new rewrite shows, the pass waits for its re-read, not the one before.3. When the page opens.
attemptRead), not as it was. An attempt found failed stays gone.outcome: 'done', nothing written) is read asagentOutcomereads it, and marked ended. Before, it left no batch and was never marked, so Next stayed on Fix open rules.4. Tests.
onlycheck.step: 'length'and addkind: 'fix'(a tab closed mid-run).Still open, as in #1556: the pass is kept per browser (round 34's item 4).
Related issue
Follow-ups to #1556 (review items 1–4).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd web && yarn vitest run src/lib/content/next-step.test.ts 'src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx' -t "Next step basket|third step"Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run:
yarn test(427 files, 4,088 tests) andyarn build, both pass.🤖 Generated with Claude Code