Skip to content

test: drain the tick's detached persist before the restart load - #45073

Closed
CrysisDeu wants to merge 1 commit into
mainfrom
fix/autonudge-restart-holds-row
Closed

CrysisDeu wants to merge 1 commit into
mainfrom
fix/autonudge-restart-holds-row

Conversation

@CrysisDeu

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Turn main green again by making the failed-holds-settlement restart test wait for the first service's pending write before it restarts.

Main is red at ec12d79 on Backend Tests (3.12, 7) and Backend Tests (Windows) (6). Both fail the same test:

FAILED test/test_autonudge_shutdown_terminal_reprobe.py::test_MUTATION_a_failed_holds_settlement_write_keeps_memory_store_and_restart_agreed
>  assert restored.active is True
E  AssertionError: assert False is True
WARNING kiro_crew.autonudge:store_loader.py:373 AutoNudge: loop 'monitor-terminal-holds-write-fails' was changed outside the gateway since its last save; loading it stopped

Why it matters

Every PR whose CI runs this file is red until main is fixed.

Not a goal

What changed (motivation → approach → change)

Decision: (A) the check is right; the test was wrong. No production change.

  • fix: tighten a loop store check #44935 added the row digest check: store_loader.py:929 (if row_digest(raw) not in recorded: _hold_unverified_row(loop)). store.py:248-253 writes the digest record as a superset before the store rename, and store.py:284-288 compacts it to the new rows after the rename.
  • The test calls service._timer(...). That tick leaves a supervised detached write from _persist_soon (autonudge.py:1278, held in _inflight_adds). The test then built a second AutoNudgeService on the same directory while that write was still running.
  • A local trace showed the race. The restart read autonudge.json before that write's rename (row digest 2ead86…). It read the digest record after the compaction (only cd0d18…). So the live row loaded as unverified_row.
  • A real restart never overlaps the old instance's writes: shutdown() drains them first. The test now awaits service._inflight_adds right after the tick, before it reads the store or restarts.

Every assertion is kept: one snapshot write, no expired, memory/store/restart all active=True with terminal_delivered == "success", then the retry settles.

Backwards compatibility

Compatible: test-only change.

Removes nothing: the diff adds one await in one test.

Tests

  • test_MUTATION_a_failed_holds_settlement_write_keeps_memory_store_and_restart_agreed now drains the first service's detached writes before reading the store and restarting.

Proof: not provable -- test-only change

Manual verification

N/A — test-only change; CI runs the file.

Real-machine verification

N/A -- the diff changes one test and runs no product code. CI shard evidence will be added in a comment.

Related Issues

Fixes #45072

Sibling sweep

Swept: git grep -lE "AutoNudgeService(base_dir=tmp_path" -- test/ | xargs grep -l restart
Sibling: test/test_autonudge_shutdown_terminal_reprobe.py -- changed here
Siblings: none -- run 46485804677 on the first main commit with #44935 ran every backend shard and only this test failed

Pattern harvest

Rule candidate: review-prompt
Pattern: a test that builds a second service on the same store dir must drain the first one's detached writes (or shut it down) before the second one loads.

Checklist

  • A Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commits
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

The failed-holds-settlement test restarted a second service while the
first still had a supervised _persist_soon write in flight. Since #44935
a load verifies each row against the gateway's digest record, so a load
that read the store before that write's rename and the digest record
after its compaction held the live row stopped as unverified_row. A real
restart drains those writes in shutdown first; the test now does too.
@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners November 30, 2026 19:32
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 39a5f6fb393f1e4a4bed9ce08fd1dc1d8183ed99 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision 39a5f6fb393f1e4a4bed9ce08fd1dc1d8183ed99 ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 39a5f6fb393f1e4a4bed9ce08fd1dc1d8183ed99 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: this is a test-only change that waits for the first service's detached write before the restart, the same drain shutdown() already does.

Notes

  • The await collects _inflight_adds once. A persist that starts after that point, or one queued in _inflight_persistence, is not waited for. Calling service.shutdown() before the restart would match the real restart order exactly and avoid that gap.

[DESIGN-REVIEWED] 39a5f6f

Description read

[DESCRIPTION-READ] 8598f4877b479f9112c2729cfdf941aed797027a6775ea05a9f7e075e73e59b0

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 39a5f6fb393f1e4a4bed9ce08fd1dc1d8183ed99 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 39a5f6f

Verdict parsed from the review's SHA-scoped output markers for commit 39a5f6fb393f1e4a4bed9ce08fd1dc1d8183ed99.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 39a5f6fb393f1e4a4bed9ce08fd1dc1d8183ed99 false-positive: <reason, 20 to 500 characters>

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 39a5f6fb393f1e4a4bed9ce08fd1dc1d8183ed99 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 39a5f6f

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 39a5f6fb393f1e4a4bed9ce08fd1dc1d8183ed99 false-positive: <reason, 20 to 500 characters>

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

CI proof on head 39a5f6f: Backend Tests (3.12, 7) is green. That shard runs test/test_autonudge_shutdown_terminal_reprobe.py, which fails on main ec12d79.

The one red, Backend Tests (Windows) (7), fails test/test_mcp_body_fields.py::TestTheSizeRefusalIsNamedAndOffered::test_an_owner_row_lets_the_field_through (facade mirror raises on sel in dashboard.handlers_instances). This PR does not touch that file. It is tracked in #45081. Design Review: PASS.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Superseded by #45124 (merged 22:42Z by @bolichen97). It drains the same detached _persist_soon writes (plus _inflight_persistence) before the restart in this test. This branch now conflicts with it and adds nothing. Closing.

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

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

main red: autonudge restart test loads its row as unverified_row after #44935

1 participant