Skip to content

Atlas refresh: count failed weeks at >=168 h, keep state of failed runs, say recorded checks - #313

Merged
cw-instinct[bot] merged 4 commits into
mainfrom
fix/atlas-refresh-state-recorded-weeks
Nov 21, 2026
Merged

cw-instinct[bot] merged 4 commits into
mainfrom
fix/atlas-refresh-state-recorded-weeks

Conversation

@cw-instinct

@cw-instinct cw-instinct Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Code, tests and protocol text only. No Atlas data or generated files (PR #311 is untouched).

Why

The Nov 15 refresh run failed after the Refresh step, so its failed-week counters were never saved and the Nov 21 run counted from older state. Also, every failed run added a "week", so a manual dispatch plus the Sunday schedule or a retry could close an entry in one week, and the closed card said "2 consecutive" while its claim said 3.

Changes

  • Counting: a failed check adds a week only when at least 168 h passed since the previous counted failed check (last_counted_at). An older entry with exactly 1 failed week uses first_failed_at (this script sets it only when it creates the entry and counts it in the same run). When the previous count time is unknown or unreadable, the check does not count: interval_baseline_at is set as the start of the 7 days; failed_weeks and first_failed_at are kept. No tolerance for schedule drift, so a Sunday run that starts earlier than the previous counted one can wait one more week; it never closes early.
  • Durable state on failure: if a step after Refresh fails, only refresh-state.json is uploaded as artifact atlas-refresh-state (21 days). atlas/tools/carry_failed_state.py (read only) scans the last 100 runs of refresh.yml on main with conclusion failure or timed_out, checks the artifact's branch, takes the newest valid state by updated_at, and skips anything missing, expired, undownloadable or malformed. refresh.py --state-from is repeatable; the newest valid updated_at wins, so an older state never overrides a newer one. No PR is opened by a failed run and no generated data is published.
  • Earned closure (Codex P1 on 87fad69): when a run counted the 2nd week but only its state was kept, the retry within 7 days closes the card without adding a week. Only an entry with failed_weeks >= 2 and a valid last_counted_at qualifies; legacy history without one is never treated as earned, and the check must still fail.
  • Adopted state is persisted (Codex P1 on 5f585e0): the run compares its final state with the state on disk, not with the adopted candidate, so a same-week rerun that carries an open PR's state (or a failed run's) writes it even when it counts nothing; the workflow then sees a state-only diff in atlas/data, opens its PR and only afterwards closes the superseded one.
  • Step order (Codex P2 on c31e3aa): the artifact upload is the last step of the job, so failure() also sees a failure of Open PR or of the cleanup; a structural test pins the order and the condition.
  • Wording: new closure claims, status history and events say "N recorded weekly checks since "; the closed box states the rule separately from the evidence. Existing claims are not rewritten.
  • PROTOCOL.md describes the counting rule.

Checks

New tests: tests/test_refresh_state_wording.py and tests/test_carry_failed_state.py (offline, fake gh, patched clock; same-week reruns, exactly 7 days, unknown/bad last-count time, failed Refresh then retry, newest-by-timestamp selection, expired/missing/malformed artifacts, branch/event provenance). Full suite: 537 tests OK locally; site build and check.py pass.

Not verified

The workflow itself has not run on GitHub: the failure() condition and job-timeout behavior, artifact upload/download, gh run list/download and the artifacts API shapes in this repo, and token permissions. That needs one real failing run on a branch, not done here. A run that adopts a carried state and changes nothing writes no state; the artifact expires after 21 days. Takes effect only after this lands on main; the existing four closed cards keep their old claim text.

No Codex request, merge or deploy is part of this PR.

…ns, say recorded checks

Code, tests and protocol only; no Atlas data.
@cw-instinct
cw-instinct Bot requested a review from nerd27dk as a code owner November 21, 2026 21:21
@github-actions github-actions Bot added the outside-signal Report or PR from outside the Commonworld team; picked up by our sweep label Nov 21, 2026
@nerd27dk

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T23:12:01.306317Z fc6f097 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 87fad69990

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread atlas/refresh.py Resolved
…er week

Codex P1 on 87fad69: a retry after a run that counted the 2nd week but lost the closure stayed live. A valid last_counted_at with failed_weeks >= 2 and a still-failing check now closes the card without adding a week; legacy history without a valid count time is never treated as earned.
@nerd27dk

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f585e03e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread atlas/refresh.py Resolved
…hing

Codex P1 on 5f585e0: state_before was taken after adopting a --state-from candidate, so a same-week rerun carrying a PR's state wrote nothing and the superseded PR branch was deleted with its counters. The run now compares with the state on disk.
@nerd27dk

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c31e3aa93a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/refresh.yml Resolved
Codex P2 on c31e3aa: failure() is evaluated when a step's turn comes, so the upload placed before Open PR could not see a failure of Open PR or of the cleanup. It is now the last step; a structural test pins the order and the condition.
@nerd27dk

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: fc6f09704c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cw-instinct
cw-instinct Bot merged commit f3bae1d into main Nov 21, 2026
14 checks passed
@cw-instinct
cw-instinct Bot deleted the fix/atlas-refresh-state-recorded-weeks branch November 21, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

outside-signal Report or PR from outside the Commonworld team; picked up by our sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant