Skip to content

ticket-275: keep the stale index window longer than a real rebuild, and stop serving stale to require_fresh - #336

Merged
ifuri-validator-agent[bot] merged 1 commit into
mainfrom
ticket/275-keep-the-stale-index-window-longer-than-a-real-rebuild
Nov 2, 2026
Merged

ifuri-validator-agent[bot] merged 1 commit into
mainfrom
ticket/275-keep-the-stale-index-window-longer-than-a-real-rebuild

Conversation

@tom-sapletta-com

Copy link
Copy Markdown
Contributor

The Planfile HTTP API flapped between 200 and 503 whenever an index rebuild ran, although a coherent last-known-good snapshot existed the entire time.

Two defects:

  1. The window was shorter than the repair. _INDEX_REPAIR_STALE_WINDOW_SECONDS was 300.0, but a rebuild of the production store (22 358 tickets, 517 MB) takes 5–9 minutes — measured twice today. The window expired inside the repair and machine callers got 503 even though _bounded_stale_index_response could have served the committed snapshot.

  2. require_fresh was ignored on that path. _bounded_stale_index_response() never received require_fresh, so a caller that explicitly asked for freshness was served a stale body with 200 and X-Planfile-Index-State: stale. The freshness guard only covered the in-memory cache path.

Change

  • The stale window now covers a real repair (1 hour). It stays bounded, so a permanently broken index still fails closed.
  • require_fresh=True returns None from the stale helper, so the request falls through to the explicit 503 instead of receiving stale content.

Verification

  • pytest tests/test_sqlite_ticket_index.py → 76 passed, including the new test_stale_index_survives_a_repair_longer_than_five_minutes_but_never_lies:
    • a 20-minute-old snapshot is served with X-Planfile-Index-State: stale (impossible before: 300 s window)
    • require_fresh=true answers 503
  • pre-existing note: the full suite shows 5 failures in tests/test_scheduled_github_sync_workflow.py in a dirty primary checkout only — that fixture observes the working tree. At this exact commit in a clean checkout those tests pass 9/9, so they are not caused by this change.
  • ./project/governance-check.sh → GOV-PASS

A rebuild of the production store (22 358 tickets, 517 MB) takes 5-9 minutes,
but the stale-serving window was 300 s. It therefore expired inside the repair
and machine callers got 503 while a coherent last-known-good snapshot existed.

The window now covers a real repair and stays bounded (a permanently broken
index still fails closed). While fixing it: the bounded stale helper never
received require_fresh, so a caller asking for freshness was served stale data
with 200 and X-Planfile-Index-State: stale. It now falls through to 503.

@ifuri-validator-agent ifuri-validator-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Validator approval after policy checks for exact head 5d00995a1d51747b9fce03fe2a11d381c9b91d6c.

Ticket: ticket-275
Correlation ID: local-semcod-planfile-pr-336-ticket-275
Model: openai/cursor-auto
Reviewed diff chunks: 1
Advisory LLM verdict: APPROVE
Advisory summary: Reviewed all 1 diff chunk(s). The change correctly extends the bounded stale-index window to cover observed rebuild durations while preserving fail-closed behavior for callers using require_fresh. The new regression test exercises both stale availability and the freshness guarantee.
Advisory findings: none
The LLM output above is advisory and was not used as the approval trust root.
Semantic review prerequisite: not_required; policy 676cb4516bbfed2a000e40b9b1b6e4a430ecc761ec546aeb53d721a1905cfdd7.

Actual PR impact radar

Exact range: 4beae8017732058a900be38ecd54041059274c82...5d00995a1d51747b9fce03fe2a11d381c9b91d6c
Change digest: bbb0f73991f91eb5fbdd59007b8463ea3e55a8bc116c717878a0aa2788255177
Score: 64/100 (L), estimated 67 min, split recommended: true
Affected services/components: repository-wide/unclassified

Machine-readable radar JSONL and SVG
{"actual_change":{"additions":125,"base_sha":"4beae8017732058a900be38ecd54041059274c82","binary_files":0,"categories":{"code":1,"configuration":1,"docs":2,"tests":1},"change_digest":"bbb0f73991f91eb5fbdd59007b8463ea3e55a8bc116c717878a0aa2788255177","comparison":"4beae8017732058a900be38ecd54041059274c82...5d00995a1d51747b9fce03fe2a11d381c9b91d6c","deletions":1,"file_count":5,"files":["planfile/api/server.py","project/TICKETS.md","project/ticket-275/README.md","project/ticket-275/intent.json","tests/test_sqlite_ticket_index.py"],"head_sha":"5d00995a1d51747b9fce03fe2a11d381c9b91d6c","service_count":0,"services":[]},"assessment_mode":"observed-pr","axes":{"coupling":5,"delivery":3,"scope":3,"uncertainty":3,"validation":2},"complexity":"L","confidence":0.9,"diagnostics":["RADAR-ACCEPTANCE-MISSING","RADAR-BUDGET-EXCEEDED"],"estimate":{"budget_minutes":30,"minutes":67,"within_budget":false},"impact":{"components":["9","planfile","project","tests"],"files":["9/9","planfile/api/server.py","project/TICKETS.md","project/governance-check.sh","project/ticket-275/README.md","project/ticket-275/intent.json","tests/test_scheduled_github_sync_workflow.py","tests/test_sqlite_ticket_index.py"],"public_interfaces":["planfile/api/server.py"],"runtime_dependencies":0},"schema":"subactor.ticket-radar/v1","score":64,"split":{"parts":[{"estimated_minutes":20,"name":"Define contract and acceptance boundary","scope":["planfile/api/server.py"]},{"estimated_minutes":10,"name":"Implement 9","scope":["9"]},{"estimated_minutes":10,"name":"Implement planfile","scope":["planfile"]},{"estimated_minutes":10,"name":"Implement project","scope":["project"]},{"estimated_minutes":10,"name":"Implement tests","scope":["tests"]},{"estimated_minutes":15,"name":"Validate and project to trackers","scope":["tests","planfile","github/gitlab/jira projections"]}],"reason":"estimated_minutes_exceed_budget","recommended":true},"standards":[{"id":"wellmanifest/dsl","revision":"6c60fc4e0dd1f1bb74f46a7745e28019908d1203","version":"0.1.0-dev"},{"id":"wellmanifest/ticket-lifecycle","revision":"5bf581907a87b46a13a73e6c033d3abe4d9a306f","version":"0.1.0-dev"},{"id":"wellmanifest/git-lifecycle","revision":"7d77d4b7af57e69bc75c3a0290b3a4805c5c4438","version":"0.2.0-dev"},{"id":"wellmanifest/logs","revision":"48c284ef7a069055c0bcb6b900147ce5e65f8b43","version":"0.3.0"}],"ticket_ref":"ticket-275"}
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128" role="img"><title>ticket-275: ticket-275: keep the stale index window longer than a real rebuild, and stop serving stale to require_fresh</title><rect width="128" height="128" rx="12" fill="#f8fafc"/><g stroke-width="1"><polygon points="64,55 72,61 69,71 59,71 56,61" fill="none" stroke="#d7dde5"/><polygon points="64,47 80,59 74,78 54,78 48,59" fill="none" stroke="#d7dde5"/><polygon points="64,38 89,56 79,85 49,85 39,56" fill="none" stroke="#d7dde5"/><polygon points="64,30 97,53 84,92 44,92 31,53" fill="none" stroke="#d7dde5"/><polygon points="64,21 105,51 89,99 39,99 23,51" fill="none" stroke="#d7dde5"/><line x1="64" y1="64" x2="64" y2="21" stroke="#aab4c0"/><line x1="64" y1="64" x2="105" y2="51" stroke="#aab4c0"/><line x1="64" y1="64" x2="89" y2="99" stroke="#aab4c0"/><line x1="64" y1="64" x2="39" y2="99" stroke="#aab4c0"/><line x1="64" y1="64" x2="23" y2="51" stroke="#aab4c0"/></g><polygon points="64,38 105,51 79,85 54,78 39,56" fill="#fb923c" fill-opacity="0.45" stroke="#c2410c" stroke-width="2"/><circle cx="64" cy="64" r="3" fill="#c2410c"/><g font-family="sans-serif" font-size="7" fill="#334155"><text x="64" y="11" text-anchor="middle">SCO</text><text x="114" y="48" text-anchor="middle">COU</text><text x="95" y="107" text-anchor="middle">UNC</text><text x="33" y="107" text-anchor="middle">VAL</text><text x="14" y="48" text-anchor="middle">DEL</text></g><text x="64" y="124" text-anchor="middle" font-family="sans-serif" font-size="8" fill="#0f172a">L · 67m</text></svg>
Merge will be attempted after this approval when explicitly authorized. ## Decision record (recomputable)
DECISION D-275-5960
TICKET ticket-275
HEAD_SHA 5d00995a1d51747b9fce03fe2a11d381c9b91d6c
CORRELATION_ID local-semcod-planfile-pr-336-ticket-275
ACTOR agent:ifuri-validator-agent[bot]
APPLIED_RULE P-CORE-015
INPUT author_login = "tom-sapletta-com"
INPUT observed_checks = ["notify=PASS","test (3.10)=PASS","governance / enforce=PASS","test (3.13)=PASS","ci-loop=PASS","governance / remote lifecycle=PASS","freshness=PASS","onedev/local-verify=PASS"]
INPUT required_checks = ["ci-loop","notify","freshness","governance / remote lifecycle","governance / enforce","test (3.10)","test (3.13)","onedev/local-verify"]
INPUT required_checks_source = "protected registry + GitHub applied rules (env/request)"
INPUT reviewer_login = "ifuri-validator-agent[bot]"
INPUT semantic_review_assessment = {"schema":"subactor.validator/semantic-review-assessment/v1","subject":{"repository":"semcod/planfile","pull_request":336,"head_sha":"5d00995a1d51747b9fce03fe2a11d381c9b91d6c","base_sha":"4beae8017732058a900be38ecd54041059274c82","diff_sha256":"5aaa84694820c85f34ae93da250af5ae128799bcf97b35e35c167ebfbdd358ee"},"policy":{"policy_schema":"subactor.validator/semantic-review-policy/v1","policy_version":1,"policy_sha256":"676cb4516bbfed2a000e40b9b1b6e4a430ecc761ec546aeb53d721a1905cfdd7","required":false,"critical_paths":[],"observed_paths":["planfile/api/server.py","project/TICKETS.md","project/ticket-275/README.md","project/ticket-275/intent.json","tests/test_sqlite_ticket_index.py"]},"grounding":"full-diff-not-per-finding-proof","execution_authority":false,"status":"not_required","reason":null,"review_sha256":null,"unresolved":[]}
INPUT superseded_checks = []
INPUT ticket_radar_receipt = {"schema":"subactor.ticket-radar/v1","base_sha":"4beae8017732058a900be38ecd54041059274c82","head_sha":"5d00995a1d51747b9fce03fe2a11d381c9b91d6c","change_digest":"bbb0f73991f91eb5fbdd59007b8463ea3e55a8bc116c717878a0aa2788255177","score":64,"complexity":"L","estimated_minutes":67,"split_recommended":true,"services":[],"authority":"ADVISORY","promotion":"FORBIDDEN"}
VERDICT APPROVE AUTHORITY DETERMINISTIC
REJECTED REQUEST_CHANGES BECAUSE NO_UNSAFE_CHANGE_REASON_FOUND
ADVISORY llm_verdict = "APPROVE" MODEL "openai/cursor-auto"
ASSERT VERDICT_AUTHORITY != "ADVISORY"

@ifuri-validator-agent
ifuri-validator-agent Bot merged commit 808dc1d into main Nov 2, 2026
8 checks passed
@ifuri-validator-agent
ifuri-validator-agent Bot deleted the ticket/275-keep-the-stale-index-window-longer-than-a-real-rebuild branch November 2, 2026 17:32
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.

1 participant