Skip to content

feat(queue): standing issue↔queue coverage reconciliation (#7016) - #7697

Merged
dezren39 merged 3 commits into
mainfrom
queue/11447-7016-queue-coverage-reconciliation
Nov 9, 2026
Merged

dezren39 merged 3 commits into
mainfrom
queue/11447-7016-queue-coverage-reconciliation

Conversation

@dezren39

@dezren39 dezren39 commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Closes #7016

Problem

Nothing reconciles the open-issue set against fleet-queue coverage. Issues enter the queue only when a creator-class lane files them (file + enqueue in the same pass); anything filed another way — a work lane filing a blocker mid-task, an audit lane, by hand, or predating the queue (epics) — silently never gets a queue item, so no lane ever dispositions it. The 2026-11-07 reconciliation found 23 such issues across the four repos; that day's import was a one-off.

What this adds

Broker — read-only POST /coverage. Given the open-issue set the caller just enumerated, it answers per issue whether a live task (queued/claimed/parked/blocked) holds its repo-health dedupe key in the named queue. Per Drew's doctrine (2026-11-07): a done task is not coverage (done means triage or a landed slice, not a resolved issue), and neither is a task in a *-shadow queue. It never writes tasks or events.

scripts/fleet/queue-reconcile/ — the scheduled job:

  • enumerates open issues with gh api --paginate (PRs filtered out; a partial page would read as coverage that does not exist),
  • asks the broker for the diff,
  • with --import, enqueues a triage packet per uncovered issue through the sanctioned CLI path, dedupe-keyed repo-health:v1:triage:<repo>:issue:<n> so re-runs are idempotent by construction,
  • observe-only by default, matching the sweeper revalidator's two-step rollout,
  • a fetch or broker failure exits 3 and names the repo in an ERRORS section — it never reports as "0 uncovered".

systemd units (hourly at :41, Persistent) + a row in doc/fleet-schedule-registry.md per the same-pass rule.

AGENTS.md: the file-and-enqueue rule for issues filed outside a creator run.

Acceptance

  • A scheduled reconciliation exists — queue-coverage-reconcile.timer, hourly, persistent.
  • Its first run reports 0 uncovered — pending deployment: the units are repo-shipped but not installed, and the running broker does not yet serve /coverage (it needs a rebuild + restart). Verified end-to-end today: GitHub enumeration succeeds, the broker answers unknown command /coverage, and the script exits 3 with the repo named rather than reporting a false zero. Once the broker is redeployed the timer's first cycle produces the real number in ~/.local/state/queue-reconcile/latest.md.
  • The file-and-enqueue rule is written into AGENTS.md.

Unrelated fix included

validate.rs: FLEET_REPOS is declared [&str; 10] but holds 9 entries, so the fleet-queue lib test target does not compile at main with --all-features. CI does not build this crate, so the defect was invisible there. One-character fix; it blocks the test target this change needs.

Tests

cargo test -p fleet-queue --all-features
  100 passed (lib), 2 passed (integration), 0 failed
python3 -I scripts/fleet/queue-reconcile/test_check_coverage.py
  6 passed

New coverage: 4 parser cases + 2 proptest properties on the dedupe-key parser (canonical keys round-trip for every class and dispatch suffix; another repo's key never matches), and 6 offline script tests (observe imports nothing, import enqueues exactly the uncovered set, full coverage imports nothing, fetch failure is an error not a zero, packet shape, report written).

The packet the script builds validates against the live broker: repo-queue validate → packet valid (repo-task/v1).


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

Nothing reconciled the open-issue set against fleet-queue coverage, so
issues filed outside a creator run never got a queue item and no lane
ever dispositioned them. The 2026-11-07 import of 23 such issues was a
one-off; this is the standing version.

- broker: new read-only POST /coverage verb. Given the open-issue set
  the caller just enumerated, it answers per issue whether a LIVE task
  (queued/claimed/parked/blocked) holds its repo-health dedupe key in
  the named queue. A done task is not coverage, and neither is a task
  in another queue (Drew's doctrine, 2026-11-07).
- scripts/fleet/queue-reconcile/: check_coverage.py enumerates open
  issues via `gh api --paginate`, asks the broker for the diff, and
  (with --import) enqueues a triage packet per uncovered issue through
  the sanctioned CLI path, dedupe-keyed so re-runs are idempotent.
  Observe-only by default, matching the sweeper's revalidator rollout.
  A fetch or broker failure exits 3 and names the repo in an ERRORS
  section — it never reports as "0 uncovered".
- systemd units (hourly :41, persistent) plus a registry row.
- AGENTS.md: the file-and-enqueue rule for issues filed outside a
  creator run.

Also fixes a pre-existing compile error in validate.rs: FLEET_REPOS is
declared [&str; 10] but holds 9 entries, so the fleet-queue lib test
target does not build at main with --all-features. CI does not build
this crate, so the defect was invisible there. One-character fix.

Tests: cargo test -p fleet-queue --all-features — 100 lib + 2
integration pass, incl. 4 new parser cases and 2 proptest properties
(canonical keys round-trip for every class and dispatch suffix; another
repo's key never matches). python3 -I test_check_coverage.py — 6 pass,
offline via --fixture and a stub fleet binary.

Closes #7016
@dezren39
dezren39 requested a review from a team as a code owner November 8, 2026 13:22
@coderabbitai

coderabbitai Bot commented Nov 8, 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 8 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: 11501df1-f80c-4ed8-a943-529c95e93cce
Commits

Reviewing files that changed from the base of the PR and between 0405be4 and 7f31fad.

Files selected for processing: 8

  • AGENTS.md
  • doc/fleet-schedule-registry.md
  • pkgs/fleet/crates/fleet-queue/src/turso_queue.rs
  • scripts/fleet/queue-reconcile/README.md
  • scripts/fleet/queue-reconcile/check_coverage.py
  • scripts/fleet/queue-reconcile/systemd/queue-coverage-reconcile.service
  • scripts/fleet/queue-reconcile/systemd/queue-coverage-reconcile.timer
  • scripts/fleet/queue-reconcile/test_check_coverage.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 8, 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-09T05:36:59.103531Z
We couldn’t complete this review. Comment @codex review to try again.
7f31fad 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: b1356769ad

ℹ️ 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 on lines +1004 to +1005
let marker = format!(":{repo}:issue:");
let start = key.find(&marker)? + marker.len();

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 Recognize legacy repository aliases when matching coverage

For renamed pilot repos, existing live tasks can still carry dedupe keys using developing-today/opencode, developing-today/openchamber, or dezren39/nix, as documented in validate.rs:13-15. This exact marker search only recognizes the current repository name supplied by the reconciliation script, despite the preceding comment promising alias support. Those tasks are therefore reported as uncovered, and import mode creates duplicate triage work under a different dedupe key rather than recognizing the existing live task. Normalize the known aliases or match all equivalent names before declaring an issue uncovered.

AGENTS.md reference: AGENTS.md:L74-L78

Useful? React with 👍 / 👎.

Comment on lines +223 to +227
out = subprocess.run(
[fleet, "queue", "enqueue", str(tmp), "--queue", queue],
capture_output=True,
text=True,
timeout=120,

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 Reuse the selected broker connection for imports

When --import is combined with --broker-url or --token-file, coverage uses those options, but this enqueue subprocess receives neither setting. The fleet client independently resolves its broker from REPO_QUEUE_BROKER_URL, its local configuration, or the session proxy, and independently loads its token (pkgs/fleet/crates/fleet-queue/src/client.rs:68-103). Consequently, a run can report successful imports into a different broker while the inspected broker remains uncovered, or fail authentication despite the supplied token being valid. Pass the selected broker URL and token-file path to the child through REPO_QUEUE_BROKER_URL and REPO_QUEUE_TOKEN_FILE.

Useful? React with 👍 / 👎.

Comment on lines +220 to +221
tmp = Path(os.environ.get("TMPDIR", "/tmp")) / f"coverage-{packet['payload']['issue']['number']}.json"
tmp.write_text(json.dumps(packet))

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 Allocate a unique temporary file for each enqueue

When an ad-hoc import overlaps the scheduled import or another manual invocation, both processes use the same temporary pathname for a given issue number. One can overwrite the other's packet before its fleet subprocess reads it, or delete the file during cleanup. For equal issue numbers in different repositories, the subprocess can consequently read the other repository's packet while retaining its original --queue argument; broker validation does not check repository-to-queue correspondence, so this can enqueue work into the wrong pilot queue. Allocate a unique temporary file per enqueue rather than sharing a deterministic pathname.

AGENTS.md reference: AGENTS.md:L75-L77

Useful? React with 👍 / 👎.

Comment on lines +227 to +229
timeout=120,
)
finally:

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 Handle enqueue subprocess exceptions before continuing

If an enqueue exceeds 120 seconds or the fleet executable cannot launch, subprocess.run raises TimeoutExpired or OSError rather than returning a nonzero exit code. The finally only removes the temporary file, so the exception escapes through main, skipping all remaining issues and repositories as well as report generation, leaving the previous latest.md in place. The timeout is reachable during a slow broker response because the fleet client's direct transport permits a 300-second read (pkgs/fleet/crates/fleet-queue/src/client.rs:108). Catch these exceptions and return a failed enqueue result so the existing error aggregation and reporting path can execute.

Useful? React with 👍 / 👎.

)

- match legacy repo-name aliases (developing-today/opencode,
  developing-today/openchamber, dezren39/nix) when deciding coverage,
  so a live task under an old name is not reported uncovered and
  re-imported under a new dedupe key;
- pass the selected broker URL and token file through
  REPO_QUEUE_BROKER_URL / REPO_QUEUE_TOKEN_FILE to the enqueue child,
  so imports cannot land in a different broker than the one inspected;
- use a unique temp packet per enqueue, so overlapping runs cannot
  overwrite or delete each other's packet (or enqueue another repo's
  packet into the wrong queue);
- treat an enqueue launch failure or timeout as a failed enqueue
  instead of escaping main and skipping the remaining issues and the
  report.
@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, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@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, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@dezren39
dezren39 merged commit e74e657 into main Nov 9, 2026
2 of 6 checks passed
@dezren39
dezren39 deleted the queue/11447-7016-queue-coverage-reconciliation branch November 9, 2026 05:43
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.

queue: no reconciliation between open issues and queue coverage — non-creator filings never get queue items

1 participant