Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR reduces temporary allocation in cron availability checks while preserving live agent eligibility checks. Example: Check worker-499 before a scheduled continuation in a 500-agent keyed roster.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this owner-directed optimization uses existing roster and admission owners, and no definite introduced correctness defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherCron availability combines the current agent roster, deletion facts, and database admission decisions to allow or reject scheduled work. flowchart TD
A[Scheduled occurrence] --> B[Cron service]
B --> C[Deletion facts]
B --> D[Live roster]
B --> E[Live admission decisions]
C --> F[Availability decision]
D --> F
E --> F
F --> G[Run or reject]
Technical reviewBest possible solution: Use direct live roster membership and a state-bound admission reader while preserving every existing revocation check. Do we have a high-confidence way to reproduce the issue? Current-main source shows each availability check constructing roster projections and normalized ID collections; runtime allocation magnitude was not independently reproduced during this read-only review. Is this the best way to solve the issue? The smallest complete fix belongs in the existing roster and admission owners, and the patch follows that boundary without adding a cache or competing decision store. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8c9fb121e8cd. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +42, Tests +57, Other +150. Total +249 across 9 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 23, 2026, 7:24 PM ET / 23:24 UTC. |
18ed0c2 to
b04847d
Compare
b04847d to
cd2a047
Compare
Read normalized membership at the roster owner, bind the admission state path once per cron service, and avoid temporary Result allocation in the string normalizer. Keep every live availability assertion and refusal/preparation check. Preserve raw roster and strict normalization contracts.
cd2a047 to
27d9c4e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27d9c4e539
ℹ️ 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".
| }; | ||
| if (owner === "server-cron") { | ||
| source = source.replace(/isAgentAvailable: \(agentId, facts\) =>([\s\S]*?),\n resolveSessionStorePath,/, | ||
| (_match, expression) => "isAgentAvailable: (agentId, facts) => {" + count("isAgentAvailable") + "return " + expression + "; },\n resolveSessionStorePath,"); |
There was a problem hiding this comment.
Preserve the expression when instrumenting cron availability
With --authority-counts, the captured expression begins with a newline because server-cron.ts puts the arrow body on the next line. Concatenating it after return triggers automatic semicolon insertion, so the instrumented callback always returns undefined without evaluating the admission-refusal or roster checks. Cron consumers such as run-queue-execution.ts check === false, so the benchmark bypasses these checks while still counting their invocation, invalidating its availability-work measurements. Trim the expression or enclose it in parentheses after return to preserve the original behavior.
Useful? React with 👍 / 👎.
|
Closing on cost versus value, not correctness. The owner result is real: availability-check allocation fell from 2.3–116 KB per check (10–500 agents, entries and list rosters) to the sampling floor. Revocation timing is unchanged. Three things keep it from landing as is:
The more important finding is the call count. An authenticated cron turn makes about 38,550 availability checks, one per authority assertion on the cron delivery fence. Each check is now cheap, but the count is where the cost comes from. Checking availability at the effect rather than on every assertion would be the simplification. That is an authority-design question, recorded for the Team perf session. The branch stays on the remote as the restart point. Evidence is in the lane report. |
Hold for performance: do not merge this candidate. Owner allocation falls sharply and all availability boundaries remain intact, but two valid serial whole-turn comparisons show adverse total GC and maximum pauses. A concurrent swapped-slot comparison was unavailable after the bounded 15-minute wait. Final-head CI completed red on four UI E2E jobs; their inherited status is unverified. The lane owner will not merge.
What Problem This Solves
Scheduled operator continuations repeatedly rebuild the full agent roster and resolve the state database path while checking cron owner availability. Each assertion asks about one agent, but temporary allocation grows with the configured fleet.
Change and User Impact
Both cron adapters use a roster-owned membership lookup. Canonical keyed entries use a direct own/enumerable lookup; legacy lists, raw ID normalization, malformed roster handling and absent-versus-empty roster behavior remain supported. A state-bound admission reader reads live refusal publications and the current preparation scope. Canonical agent IDs return unchanged before normalization, avoiding repeated lowercasing. The strict normalization API is unchanged.
Availability assertions remain at every existing boundary: agent removal, deletion blocking, refusal changes and expired preparation scopes still revoke work at the next check. No cache, retained roster, configuration, schema or migration changes.
Production delta is +41 lines: +34 for direct membership with raw-roster compatibility and shared roster selection, +7 for the fixed-state live reader, +4 for canonical normalization, +1 existing-barrel export, and −5 in cron adapters. Each addition replaces repeated work; no unrelated deletion offsets the count. This removes work rather than retaining prepared objects, but it is not a net-LOC deletion.
Measurement
Five samples per side for each of six cells, 20,000 checks per sample (100,000 per side/cell), alternating baseline/candidate process order. Original baseline source:
f8d9d253e1c4bf4433d32f9827d5f078fa377112; final owner implementation is unchanged by the latest-main rebase. Linux Node 26.12.1; 4 KiB inspector sampling includes collected objects. Timing and GC use a separate unsampled window. All answers matched. Candidate estimates are at the sampling floor, not proof of exactly zero allocation.The source-instrumented authenticated cron continuation also completed five turns per side, with one restored operator source, three tool completions and zero resets per turn. Mean availability calls were 38,558.6 → 38,549.4 (−0.024%). These synthetic workload counts are nested assertions, not production calls/turn or distinct permission decisions. No check was moved or removed.
Whole-isolate sampling uses a separate run without authority-count source instrumentation with the same synthetic flow and includes ordinary turn work. The first sequential five-turn comparison is recorded below. A reverse-order candidate→baseline repeat used fresh identical fixtures, the same six pinned owner sources and a 210-second post-launch capture boundary. Both comparisons are serial context, not concurrent swapped-slot pairs. No valid observation was discarded.
The first candidate maximum was 51.870 ms versus baseline 13.395 ms. The repeat maximum was 75.525 ms versus baseline 27.047 ms. Both exceed
max(50 ms, 2 × baseline maximum). The shared guard did not interrupt these runs. All valid observations are retained.The observer's total GC includes incremental events omitted from V8 collection-pause totals above. Use observer totals for the all-GC comparison:
Total GC is adverse in both serial sets (+37.28% and +44.73%). This is a hold recommendation, not a claim of a completed v4 concurrent gate or proven causal attribution. Promotion changes signs (−0.332 MB then +1.086 MB per turn), so it is inconclusive, not adverse, under v5.2. Event-loop p99 counts range from 189–366 per turn, below 1,000; GC tails also fall below the collection thresholds. No tail-percentile gate or production latency improvement is claimed.
The first outlier initially looked consistent with a startup memory-reducer phase shift, but the repeat also showed a large candidate major pause and the broader process trace did not establish equivalence. That explanation remains unproven. No further runs followed the repeat. The shared quiet-slot acquisition ended at 900 seconds without a grant; no paired workload started.
Reverse-order repeat: every turn and sample count
Owner timing-window GC totals and maximum pauses, every process pair
Reproduce the owner matrix with
node --expose-gc --import ./scripts/tsx.mjs scripts/perf/cron-availability-measure.ts --mode baselineon original source and--mode candidateon the changed source.--rounds 1supports external AB/BA ordering;--mode bothis only a callback diagnostic because it shares the current normalizer. The script documents trace-GC flags.scripts/perf/README.mddocuments the authenticated--operator-access-policy --cron-operator-turn --sessions 1 --reset-every-rounds 0flow; run--authority-countsseparately from--allocations, using fresh identical fixtures. Check timing did not require a whole-Gateway A/B. The attempted extra controlled comparison could not obtain a slot; the reverse-order serial repeat retained the GC concern.Proof
Focused local checks used Node 26.12.1 and one worker:
src/agents/agent-scope-config.test.ts: 35 passed; the no-projection regression fails on the original membership implementation.src/state/agent-database-admission.test.ts: 14 passed, including live replacement/clearing, fixed state scope and escaped preparation revocation.src/gateway/server-cron.test.ts: 85 passed.src/cron/store/run-receipt-store.test.ts,src/cron/session-reaper.test.ts,src/cron/service/store.test.ts,src/cron/service.manual-delivery.test.ts: 50 passed.packages/normalization-core/src/agent-id.test.ts: 19 passed.test/scripts/gateway-bench-profile.test.ts: 14 passed.test/scripts/eager-import-closure.test.ts,test/scripts/pr-wrapper-source-closure.test.ts: 22 passed; export-name collision guard passed.git diff --check: passed. PR CI owns broad proof; no Testbox/Crabbox lease used.src/gateway/server.chat-abort-settlement.test.ts,src/gateway/server-methods/progress-card-refresh.integration.test.ts,src/gateway/tools-invoke-authorization.test.ts: 38 tests passed under pinned Bun after the CI fixture repairs.test/scripts/type-suppression-inventory.test.ts: 4 passed. Its single added entry explicitly records the deliberately malformed JavaScript roster fixture; production types and the runtime assertion stay strict.CI repairs are preserved, with no reruns to chase green:
Final reviewed source head:
27d9c4e5399ef6e239bddcec045e3181db468f36. Final-head CI run 40043692738 completed with all changed Node test shards, core test typechecks, lint, and all three PostgreSQL conformance jobs passing. Four UI E2E jobs failed, leaving the aggregate CI gate red:chat-workspace-directory-race.e2e.test.ts: reports button timeout;sidebar-complete-roster.e2e.test.ts: four missing child-toggle cases.chat-file-links.e2e.test.ts: Files filter button timeout.session-management.operator-scopes.e2e.test.ts: SESSION_WRITE organization assertion, expected 1, received 0.chat-workspace-downloads.e2e.test.ts: large.txt button timeout.No UI files changed in this PR. Each failed job's log was fetched once. The latest scheduled-main result available during the investigation was 40040034138, source
2a7d1994c2a1477483661bc4af5cc90e4d76e8df, which predates subsequent UI changes and has no matching UI signatures. Inherited attribution remains unverified; these failures are not dismissed or rerun for green. The performance hold already prevents landing; final CI is not claimed green.Deployment Signal and Limits
During scheduled operator continuations, roster projection and repeated state-path resolution should disappear below availability checks; canonical normalization should no longer allocate there. Assertion frequency and next-check revocation should remain unchanged. Windows without these jobs need not show a measurable difference. The owner benchmark measures successful last-entry checks; raw compatibility and removal/refusal behavior are covered by tests. The synthetic turn uses a small fixture and does not establish production capacity.
Lead handoff: keep this candidate unmerged because of the repeated GC concern. The requested owner and authenticated continuation evidence is complete; the concurrent comparison was unavailable. Production growth (+41 lines), small whole-turn fixture, serial host exposure and unresolved GC causality are explicit limitations. Final-head CI is complete with the four UI E2E jobs above still red. Inherited attribution and GC causality remain open; no merge is authorized by this handoff.