Skip to content

fix(warning,batch): stderr fallback on handler throw + align batch cap to concurrency limit - #170

Merged
dahai80 merged 1 commit into
mainfrom
audit-batchf-warning-batch-cap
Aug 28, 2026
Merged

dahai80 merged 1 commit into
mainfrom
audit-batchf-warning-batch-cap

Conversation

@dahai80

@dahai80 dahai80 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

What

Two surgical fixes from the 0827 audit (P0-P3 sweep, Batch F):

2.2.6 — warningHandler empty catch = warning black hole

src/utils/warningHandler.ts strips the Node default warning listener (process.removeAllListeners('warning')) for non-dev builds, then installs its own handler. That handler wrapped its body in try { ... } catch {} with an empty catch — if the handler itself threw (e.g. analytics logEvent threw), the warning was permanently lost with no fallback.

Fix: write to process.stderr as a last resort inside the catch, gated on CLAUDE_DEBUG or dev-build so the non-dev silent path is byte-identical to today. If stderr itself fails (closed fd), a final no-op catch is the true last resort — nothing more to degrade to.

1.4.7 — batch prompt cap exceeds hard spawn cap

src/skills/bundled/batch.ts told the model to decompose into 5–30 worktree agents, but the AgentTool hard concurrency cap (FUSION_MAX_CONCURRENT_SUBAGENTS, default 20 in subagentGuardrails.ts) rejects the 21st+ spawn. The model would spawn 30, hit the limit at 20, then retry / error-spin on the rejected ones.

Fix: bind MAX_AGENTS to DEFAULT_MAX_CONCURRENT_SUBAGENTS so the prompt upper bound and the hard cap share one source — no drift. The skill description string interpolates the same constant.

Why surgical

  • 2 files, +19/-4.
  • 2.2.6: new code lives entirely inside an existing catch that was previously empty; dev-gate preserves the silent non-dev path.
  • 1.4.7: one import + one constant rebinding; no control-flow change.
  • Both default-on (no feature flag, no env gate) — these were real production defects, not experimental paths.

Verification

  • bun run typecheck → 0 errors
  • bun test src/__tests__/ → 704 pass / 0 fail
  • bun run lint → 4601 errors (net-zero vs baseline; no new diagnostics in changed files)
  • bun run build:dev → 3755 modules, built ./fusion-code-dev

Audit context

0827 audit residual triage. These two were the only genuine surgical default-on findings among the 12 OPEN candidates. The rest were: closed by prior PRs (2.2.2 stream-resume via #163, 2.2.1 via Batch B), experimental-feature-gated-off (2.2.4 unattended retry, 1.2.x daemon cluster — DCE'd from shipped binary), deliberate design pushback (1.4.6 budget stub = v1 DEFERRED), or false positives verified against current code (2.1.6 abortController = fresh per turn via new QueryEngine/newAbortController; 1.3.4 normalize cache = reference-identity invalidation handles compact). Documented in memory per Rule 12.

Closes audit 2.2.6 + 1.4.7.

Co-Authored-By: Claude Fable 5 [email protected]

…p to concurrency limit

audit 2.2.6: warningHandler empty catch after removeAllListeners('warning')
made warnings a black hole when the handler itself threw (e.g. analytics
logEvent). Add stderr last-resort write in catch, dev/verbose-gated so the
non-dev silent path is unchanged.

audit 1.4.7: batch skill prompt told the model to spawn 5-30 agents while
the AgentTool hard concurrency cap (FUSION_MAX_CONCURRENT_SUBAGENTS) defaults
to 20 — the 21st+ spawn was rejected, causing model retry/error-spin. Bind
MAX_AGENTS to DEFAULT_MAX_CONCURRENT_SUBAGENTS so prompt and hard cap share
one source.

Gates: typecheck 0 / 704 tests / lint net-zero 4601 / build:dev 3755 modules.

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit 2ea6d15 into main Aug 28, 2026
1 check passed
@dahai80
dahai80 deleted the audit-batchf-warning-batch-cap branch August 28, 2026 05:27
dahai80 added a commit that referenced this pull request Aug 28, 2026
…sx (audit 1.1.1) (#172)

Third surgical extraction in the REPL.tsx god-module split (audit §1.1.1).
The three viewed-task derives (viewedTask / viewedTeammateTask / viewedAgentTask)
move from inline in REPL.tsx to a pure-function selector module:
src/tasks/viewedTaskSelector.ts. No React, no side effects — deps as args.

- getViewedTask: raw record lookup by id
- getViewedTeammateTask: teammate-only narrowed (in_progress_teammate)
- getViewedAgentTask: teammate OR local_agent — drives downstream boolean checks

REPL keeps the three const bindings as thin call wrappers (identical names,
identical downstream usage) — pure relocation + import wiring, byte-identical
behavior. Removed now-unused isInProcessTeammateTask guard import from REPL
(sole call site moved out); kept InProcessTeammateTaskState type (still used
at the panel helper) and isLocalAgentTask (two other call sites).

REPL.tsx 6741 → 6732 LOC (-9). viewedTaskSelector.ts +36 LOC (new).
Cohesion win: selector logic now reusable + unit-testable in isolation.

Gates: typecheck 0 / 714 tests pass (+10 new) / lint net-zero vs 4601 baseline
/ build:dev 3757 modules.

Follows PR #168 (leaf components, -285) + PR #171 (spinner derives, -70) in
the multi-session split. Task #170 stays in_progress — full 4-6wk split
continues in follow-up PRs.

Co-authored-by: Claude Fable 5 <[email protected]>
dahai80 added a commit that referenced this pull request Aug 29, 2026
….1 slice #34) (#207)

Slice #34 of #170 REPL god-module split. Extract the idle-return-hint
useEffect body (5 early-return guards + setTimeout with 5 stale-closure-bypass
positional args generating Ink <Text> JSX for the hint_v2 variant + logEvent +
cleanup) into maybeScheduleIdleReturnHint() in src/screens/idleReturnHint.tsx.

PURE-ROUTING SUB-BLOCK class (6th, like slice #29 maybeSendIdleNotification).
The function returns the setTimeout handle so the kept-thin useEffect cleanup
(clearTimeout + removeNotification + ref reset) still works byte-identically.
JSX-generating extract -> .tsx + Text import from ../ink.js.

5 setTimeout-arg + 2 guard dep + removeNotification pass via ctx object;
getFeatureValue_CACHED_MAY_BE_STALE/logEvent/AnalyticsMetadata/getGlobalConfig/
getTotalInputTokens/formatTokens imported directly. removeNotifications path
checked: formatTokens became import-only (sole user moved) -> removed from
REPL; getFeatureValue/getGlobalConfig/getTotalInputTokens/Text/logEvent/
AnalyticsMetadata still multi-use -> kept.

Gates: typecheck 0 errors / 921 pass / biome new-file-clean / build:dev pass.
REPL 5754 -> 5703 (-51 net: -59 body, +8 thin shell). Byte-identical behavior.

Co-authored-by: Claude Fable 5 <[email protected]>
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