Skip to content

fix(ci): env-var budget check fails on main after the Doctor lint anchor handoff - #172887

Merged
steipete merged 2 commits into
mainfrom
steipete/env-var-budget-455
Oct 15, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/env-var-budget-455

Conversation

@steipete

@steipete steipete commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: the environment-variable budget check fails on every main push (and in PRs that run the max-lines ratchet) because #170374 added a 455th distinct OPENCLAW_* name against the owner-held budget of 454.

User Impact

No user-visible change. The CI ratchet passes again (OPENCLAW_* count 454/454) without raising the budget, and update rehearsal budgeting behaves exactly as #170374 intended.

Why This Change Was Made

#170374 anchors each rehearsal validation command's optional-inspection window at that command's own start. The rehearsal doctor lint --json CLI spawns a separate lint worker that starts later, so it handed the worker its start time through a new environment variable, OPENCLAW_UPDATE_REHEARSAL_COMMAND_STARTED_AT_MS. That value had exactly one consumer (the worker's single budget resolution), and the CLI already sends that worker a JSON payload on stdin from the same build.

The anchor now travels in that stdin payload as a strict { options, commandStartedAtMs } envelope and is threaded into resolveDoctorUpdateBudget. In-process lint and the repair Doctor (which runs in its own driver-spawned process) keep anchoring at their own performance.timeOrigin, so budget semantics are unchanged. The environment name and its constant are deleted.

The deferred-inspection result builder moves unchanged into doctor-lint-output.ts, beside its sibling createStateSnapshotFailureExecution, so doctor-lint-runner.ts stays within its 700-line cap.

Release-note context: internal CI/update-rehearsal fix; no changelog entry needed.

Evidence

  • node --import ./scripts/tsx.mjs scripts/check-env-var-count.mts: OPENCLAW_* count 454/454 (was 455 exceeds budget 454 on main). Bisected with the script's own file filter: 454 at the parent of c7dd7b9, 455 at c7dd7b9; that name is the only net change since the last budget commit.
  • pnpm check:max-lines-ratchet, pnpm check:assertion-safety, pnpm check:test-mock-exports (all --base origin/main): pass.
  • pnpm test src/commands/doctor-lint-process.test.ts src/commands/doctor-lint.update-budget.test.ts src/cli/doctor-lint-disposal.process.test.ts src/cli/program/register.maintenance.lazy.test.ts: 24 passed. The disposal test spawns the real lint worker, so the new stdin envelope is exercised end to end; the process test asserts the envelope carries the anchor, and the update-budget test proves an inherited anchor wins over the process start.
  • pnpm tsgo, oxlint and oxfmt on touched files, git diff --check: clean.

Inherited CI failure (not caused by this PR)

checks-ui-e2e (2/7) fails ui/src/e2e/session-management.sidebar.e2e.test.ts > nests spawned sessions (both personal-pin variants) with expected 4 to be +0 at the "children start collapsed" assertion. This PR changes no ui/ files. The same failure reproduces locally on bare origin/main at 90943ae without this diff (pnpm test:ui:e2e ui/src/e2e/session-management.sidebar.e2e.test.ts -t "nests spawned sessions": 2 failed). Bisected locally: both cases pass at 4d60655 and fail at 12ec309 (#172362, fix: reveal new child sessions in the sidebar), which changed child-session reveal behavior without updating this e2e; the newest scheduled main CI run (38694591842, head e1dbb56) predates it, so the failure report has no comparable main job. Tracked separately as a red-main follow-up.

The first CI run (38697658120) also failed check-test-types-core-5 with a TS2322 in this PR's own test (options.input is string | Uint8Array); fixed in 66514e4 by narrowing the captured stdin to a string.

#170374 added OPENCLAW_UPDATE_REHEARSAL_COMMAND_STARTED_AT_MS so the
rehearsal `doctor lint --json` CLI could pass its validation-command
budget anchor to the lint worker it spawns. That pushed the distinct
OPENCLAW_* count to 455 against the owner-held budget of 454, failing
the env-var check inside the max-lines ratchet on every main push.

The CLI already sends the worker a JSON payload on stdin and both
processes are always the same build, so the anchor now travels there.
The worker parses a strict { options, commandStartedAtMs } envelope and
threads the value into its single resolveDoctorUpdateBudget call; every
other command keeps anchoring at its own performance.timeOrigin. Budget
semantics are unchanged.

The deferred-inspection result builder moves next to its sibling
createStateSnapshotFailureExecution in doctor-lint-output.ts so
doctor-lint-runner.ts stays within its line cap.
@clawsweeper

clawsweeper Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 15, 2026 07:16
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T07:19:31.322029Z f8d586d Draft marked ready
ℹ️ 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.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S labels Oct 15, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 15, 2026
@clawsweeper

clawsweeper Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR passes Doctor lint’s command-start anchor through the existing worker stdin payload instead of an environment variable.

Example: The environment-variable ratchet checks production source against its budget of 454 names.

  • Before: The additional worker-handoff variable produces 455 names and fails the check.
  • After: The supplied command output reports 454/454 while the worker receives its anchor through stdin.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused patch appears correct and the central CI count has supplied terminal evidence, but update-path proof is incomplete and one changed test asserts mock plumbing.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Main-push and affected PR validation fail the environment-variable budget check.
Reason: The maintainer-authored direction removes an unnecessary private environment variable without increasing the budget or adding an operator setting.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs a concrete CI ratchet failure without raising the budget, and no introduced correctness or security defect was found.

Priority: P2
Reviewed head: f8d586dc06095fe6abfbac72ba5cce7c659704ae

Before merge

None.

Findings

None.

Tests

  • Low-value test src/commands/doctor-lint-process.test.ts: Remove or replace the updated handoff case with behavioral coverage: it asserts the payload passed to a mocked process runner without showing that the worker consumes the anchor.
  • Missing end-to-end proof: The supplied worker test bypasses budget admission with --only; no published-driver update run for this head demonstrates anchor consumption through the new envelope, and base-fail/head-pass coverage of that composition is not shown.
Agent review details

How this fits together

The update rehearsal launches a candidate Doctor CLI, which supervises a same-build lint worker; the worker consumes options and timing information and returns a JSON inspection report.

flowchart TD
A[Update rehearsal] --> B[Candidate Doctor CLI]
B --> C[Worker stdin envelope]
C --> D[Doctor lint worker]
D --> E[Shared inspection budget]
E --> F[JSON inspection report]
Loading

Technical review

Best possible solution:

Use the existing same-build stdin handoff while preserving command-start budgeting, advisory deferral, and worker cleanup behavior.

Do we have a high-confidence way to reproduce the issue?

The ratchet source, fixed budget, introduced environment name, and supplied before/after count establish the failure path; this review executed no target code.

Is this the best way to solve the issue?

The existing stdin transport is an appropriate owner for this private same-build value, and inspection found no remaining consumer requiring the removed environment variable.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 03af81024de8.

Provenance checked

  • Worker command-start anchor keeps the original intent (c7dd7b9: Keep a later-spawned lint worker on its supervising CLI’s validation-command clock.)
  • Report-before-disposal lifecycle keeps the original intent (7723e49: Preserve completed checks while bounding slow disposal of the isolated worker.)
  • Inspection runner and deferred output keeps the original intent (439940b: Keep the inspection graph lazy and maintain one findings collector; this patch retains that boundary and moves the unchanged output builder beside related output code.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 7723e49 adds src/commands/doctor-lint-options.ts:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7723e490386a; files: src/commands/doctor-lint-options.ts)
  • Dallin Romney: Raw commit c7dd7b9 adds src/flows/doctor-update-budget.ts:34 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c7dd7b94c8f3; files: src/flows/doctor-update-budget.ts)

PR surface

Source +23, Tests +7. Total +30 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 7 77 54 +23
Tests 2 14 7 +7
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 91 61 +30

Labels

Label changes:

  • add P2: A production-source ratchet failure blocks CI validation, while the patch intentionally preserves runtime behavior.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A production-source ratchet failure blocks CI validation, while the patch intentionally preserves runtime behavior.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 15, 2026, 3:32 AM ET / 07:32 UTC.

@steipete
steipete merged commit 9d5724c into main Oct 15, 2026
127 of 130 checks passed
@steipete
steipete deleted the steipete/env-var-budget-455 branch October 15, 2026 08:26
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

steipete added a commit that referenced this pull request Oct 15, 2026
Complete the consumer migrations from #172887, #172992, #172771 and #172989. Keep local schemas and callback types private and remove redundant barrel exports. Session sharing authority remains in its policy owner and is still enforced by production callers.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…hor handoff (openclaw#172887)

* fix(ci): hand the Doctor lint budget anchor to its worker over stdin

openclaw#170374 added OPENCLAW_UPDATE_REHEARSAL_COMMAND_STARTED_AT_MS so the
rehearsal `doctor lint --json` CLI could pass its validation-command
budget anchor to the lint worker it spawns. That pushed the distinct
OPENCLAW_* count to 455 against the owner-held budget of 454, failing
the env-var check inside the max-lines ratchet on every main push.

The CLI already sends the worker a JSON payload on stdin and both
processes are always the same build, so the anchor now travels there.
The worker parses a strict { options, commandStartedAtMs } envelope and
threads the value into its single resolveDoctorUpdateBudget call; every
other command keeps anchoring at its own performance.timeOrigin. Budget
semantics are unchanged.

The deferred-inspection result builder moves next to its sibling
createStateSnapshotFailureExecution in doctor-lint-output.ts so
doctor-lint-runner.ts stays within its line cap.

* test(doctor): narrow the captured worker stdin to a string
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
Complete the consumer migrations from openclaw#172887, openclaw#172992, openclaw#172771 and openclaw#172989. Keep local schemas and callback types private and remove redundant barrel exports. Session sharing authority remains in its policy owner and is still enforced by production callers.
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant