Skip to content

fix(orchestrator): project-reconcile.sh times out over ~200 items — make the bounded pass the standard path #1408

Closed

Description

@dezren39

Problem

project-reconcile.sh (org Project #4 "Developing Today" sync, orchestrator is single writer per #910 Stage 4) computes ALL proposals over the full ~200-item Project before writing anything. The proposal computation does not finish inside the run's time budget, so passes die with 0 Project writes:

  • 2026-10-27 07:41Z pass — ended incomplete at 540s timeout mid-list; which MOVE writes completed is unverified.
  • 2026-10-27 08:12Z pass — exit 124 at 240s, 0 writes (report: reconcile-2026-10-27-0812.txt, header + KEEP lines only).
  • 2026-10-27 08:43Z pass — interrupted during proposal computation, 0 writes (reconcile-2026-10-27-0843.txt, header only).
  • 2026-10-27 11:14Z pass — dry-run timed out at 240s after proposing on only ~20 of 200 items; --apply not attempted because it would time out identically.

Four consecutive incomplete passes. The Project board drifts behind actual issue/PR states until this lands.

What works today

The bounded inline pass (2026-10-27 06:23Z) applied 14 updates successfully by working a bounded slice instead of the whole list. The very first Stage 4 pass (2026-10-26) also completed when the Project had 27 items — the approach does not scale to 200.

Fix

Make the bounded pass the standard path in project-reconcile.sh:

  • Process items in bounded batches (e.g. oldest / most-blocked first, within the existing ~25-update cap), writing each batch before computing the next.
  • A pass that hits its time budget must leave the writes it completed applied and reported — never all-or-nothing.
  • The run report must state exactly which writes completed, so the next pass can resume instead of re-deriving state.
  • Keep the existing rules unchanged: label-gated auto-add (now/next/epic), status sync signals, single-writer discipline, no new Project fields.

Acceptance

  • A full pass over the ~200-item Project completes within the orchestration run's budget, or completes a bounded batch with applied writes and a precise resume point.
  • Two consecutive orchestration passes run with no incomplete-reconcile flag in the run log.

Activity

  1. developing-today commented on Oct 27, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    source/humanFiled directly by a human
    priority/highImportant and time-sensitive
    effort/mMedium: expected under 1 day of work
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    on Oct 27, 2026
  3. dezren39 commented on Oct 27, 2026

    @dezren39
    MemberAuthor

    Intake review

    🤖 Agent note · filed

    • Agent: fleet monitor (repo-fleet-monitor)
    • Session / ID: repo-fleet-monitor run 2026-10-27T14:14Z
    • Found via: monitor reconciliation (intake enrichment, protocol §5)
    • Task: intake pass — liveness check, labels normalized, acceptance criteria already present in the body under ## Acceptance
    • Expectation: see the effort label on this issue
    • Links: n/a

    Related: Related: filed from the orchestrator's own run logs after four consecutive incomplete passes (2026-10-27 07:41Z–11:14Z); the orchestrator/single-writer context is #910 Stage 4. The body already carries an ## Acceptance section, so no criteria were appended — this pass is labels + this note only.

    Risks / notes: The bounded inline pass at 06:23Z (14 updates applied) is the existence proof. Risk: batching must preserve the single-writer discipline and the ~25-update cap; a pass that reports writes it did not actually apply would be worse than today's honest zero — the report's write list should be verified against the Project after the first landed run.

    Suggested approach: Implement the bounded batch loop inside project-reconcile.sh itself (write each batch before computing the next), then watch two consecutive orchestration passes for the incomplete flag.

    Liveness: searched merged PRs and recent fleet records this run — no merged PR explicitly resolves this issue, so it stays open. Marked meta/enriched.

  4. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    Reconcile timeout fixes implemented (all three approved by Drew 2026-10-28 ~06:05 CDT). The hourly orchestration pass remains the single writer — no --apply was run outside it; the pass picks the new script up on its next reconcile step, and the incremental state file is already primed.

    1. Incremental proposals — project-reconcile.sh now persists project-reconcile-state.json beside itself: per item, the last proposal plus the signal snapshot it came from (issue state + updatedAt, and a hash of the repo's open-PR/branch signals). An item whose snapshot is unchanged reuses its stored proposal and skips the timeline fetch entirely. Cross-reference events bump the issue's updatedAt, and any open-PR or branch change flips the repo signal hash, so a stale reuse cannot survive a signal change. Missing/corrupt state, or a new --full flag, forces a full recompute.

    2. Batched signal reads — issue state/updatedAt and timeline cross-references for all ~200 items are now fetched with a few GraphQL queries per repo (aliased issue fields: one light query per repo for every item, one heavy timeline query covering only new/changed items). The per-repo open-PR and branch reads were already batched. If a repo's batched query fails, that repo falls back to the legacy per-item REST path — a GraphQL outage degrades to slow, not wrong. Proposal semantics are unchanged: same signal→status mapping, same ~25-write cap, same Done → In Review → In Progress → Todo apply order. The PR/branch matching logic was lifted verbatim into a shared function used by both paths.

    3. Step timeout 600s → 1500s — the 600s was not stored anywhere: not in the script, and not in the orchestration-pass job definition (job timeout is 1800s requested / 3600s effective). The pass worker was applying it ad hoc per run (240s in one early run, 600s later). It is now pinned durably in the job body's step-3 HOW line: run the script under timeout 1500. Verified by diffing the saved job definition before/after — that line is the only body change.

    Measured (dry-run, same 200 items)

    • Before: proposal step intermittently exceeded 600s → exit 124 with 0 writes (latest: 2026-10-28 04:12 pass). Last clean full run of the old script took ~12 min (05:12 pass). Re-run as a baseline today under load, the old script processed 137 of 200 items in ~24 min without finishing.
    • After, full recompute (no state): proposals in ~5.5 min, while competing with that baseline run.
    • After, incremental (steady state): proposals in 46s; whole script 1m52s — 198/200 items reused from state, 2 recomputed, result identical (0 changes, 200 unchanged, 0 skipped).
    • Semantics parity: all 137 proposal lines the old script produced today are byte-identical to the new script's output for the same items.
  5. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 2, 2026
  6. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  7. 17 remaining items

  8. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: done
    outcome: already_done; task 7242 was a duplicate coverage-loop triage of work already completed by task 2579 (#6590720979).
    verified: fetched origin/main SHA a51be0e contains neither a project-reconcile script path nor any tracked project-reconcile reference (git ls-tree + git grep). #1408 remains OPEN; no open PR references it. The prior triage records the out-of-repository scope and the remaining external check: two orchestration passes with no incomplete-reconcile flag.
    disposition: no code fix task can be routed in developing-today/code; do not close #1408 without the two-pass evidence. Claim labels cleared; no files changed.

  9. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    Orchestration pass orch-2026-11-06T16:17:44Z — fresh data point on the reconcile timeout: project-reconcile.sh --apply was killed by the 1500s wrapper (exit 124) during the scan/proposal phase, before any writes (0 APPLIED lines in reconcile-1617-apply2.log; log ends mid-scan at item #6298 of 523 items). A first --apply attempt the same run was SIGTERM'd mid-scan by a service restart. The same day's dry-run completed in ~6 min (16:23:38Z→16:29:50Z, pending=262), so apply-mode scanning is now far slower than dry-run scanning and cannot finish inside the cap — the Project backlog (262 pending proposals) is not draining. Full detail in the orchestrator run log (orch-2026-11-06T16:17:44Z, corrections 2-3).

  10. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor

    🤖 Agent note · done (triaged)

    • Agent: queue worker (repo-worker-code, lane code-y)
    • Session / ID: task 11944 (triage-doctrine re-triage; prior triages were task 2579 and task 7242)
    • Found via: queue claim
    • Task: Re-triage issue fix(orchestrator): project-reconcile.sh times out over ~200 items — make the bounded pass the standard path #1408 (project-reconcile.sh timeouts — make the bounded pass the standard path) on current state: real-and-current or validated invalid; convert to a fix packet if a scoped in-repo remainder exists.
    • Verdict: REAL AND CURRENT — not invalid, not closable, and NOT routable as a small_fix in developing-today/code, because the script does not live in this repo (the same disposition task 7242 reached, re-verified fresh below). No fix packet is enqueued in repo-health-code-pilot: a packet ordering a worker to edit a file this repo does not contain would be a packet defect.
    • Evidence:
      • Reproduced fresh on this issue (2026-11-06 orchestration pass comment): project-reconcile.sh --apply was killed by the 1500s wrapper (exit 124) during the scan/proposal phase with 0 writes, mid-scan at item id(phase-14): More shells (mobile, native, hardware) — v3 — outline: hardware shell #6298 of 523 items; the same day's dry-run completed in ~6 min with 262 pending proposals — the Project backlog is not draining in apply mode.
      • Intermittent, not recovered: the 2026-11-07T05:15:28Z pass completed cleanly (exit 0, ~757s) after the previous pass hung twice and was killed — passes squeak through at ~757s when they complete at all, against a 1500s cap in apply mode. The all-or-nothing scan remains the root cause named in the issue.
      • Out-of-repo scope re-verified: at current main c977d913e9d2, git ls-tree -r origin/main + grep find no project-reconcile script or reference in developing-today/code (task 7242 verified the same at a51be0e). The script is the orchestrator's own tooling. (Verification note: two tool outputs this shift named candidate script paths that direct checks refuted; no script home is asserted here because none could be verified — the negative claim, absence from this repo, is the one verified twice independently.)
      • Acceptance is operational: "two consecutive orchestration passes with no incomplete-reconcile flag in the run log" — that evidence can only come from the orchestrator's own passes after the fix, not from a PR in this repo.
    • What remains, and whose it is: (1) the bounded-pass rework (batched writes, resume-precise reporting, per the issue's Fix section) in project-reconcile.sh's own home — orchestrator tooling owner; (2) the two-clean-passes evidence from subsequent orchestration runs, after which this issue can close with that evidence. Recorded in the code backlog as an orchestrator-owned lead so it is not lost.
  11. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    FIXED 2026-11-08 — reconcile writes again (Drew: "fix it don't just notice it's broken")

    A dedicated fixing pass (not the hourly orchestrator) root-caused each failure mode, patched project-reconcile.sh in place, and ran one full real reconcile. Evidence below; the pre-fix script is preserved in the run's backup.

    Root causes (one per failure mode)

    1. Standing dry-run — THE blocker. The script's default mode was --dry-run, and the hourly orchestration pass invokes the script with no mode flag (its body says only "run it"). Every logged run in history — all of Nov 7 and Nov 8 — was mode=dry-run. Each pass computed ~262–289 proposals and wrote nothing; the same proposals recurred forever (e.g. code#1063 In Review -> Todo proposed at 09:56Z and again at 16:32Z). The board drifted: 209 of 524 items sat with Status UNSET, 289 changes pending at fix time.
    2. "gh project field-list failed (token scopes?)" — the token is fine: fetched fresh and verified live during the fix (field-list + item-list both succeed; Status field and all four options resolve). The failure was in the fetch path: the script looked the token up with the raw Bitwarden CLI while the pass body specifies the broker route (fleet secrets get github.project-token). The error handler then discarded gh's real stderr and printed the "(token scopes?)" guess — the same guess that sent earlier passes down the wrong trail.
    3. "item-list failed / user-token GraphQL rate limit exceeded" — two identities are in play: Project calls use the project token's own bucket; issue/PR/branch signal reads use the ambient gh identity (dezren39 user token), the bucket the whole fleet shares. When that bucket is exhausted, the batched signal queries fail (the jq: Cannot iterate over null lines in the logs).
    4. 1500s timeout mid-scan — when a batched query failed (mode 3), the script fell back to per-item REST for the whole repo: 2 REST calls × ~500 items against the same exhausted bucket. That fallback storm is what timed out (18:52Z pass died at 287/524 verdicts) and what kept project-reconcile-state.json stale, because state is only persisted after the proposal phase completes.

    The fix (all in project-reconcile.sh)

    • Default mode is now --apply. A bare invocation (what the pass runs) writes; --dry-run remains an explicit opt-in. The 25-writes-per-pass cap, apply ordering (Done first), and label-gated auto-add rules are unchanged.
    • Token fetch via fleet secrets get github.project-token (broker route, per the pass body) instead of the raw Bitwarden CLI lookup; field-list/item-list failures now log gh's real stderr (first 300 chars) instead of the "(token scopes?)" guess.
    • Legacy-fallback gate: a batched-query failure now records whether it was a rate limit. The per-item REST fallback engages only when the failure was NOT a rate limit AND the repo has at most 40 items; otherwise the repo is frozen for that pass — items reuse their stored proposals/state, the pass still completes, persists fresh state, and applies any still-valid writes. No more timeout storm.
    • Restored the exec bit on the script (found 0660; passes had been invoking it via a shell fallback — it is now directly executable again as documented).

    Proof run (2026-11-08, manual, this fix lane as the cycle's single writer)

    What remains

    • Not closing this issue yet. Per the fix brief, closure waits until the next regular orchestration pass also succeeds WITH writes (it should now: bare invocation defaults to apply). If the next pass logs mode=apply, applied>0, this issue can close.
    • The backlog (264 proposals + 23 adds) drains at the standing 25/pass cap — roughly 12 hourly passes. That cap is a pass rule, not a bug; changing it is Drew's call, not made here.
    • The ambient user-token bucket remains shared by all fleet signal reads; the freeze gate means an exhausted bucket now degrades a pass to stored proposals instead of killing it, but the bucket contention itself is unchanged.
  12. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    2026-11-12 partial failure (milestone writes: "Resource not accessible by personal access token"; 6 applied, 49 pending) — Drew's ruling: board sync should not run on the single Projects-only PAT. Fix direction filed as #8887: a fleet gh passthrough that rotates the personal token + the 3 App installation tokens, with project-reconcile.sh rewired onto it.

  13. developing-today-fleet commented on Nov 12, 2026

    @developing-today-fleet
    Contributor

    Both failure modes tracked here are fixed and verified 2026-11-12:

    1. Milestone "Resource not accessible" writes — root cause: Status writes ran under the Projects-only PAT, which GitHub refuses on issues carrying a milestone. Fix: fleet gh (code#8887; PRs fleet gh: passthrough with personal + App token rotation (#8887) #9014 + fleet gh: rotate all three fleet Apps, add tiers probe, platform-verifier TLS roots (#8887) #9054) rotates the personal token and all three fleet Apps' installation tokens; project-reconcile.sh and project-sync-apply.sh now run through it. Verified: the code#8582 milestone write lands both directions; a full pass completed with zero "Resource not accessible" failures; 11 rate-limit-queued writes drained and readback-verified on the board.
    2. Timeouts / lost runs — root causes: per-item jq + branch-scan cost across ~800 items, and run output living in per-exec /tmp. Fixes in project-reconcile.sh: per-repo verdict maps precomputed once, a 1200s self-timebox that ends the pass cleanly with applied writes + resume state (state rows for unprocessed items carry forward), and a persistent per-run log (reconcile-orch-.log) teed into the state dir. The fixed pass ran in 194s.

    Also fixed en route: the App leg's HTTPS used webpki-roots and failed with UnknownIssuer behind the sandbox's TLS-intercepting egress proxy; it now validates against the platform root store (PR #9054).

    Closing as completed — per-pass verification continues in orchestrator-log.md; any recurrence gets a fresh issue per the file-the-issue rule.

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

Metadata

Metadata

Assignees

Labels

effort/mMedium: expected under 1 day of workepic/pm-stackReprioritization program epic (2026-11-12)kind/bugSomething isn't working (prefixed form of the classic bug label)meta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivesource/humanFiled directly by a humanstatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions