Skip to content

feat(pm-stack): scheduled-history collector — per-run history for OpenChamber scheduled tasks (#2174 Gap 1) - #8437

Merged
dezren39 merged 3 commits into
mainfrom
queue/12585-2174-run-history
Nov 14, 2026
Merged

dezren39 merged 3 commits into
mainfrom
queue/12585-2174-run-history

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Refs #2174 (Gap 1 of the evidence gaps; Gap 3 named as the follow-on on the issue).

Builds the per-run history consumer for OpenChamber scheduled tasks in pm-stack/scheduled-history/:

Live verification (2026-11-11): first tick inserted 24 rows (one per code-project scheduled task's latest run), every row token-enriched (e.g. one run: input 1,199,142 / output 6,470 tokens, cost 0.192); second tick inserted 0 (idempotent). Tests: test_collect.py 13/13 (insert, dedupe, running→error transition, supersede-finalize, token enrichment present/absent, never-ran, store round-trip).

Queue: task 12585, lane code-v (resumed prior handoff branch queue/12585-2174-run-history).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 02:27
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 58 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 02e3d1bd-c3fc-4d30-b1c2-e6a01c8edd6b
Commits

Reviewing files that changed from the base of the PR and between fa5548b and 3ffc41c.

Files selected for processing: 6

  • doc/fleet-schedule-registry.md
  • pm-stack/scheduled-history/README.md
  • pm-stack/scheduled-history/collect.py
  • pm-stack/scheduled-history/scheduled-history.service
  • pm-stack/scheduled-history/scheduled-history.timer
  • pm-stack/scheduled-history/test_collect.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-14T20:50:16.250346Z
We couldn’t complete this review. Comment @codex review to try again.
3ffc41c New commits
ℹ️ 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: 044d40f77a

ℹ️ 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 pm-stack/scheduled-history/collect.py Outdated
Comment on lines +170 to +173
if lookup is not None and row.get("tokens") is None and row.get("session_id"):
got = lookup(row["session_id"])
if got:
row.update(got)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Refresh usage while the session is still accumulating tokens

When the first poll finds a session that is still running, this condition permanently freezes its current token counts, cost, and session_updated_at: every later poll skips the lookup because tokens is already non-null. This also affects sessions that outlive the scheduler’s terminal transition, explicitly acknowledged in the README, so long-running tasks can retain zero or partial usage indefinitely and corrupt the comparison/watchdog dataset. Refresh session enrichment on subsequent polls independently of the scheduler outcome.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 3ffc41c (task 17227 shepherd pass) — see the merge-ready note on this PR for the per-finding disposition and the new regression checks in test_collect.py (19/19 pass).

Description=Run the scheduled-task history collector every 5 minutes — code#2174 Gap 1

[Timer]
OnCalendar=*:0/5

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Register the collector timer in the fleet schedule registry

This introduces a recurring laptop systemd schedule, but doc/fleet-schedule-registry.md has no entry for scheduled-history.timer, and this commit does not update the registry. Because the registry supplies the fleet placement audit’s inventory, this collector’s recurring work will be invisible to that review. Add its registry row in the same change, as required for new laptop timers.

AGENTS.md reference: AGENTS.md:L53-L58

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 3ffc41c (task 17227 shepherd pass) — see the merge-ready note on this PR for the per-finding disposition and the new regression checks in test_collect.py (19/19 pass).

Comment thread pm-stack/scheduled-history/collect.py Outdated
Comment on lines +235 to +237
if args.since and started < args.since:
continue
if args.until and started > args.until:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Compare parsed timestamps when filtering run history

When --since or --until uses an ISO timestamp with Z or a non-UTC offset, these string comparisons can include or exclude the wrong runs because stored timestamps always use +00:00. For example, a run starting at 2026-11-11T12:30:00+00:00 is excluded by --since 2026-11-11T13:00:00+01:00, even though that bound means 12:00 UTC. Parse and normalize both bounds and stored timestamps before comparing them so the documented inclusive time window operates on instants rather than their textual representations.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 3ffc41c (task 17227 shepherd pass) — see the merge-ready note on this PR for the per-finding disposition and the new regression checks in test_collect.py (19/19 pass).

Comment thread pm-stack/scheduled-history/collect.py Outdated
Comment on lines +196 to +198
os.makedirs(os.path.dirname(path), exist_ok=True)
doc = {"schema": "scheduled-history/v1", "rows": rows}
fd, tmp = tempfile.mkstemp(dir=os.path.dirname(path), suffix=".tmp")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve bare store filenames before creating their directory

When the collector is invoked with a bare relative store filename, such as --store history.json collect --dir /project, os.path.dirname(path) returns an empty string and os.makedirs('') raises FileNotFoundError. Consequently this --store override never saves any collected history, even though the same path works with list. Normalize the store path or resolve its parent to . consistently for both directory creation and temporary-file placement.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 3ffc41c (task 17227 shepherd pass) — see the merge-ready note on this PR for the per-finding disposition and the new regression checks in test_collect.py (19/19 pass).

@dezren39

Copy link
Copy Markdown
Member Author

agent-note:v1
state: picked-up
task: 17227
lane: code-a
worker: repo-worker-code
What: Shepherding PR #8437 to a terminal outcome (90-day review open-PR pass). Verified fresh: PR #8437 OPEN, head 044d40f, no held / user/owned / do-not-merge / do-not-auto-edit labels; issue #2174 OPEN; the scheduled-history module is NOT on current main. Codex review completed WITH four unresolved findings (P1: token enrichment frozen at first poll for still-running sessions, collect.py:173; P1: timer not registered in doc/fleet-schedule-registry.md; P2: --since/--until string comparison breaks with Z/offset bounds, collect.py:237; P2: bare relative --store filename crashes directory creation, collect.py:198). Per the Codex findings gate, these must be dispositioned before any merge.
Next: fix all four findings in a dedicated worktree with tests, push, recheck, and merge on its merits.

@dezren39 dezren39 added work/assigned Queue worker lifecycle state queue/claimed Queue worker lifecycle state status/in-progress Queue worker lifecycle state labels Nov 14, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@dezren39

Copy link
Copy Markdown
Member Author

agent-note:v1
state: merge-ready
task: 17227
lane: code-a
worker: repo-worker-code
What: Merging PR #8437 on its merits, with all four Codex findings fixed in commit 3ffc41c (each finding thread also has a reply):

  • P1 collect.py enrichment freeze: the tokens-is-None gate is removed — session enrichment now refreshes on every poll while the session store has the row, independently of the outcome freeze (docstring + README updated to match). New checks: refresh first poll enriches; later poll updates tokens on a terminal row.
  • P1 timer registration: scheduled-history.timer row added to doc/fleet-schedule-registry.md section 2b (OnCalendar=--* *:0/5:00, activates scheduled-history.service, code#2174).
  • P2 --since/--until string comparison: bounds and stored timestamps are parsed to instants (parse_instant: Z and non-UTC offsets handled, naive read as UTC) and compared as datetimes; an unparseable bound is an error (exit 2). New checks cover offset and Z bounds.
  • P2 bare --store filename: save_store resolves the parent via os.path.abspath before makedirs/mkstemp. New check: bare relative filename round-trips.
    Verification: python3 pm-stack/scheduled-history/test_collect.py — 19/19 checks pass (13 pre-existing + 6 new). Current main merged cleanly before the fix commit; PR is MERGEABLE/CLEAN. Post-merge ops note from the PR body stands: the laptop unit currently ExecStarts from the original branch worktree — reinstall from the primary clone now that the canonical-path unit lands on main.

@dezren39
dezren39 merged commit 3c72e9c into main Nov 14, 2026
2 checks passed
@dezren39
dezren39 deleted the queue/12585-2174-run-history branch November 14, 2026 20:50
@dezren39 dezren39 removed status/in-progress Queue worker lifecycle state queue/claimed Queue worker lifecycle state work/assigned Queue worker lifecycle state labels Nov 14, 2026
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