Skip to content

Local-first 🧠 memory for Hermes Agent that lives in your Obsidian vault and remembers project context. Nightly 😴 dream passes turn repeat corrections into confirmed preferences with measurable confidence. Adapters ship for Claude Code, Codex, and OpenClaw, with an MCP server for anything else.

TypeScript

fix(ci): stop silent test hangs and Windows flakes (#301)

Serg Eroshea93a9292d1b0
diff --git a/.apb/playbooks/osb-pr-prepare/1.4.2/playbook.yaml b/.apb/playbooks/osb-pr-prepare/1.4.2/playbook.yaml
new file mode 100644
index 00000000..2448ee4e
--- /dev/null
+++ b/.apb/playbooks/osb-pr-prepare/1.4.2/playbook.yaml
@@ -0,0 +1,1007 @@
+schema: 2
+id: osb-pr-prepare
+name: Open Second Brain PR prepare
+description: 'Turn an Open Second Brain branch whose implementation is done into an open pull request that is ready for the operator to merge. Works for every change kind (feature, fix, refactor, chore, docs, deps). Steps: intake and commit of any uncommitted work, a local zg index, docs plus the version and CHANGELOG decision the change kind drives (CLAUDE.md), the CI QA gates run locally exactly as CI runs them and the code-ranker architecture gate against the main baseline (each with its fix loop), then the owner''s dev quality cycle (skill dev-quality-cycle: OpenCodeReview on the claude-code provider, a read-only Codex gpt-6-sol review, claude -p /security-review, the security-audit and test-audit skills, with its convergence rule), the QA and architecture gates again when the cycle changed anything, an owner approval gate before the push, then push, open the PR with a verified mermaid diagram, one blocking CI wait that ends only when every check has finished, and a bounded bot-review loop. It never merges and never arms auto-merge. The run input (instruction) carries the change kind, the intent, the related issues or cards and the base branch. The finish answer reports the PR URL, the CI state, a summary and whatever is left for a human.'
+version: 1.4.2
+params:
+- name: brief
+ type: text
+ label: Standing brief for PR preparation (override to change the rules)
+ options: null
+ default: 'Open Second Brain is a PUBLIC repository. Every artifact (code, commits, PR text, CHANGELOG, comments) is English, uses the full name "Open Second Brain" in prose, and carries no exclamation marks. Engineering bar: SOLID, KISS, DRY, repeated literals hoisted into named constants, no fallbacks that silently do nothing, no stubs, errors surface explicitly and by name. Commits: conventional (`type(scope): imperative summary`), one atomic unit each, formatted and linted before every commit (`bun run fmt`, `bun run lint`; the repo pre-commit hook enforces fmt, mirrors and lint), files staged by name - never `git add -A` or `git add .` (the ignored runtime state in .apb/runs/, .apb/tmp/ and .zvec-grep/ is never part of a change, and the committed .apb/ playbooks and profiles change only when the change is about them). When the commit_trailer parameter is non-empty, every commit message ends with a blank line and that trailer; when it is empty (the default), commit messages carry no trailer and no AI-authorship marker. Tests run with a throwaway HOME: `env HOME=$(mktemp -d) bun test <paths>`. Code search: zg (`zg --mode direct --refresh wait "<question>"` for semantic and hybrid hits, `--fts <Symbol>` for exact symbols, `zg --rg -n -w <symbol> src tests` for exhaustive callers); CodeGraph is not used. Never merge a PR, never arm auto-merge, never push to the base branch, never force-push over commits you did not write. Never touch the kanban board: card ids are context, not something to move or comment. Security details never go into public text; see the cycle_review node. Long commands: wait with ONE blocking call, never a polling loop; never end a reply while a command you started is still running, and never end with a progress report - the reply is the node result.'
+- name: kind
+ type: enum
+ label: Change kind (auto reads it from the instruction, then the branch prefix)
+ options:
+ - auto
+ - feature
+ - fix
+ - refactor
+ - chore
+ - docs
+ - deps
+ default: auto
+- name: base
+ type: text
+ label: Base branch (an explicit base in the instruction wins)
+ options: null
+ default: main
+- name: release
+ type: enum
+ label: Version bump (auto derives it from the kind, and for deps from the runtime dependencies; see the intake node)
+ options:
+ - auto
+ - major
+ - minor
+ - patch
+ - none
+ default: auto
+- name: commit_trailer
+ type: text
+ label: Trailer that ends every commit message (empty for none)
+ options: null
+ default: ''
+- name: pr_footer
+ type: text
+ label: Last line of every PR description (empty for none)
+ options: null
+ default: ''
+defaults:
+ profile:
+ name: osb-developer
+ scope: auto
+ max_retries: null
+ timeout_seconds: null
+ on_failure: blocked
+supervisor: null
+trigger:
+ when:
+ - prepare a pull request for an open-second-brain branch whose implementation is done
+ - review, gate, version and open a PR for an open-second-brain change of any kind
+ - get an open-second-brain branch to an open PR with green CI and addressed bot review
+ avoid_when:
+ - the change is not implemented yet (implement it first, or use osb-feature-release)
+ - merging or releasing (the operator merges; osb-release publishes)
+ examples:
+ - prepare the PR for this branch, it is a fix for issue 190
+ - open a docs PR from the current branch
+requires:
+ files:
+ - CLAUDE.md
+ commands:
+ - zg
+ - code-ranker
+ - bun
+ - git
+ - gh
+ - ocr
+ - codex
+ - claude
+goal:
+ statement: The branch is open as a pull request against the base, with green CI, bot review findings addressed or answered, the version and CHANGELOG handled as CLAUDE.md prescribes for the change kind, and nothing merged.
+ criteria:
+ - description: The PR is open, not merged, auto-merge is not armed, and its head is the reviewed and gated commit.
+ check:
+ type: manual
+ - description: The dev quality cycle (skill dev-quality-cycle) ran on the final reviewed head before the push and converged by its own stop rule, the local CI gates and the architecture gate with zero new violations against the main baseline ran, with the gates re-run after any cycle fix, and the owner approved the push; CI is green on the final head, or the finish answer names exactly what is left for a human.
+ check:
+ type: manual
+ - description: A release-bearing kind carries its version bump, CHANGELOG entry with link reference and a mermaid diagram that renders in the PR; a no-release kind carries none of the version changes.
+ check:
+ type: manual
+effects:
+- fs_read
+- fs_write
+- network
+- external
+nodes:
+- id: start
+ title: null
+ expected_duration: null
+ inputs: null
+ outputs: null
+ cache: null
+ type: start
+- id: intake
+ title: Resolve the PR context and commit pending work
+ expected_duration: 15m
+ inputs: null
+ outputs: null
+ cache: null
+ success_check: scripts/check-context.sh
+ type: agent_task
+ prompt: |
+ Standing brief: {{params.brief}}
+ Commit trailer: {{params.commit_trailer}}
+ Parameters: kind={{params.kind}}, base={{params.base}}, release={{params.release}}
+ Run input: {{run.instruction}}
+
+ You prepare the context every later node relies on. Work in the
+ repository root; do not change code beyond committing work that is
+ already there.
+
+ 1. Base: an explicit base branch in the run input wins, else the
+ base parameter. `git fetch origin <base>`.
+ 2. Kind (feature|fix|refactor|chore|docs|deps): the run input wins,
+ then a kind parameter other than auto, then the branch prefix
+ (feat/ fix/ refactor/ chore/ docs/ deps/ or chore/deps). If none
+ of these decides it, fail naming the ambiguity; do not guess.
+ 3. Release bump: a release parameter other than auto wins (the run
+ input may state one too). Otherwise the kind decides, following
+ CLAUDE.md ("for any feature/fix PR that ships a release") and the
+ history of main: feature -> minor, fix -> patch, refactor, chore,
+ docs -> none (no version bump and no CHANGELOG entry, like #175,
+ #142 and #121 on main). deps -> none when only development
+ dependencies or tooling move (package.json devDependencies,
+ bun.lock entries only they pull in, CI actions); deps -> patch
+ when the diff adds, removes or changes a RUNTIME dependency
+ (package.json dependencies, optionalDependencies or
+ peerDependencies, or pyproject.toml project dependencies),
+ because that changes what users install. Read the diff of those
+ files to decide; say which rule applied in the intent.
+ 4. Branch: if HEAD is on the base branch with uncommitted work, create
+ `<prefix>/<slug>` (prefix from the kind: feat, fix, refactor,
+ chore, docs, deps) and move the work there. A detached HEAD, or
+ a branch with no change against origin/<base> and nothing
+ uncommitted, is a failure with that reason.
+ 5. Uncommitted implementation work: read it, then commit it as
+ atomic conventional commits per the brief (formatted and linted,
+ staged by name). Leave the ignored runtime state (.apb/runs/, .zvec-grep/) alone. If a
+ change looks unrelated to the stated intent, leave it
+ uncommitted and fail, naming the files.
+ 6. Record the context for the script nodes:
+ `d=$(git rev-parse --path-format=absolute --git-path osb-pr-prepare); mkdir -p "$d"`
+ and write "$d/context.env" with exactly these shell assignments:
+ OSB_BASE=<base>, OSB_KIND=<kind>, OSB_RELEASE=<major|minor|patch|none>,
+ OSB_BRANCH=<branch>. Remove a stale "$d/pr.env" only if its PR is
+ not open for this branch (`gh pr view <n> --json state,headRefName`);
+ keep it when it is, so a re-run updates the same PR.
+
+ Write your verdict to $APB_STATUS_FILE with outputs
+ {kind, release, base, branch, intent (one paragraph, English),
+ issues (GitHub issue numbers the change addresses, or []),
+ cards (kanban card ids from the run input, or []),
+ commits_added (list of "sha title")}.
+ profile: null
+ max_retries: 1
+ timeout_seconds: null
+ workdir: null
+ isolation: null
+ connectors: []
+ interactive: false
+- id: zg_index
+ title: Ensure the local zg index
+ expected_duration: 5m
+ inputs: null
+ outputs: null
+ cache: null
+ type: script
+ script: scripts/zg-index.sh
+ runner: sh
+ timeout_seconds: 1800
+- id: docs_version
+ title: Docs, version and CHANGELOG per the change kind
+ expected_duration: 30m
+ inputs: null
+ outputs:
+ files: []
+ extract: node_output
+ cache: null
+ success_check: scripts/check-release.sh
+ type: agent_task
+ prompt: |
+ Standing brief: {{params.brief}}
+ Commit trailer: {{params.commit_trailer}}
+ Context: {{nodes.intake.output}}
+
+ Follow CLAUDE.md "Versioning" exactly. The release bump in the
+ context (OSB_RELEASE in <git-dir>/osb-pr-prepare/context.env) decides:
+
+ - major|minor|patch (the PR ships a release):
+ 1. CHANGELOG.md: a new `## [X.Y.Z] - <today, YYYY-MM-DD>` entry at
+ the top in the house voice (read the last three entries first:
+ an opening paragraph, then Fixed / Changed / Added with bold
+ lead-ins, capability-first, true to the diff). An existing
+ `## [Unreleased]` section becomes that entry rather than
+ staying above it. Add the link reference
+ `[X.Y.Z]: https://github.com/itechmeat/open-second-brain/compare/vPREV...vX.Y.Z`
+ above the previous one. Security fixes are worded neutrally.
+ 2. package.json `version` only, then `bun run scripts/sync-version.ts`
+ and `bun run scripts/sync-version.ts --check`. Never hand-edit
+ the mirrored manifests.
+ - none: no version bump, no CHANGELOG entry.
+
+ For every kind: README "What is new" or the docs the change affects
+ (install/, docs/, hooks/README.md, skills/) are updated when the
+ change alters what they describe; after changing skills/ or
+ hooks/hooks.json run `bun run sync-plugin-mirrors`. Commit as
+ `chore(release): vX.Y.Z` for the bump and `docs(<scope>): ...` for
+ docs.
+
+ Wrap ONLY the result in <node_output> and </node_output>: the bump
+ (PREV -> X.Y.Z, or none and why), the CHANGELOG heading, the docs
+ touched, commit shas.
+ profile: null
+ max_retries: 1
+ timeout_seconds: null
+ workdir: null
+ isolation: null
+ connectors: []
+ interactive: false
+- id: qa_gates
+ title: CI gates, run locally as CI runs them
+ expected_duration: 25m
+ inputs: null
+ outputs: null
+ cache: null
+ type: script
+ script: scripts/qa-gates.sh
+ runner: sh
+ timeout_seconds: 3600
+- id: qa_check
+ title: QA verdict
+ expected_duration: null
+ inputs: null
+ outputs: null
+ cache: null
+ type: condition
+ max_loops: 4
+- id: qa_fix
+ title: Fix the red QA gates
+ expected_duration: 40m
+ inputs: null
+ outputs:
+ files: []
+ extract: node_output
+ cache: null
+ type: agent_task
+ prompt: |
+ Standing brief: {{params.brief}}
+ Commit trailer: {{params.commit_trailer}}
+ Gate output: {{nodes.qa_gates.output}}
+
+ Make every red gate green in the branch. Full logs are in
+ <git-dir>/osb-pr-prepare/qa-logs/<step>.log. The usual repairs:
+ `bun run fmt`, `bun run lint:fix`, `bun run sync-plugin-mirrors`,
+ `bun run scripts/sync-version.ts`, and for the openclaw-bundle gate
+ a rebuild with the CI Bun: `PATH=~/.cache/osb-pr-prepare/bun-1.4.4/bun-linux-x64:$PATH
+ bun run build:openclaw` (never with the local newer Bun). Fix
+ failing tests at their cause, not by weakening assertions.
+
+ A failing test that is environment-only (it fails on the merge base
+ too, in this environment, for a reason outside the branch, such as
+ the WSL loopback timeout in capability-tier) is not fixed here:
+ prove it by running that one test on the merge base in a throwaway
+ worktree, then append its exact `bun test` name (as printed after
+ "(fail) ", without the timing) to
+ <git-dir>/osb-pr-prepare/known-test-failures.txt and name it with
+ the evidence in your output. Write the merge base you proved it on
+ (`git merge-base origin/<base> HEAD`) to
+ <git-dir>/osb-pr-prepare/known-test-failures.base: the QA gate
+ ignores the list once the merge base moves. Never add a test that
+ fails only on the branch.
+
+ Commit fixes per the brief. Wrap ONLY the result in <node_output>
+ and </node_output>: each red gate, the cause, the fix commit or the
+ known-failure evidence.
+ profile: null
+ max_retries: null
+ timeout_seconds: null
+ workdir: null
+ isolation: null
+ connectors: []
+ interactive: false
+- id: arch_gate
+ title: Architecture gate (code-ranker, regressions only)
+ expected_duration: 2m
+ inputs: null
+ outputs: null
+ cache: null
+ type: script
+ script: scripts/arch-gate.sh
+ runner: sh
+ timeout_seconds: 900
+- id: arch_check
+ title: Architecture verdict
+ expected_duration: null
+ inputs: null
+ outputs: null
+ cache: null
+ type: condition
+ max_loops: 3
+- id: arch_fix
+ title: Fix the architecture regressions
+ expected_duration: 30m
+ inputs: null
+ outputs:
+ files: []
+ extract: node_output
+ cache: null
+ type: agent_task
+ prompt: |
+ Standing brief: {{params.brief}}
+ Commit trailer: {{params.commit_trailer}}
+ Gate output: {{nodes.arch_gate.output}}
+
+ The code-ranker gate found violations this branch introduces against
+ the merge base (pre-existing debt is excluded by the baseline).
+ Before touching code, read `code-ranker docs ts <PRINCIPLE>` for each
+ finding (for example ADP for a cycle, HK for coupling), then apply
+ the smallest structural fix it prescribes, keeping behavior and
+ public APIs intact. Re-run the gate yourself with
+ `sh .apb/playbooks/osb-pr-prepare/$(cat .apb/playbooks/osb-pr-prepare/current)/scripts/arch-gate.sh`
+ (the script node runs it again after you).
+ Run the affected tests, commit as `refactor(<scope>): ...`.
+
+ Wrap ONLY the result in <node_output> and </node_output>: each
+ violation and the commit that removed it.
+ profile: null
+ max_retries: null
+ timeout_seconds: null
+ workdir: null
+ isolation: null
+ connectors: []
+ interactive: false
+- id: cycle_run
+ title: Dev quality cycle, steps 1-3 (OCR, Codex, /security-review)
+ expected_duration: 30m
+ inputs: null
+ outputs: null
+ cache: null
+ type: script
+ script: scripts/cycle-run.sh
+ runner: sh
+ timeout_seconds: 5400
+- id: cycle_review
+ title: 'Dev quality cycle: verify, audits, fixes, convergence'
+ expected_duration: 75m
+ inputs: null
+ outputs:
+ files: []
+ extract: node_output
+ cache: null
+ success_check:
+ marker: 'CYCLE: done'
+ type: agent_task
+ prompt: |
+ Standing brief: {{params.brief}}
+ Commit trailer: {{params.commit_trailer}}
+ Context: {{nodes.intake.output}}
+ Runner output (steps 1-3): {{nodes.cycle_run.output}}
+
+ Load the dev-quality-cycle skill by name and follow it: SKILL.md,
+ references/steps.md, references/convergence.md and
+ templates/report.md. The skill is the rule; this prompt only adds
+ what is specific to Open Second Brain and to this playbook.
+
+ 1. Steps 1-3 already ran through the skill runner (the cycle_run
+ node; its last line is `CYCLE-RUN: <status> exit=<n>
+ summary=<path>`). Read summary.txt and the ocr, codex and
+ security-review outputs in that run folder. `nothing-new` (runner
+ exit 4) means the cycle already reviewed HEAD on an earlier
+ pass: skip to the output below with `CYCLE: done (0 rounds, 0
+ real, 0 fixed, 0 declined)` and that reason. `failed`: a step
+ did not really review; rerun only that step with the skill
+ runner once (`--steps <step>`, same range) and report it; never
+ report a step that did not review as clean. `resumable`: a
+ usage or session limit; run the printed resume command once
+ after the reset when it is within 30 minutes, else fail this
+ node naming the reset time and the resume command.
+ 2. Step 4: the security-audit skill in guidance mode, focused on
+ the cycle range and the trust boundaries it touches (read
+ callers with `zg --rg -n -w <symbol> src tests plugins
+ scripts hooks skills` where a changed function is reached from
+ an MCP tool, CLI verb, hook, HTTP transport, file import or
+ config read). Never the full audit workflow.
+ 3. Step 5: the test-audit skill on every test file the range adds
+ or changes, with the Open Second Brain commands from the brief
+ instead of the OpenClaw tooling it names. Two project rules on
+ top: a test that compares output embedding a timestamp or a
+ generated id is normalised or rewritten; a regression test
+ (kind fix, or any test that pins a bug) is proved to fail on
+ the merge base for the intended reason (throwaway `git worktree
+ add --detach "$(mktemp -d)" <merge-base>`, copy in only that
+ test, `env HOME=$(mktemp -d) bun test <file>`, record the
+ failure line, remove the worktree).
+ 4. Step 6 is the QA and architecture gate nodes that ran before
+ you and the final_gates node after you; run the targeted tests
+ of anything you fix (`env HOME=$(mktemp -d) bun test <paths>`).
+ 5. Findings: verify each against the code, classify and decide as
+ references/convergence.md says (real only with a concrete
+ failing scenario; decline the rest in one line). Fix the real
+ ones in dedicated conventional commits per the brief, smallest
+ diff; zg finds the callers and sibling implementations that
+ must change alike (Python plugin mirror, Codex mirrors, docs).
+ New rounds only as the convergence table says, scoped to the
+ fix commits, through the skill runner (for example
+ `<skill>/scripts/cycle.sh --range <before-fix>..HEAD --steps
+ ocr`); stop by its stop rule. Long runner calls: one blocking
+ wait, never a polling loop.
+ 6. Do not push and do not touch the version or CHANGELOG: the QA
+ and architecture gates run again after you when you committed.
+ 7. Last, record the head the cycle reviewed: write the line
+ `<branch> <git rev-parse HEAD>` to
+ <git-dir>/osb-pr-prepare/cycle-reviewed (the cycle_run node of a
+ later pass reviews only what came after it).
+
+ Security dispositions (the repository is PUBLIC):
+ - A confirmed issue the branch introduces (never released): fix it in
+ the branch with a regression test, as an ordinary conventional commit.
+ - A confirmed issue in code already released on the base that the
+ diff touches: fix it in THIS public PR, worded neutrally, AND open a
+ private DRAFT security advisory that carries the details. Both,
+ always: the fix does not wait for the advisory, and the advisory is
+ not skipped because the fix ships.
+ - A confirmed issue in released code the diff does not touch: do not
+ fix it here; open a private draft advisory only.
+ Private advisory, created as a draft and never published by you:
+ `gh api repos/itechmeat/open-second-brain/security-advisories -X POST
+ -f summary=<short> -f description=<details and fix> -f severity=<low|medium|high|critical>`
+ plus the required vulnerabilities field per the GitHub REST docs.
+ The advisory is the ONLY place the exploit details, the attack
+ narrative and the severity are written. Public artifacts (commit
+ messages, code comments, test names, the PR title and body, PR
+ comments and replies, CHANGELOG, docs, release notes) describe a
+ security fix only in neutral behavioral terms ("validate X before Y",
+ "refuse paths outside the vault"), with no exploit, no attack
+ narrative, no severity, no advisory id and no words like vulnerability
+ or exploit.
+
+ Wrap ONLY the result in <node_output> and </node_output>. Required
+ first line: `CYCLE: done (<rounds> rounds, <real> real, <fixed> fixed,
+ <declined> declined)`. Then the report filled from the skill's
+ templates/report.md (every step, fixed with sha, declined with the
+ reason, not-this-change items, the next-round decision with its
+ reason, skill update). Security findings appear only as counts and
+ advisory references; this output stays in the run. A runner or
+ skill that cannot be loaded is a node failure naming the error,
+ never a review without the cycle.
+ profile:
+ name: osb-reviewer
+ scope: auto
+ max_retries: 1
+ timeout_seconds: null
+ workdir: null
+ isolation: null
+ connectors: []
+ interactive: false
+- id: final_gates
+ title: QA and architecture gates again after the review
+ expected_duration: 27m
+ inputs: null
+ outputs: null
+ cache: null
+ type: script
+ script: scripts/final-gates.sh
+ runner: sh
+ timeout_seconds: 4500
+- id: final_check
+ title: Final gate verdict
+ expected_duration: null
+ inputs: null
+ outputs: null
+ cache: null
+ type: condition
+ max_loops: 3
+- id: final_fix
+ title: Fix the red final gates
+ expected_duration: 40m
+ inputs: null
+ outputs:
+ files: []
+ extract: node_output
+ cache: null
+ type: agent_task
+ prompt: |
+ Standing brief: {{params.brief}}
+ Commit trailer: {{params.commit_trailer}}
+ Gate output: {{nodes.final_gates.output}}
+ Cycle report: {{nodes.cycle_review.output}}
+
+ The QA or the architecture gate turned red after the dev quality cycle
+ pass. Make every red gate green in the branch without undoing a
+ cycle fix: for QA, the repairs and the known-failure rule
+ of the qa_fix node (full logs in <git-dir>/osb-pr-prepare/qa-logs/);
+ for architecture, the code-ranker rule of the arch_fix node (read
+ `code-ranker docs ts <PRINCIPLE>` first, smallest structural fix).
+ Commit per the brief. A code fix (not a pure formatting or mirror
+ sync) goes through the convergence table of the dev-quality-cycle
+ skill before you finish: usually OCR on your fix commits only
+ (`<skill>/scripts/cycle.sh --range <before-fix>..HEAD --steps ocr`);
+ verify its findings like the cycle_review node does. Then write
+ `<branch> <git rev-parse HEAD>` to
+ <git-dir>/osb-pr-prepare/cycle-reviewed. The script node runs both
+ gates again after you.
+
+ Wrap ONLY the result in <node_output> and </node_output>: each red
+ gate, the cause, the fix commit, and the cycle pass on the fix
+ commits (range, findings, decision).
+ profile: null
+ max_retries: null
+ timeout_seconds: null
+ workdir: null
+ isolation: null
+ connectors: []
+ interactive: false
+- id: push_approval
+ title: Owner approval of the push and the PR
+ expected_duration: null
+ inputs: null
+ outputs: null
+ cache: null
+ type: human_review
+ options:
+ - approve
+ - reject
+ prompt: 'The dev quality cycle is closed and the final gates are green. Read the cycle report (cycle_review output) and the final gate verdict, then approve to push the branch and open or update the PR, or reject to stop the run before anything leaves the machine. An approval covers this branch: the CI-fix pushes of the same PR that follow it (ci_fix) need no new approval; CodeRabbit fixes are pushed under the host''s own exception once their cycle is clean.'
+- id: push_pr
+ title: Push and open (or update) the PR
+ expected_duration: 25m
+ inputs: null
+ outputs:
+ files: []
+ extract: node_output
+ cache: null
+ success_check: scripts/check-pr.sh
+ type: agent_task
+ prompt: |
+ Standing brief: {{params.brief}}
+ PR footer (the exact last line of the description): {{params.pr_footer}}
+ Context: {{nodes.intake.output}}
+ Cycle report: {{nodes.cycle_review.output}}
+ Push approval note: {{nodes.push_approval.review_note}}
+ Docs and version: {{nodes.docs_version.output}}
+
+ 1. Push. If the diff against origin/<base> touches .github/workflows/,
+ push over SSH so no token scope can refuse it:
+ `git push [email protected]:itechmeat/open-second-brain.git HEAD:refs/heads/<branch>`
+ then `git branch --set-upstream-to=origin/<branch>` after a
+ `git fetch origin <branch>`; otherwise `git push -u origin <branch>`.
+ Never push to the base, never force-push commits you did not write.
+ 2. PR text, in the voice of the recent PRs (`gh pr view 193` and
+ `gh pr view 191` are the reference): title as a conventional
+ summary, with ` (vX.Y.Z)` appended when the PR ships a release
+ (`feat: <capability tagline> (v1.58.0)`, `fix(<scope>): ... (v1.57.2)`).
+ Body: Summary (capability-first), a mermaid diagram of the
+ process-level benefit (required when the PR ships a release,
+ optional otherwise), What changed, Verification (the gates that
+ ran, with counts; when the diff against origin/<base> exceeds
+ 100 files, one line naming the bot review as skipped, since
+ CodeRabbit skips a change set over its 100-file limit), and
+ `Closes #N` / `Refs #N` for the GitHub issues in the context.
+ Kanban card ids stay out of the public text. Security fixes in
+ neutral terms only. When the PR footer above is non-empty, the
+ description ends with it verbatim; when it is empty, the
+ description carries no footer and no AI-authorship marker.
+ 3. Mermaid: try a local parse first when it runs here
+ (`bunx -p @mermaid-js/mermaid-cli mmdc -i <file>.mmd -o <file>.svg`;
+ agent-browser's Chrome can serve as PUPPETEER_EXECUTABLE_PATH).
+ The check that counts is the PR page: once the PR exists, open it
+ with agent-browser and confirm the diagram rendered as a diagram
+ (no "Unable to render rich display" box). Fix and
+ `gh pr edit --body-file` until it does.
+ 4. Open or update: if an open PR for this branch exists
+ (`gh pr view --json number,state`), update its title and body;
+ else `gh pr create --base <base> --head <branch> --title ...
+ --body-file ...`. Never `gh pr merge`, never `--auto`.
+ 5. Record `OSB_PR_NUMBER=<n>` and `OSB_PR_URL=<url>` in
+ <git-dir>/osb-pr-prepare/pr.env.
+
+ Wrap ONLY the result in <node_output> and </node_output>. Required
+ first line: `PR: #<number> <url>`. Then the pushed head sha and the
+ mermaid evidence (local render, and what the PR page showed).
+ profile: null
+ max_retries: 2
+ timeout_seconds: null
+ workdir: null
+ isolation: null
+ connectors: []
+ interactive: false
+- id: ci_wait
+ title: Wait for CI (one blocking watch)
+ expected_duration: 35m
+ inputs: null
+ outputs: null
+ cache: null
+ type: script
+ script: scripts/ci-wait.sh
+ runner: sh
+ timeout_seconds: 6600
+- id: ci_wait_final
+ title: Wait for CI after the budget-capped bot review pass
+ expected_duration: 35m
+ inputs: null
+ outputs: null
+ cache: null
+ type: script
+ script: scripts/ci-wait.sh
+ runner: sh
+ timeout_seconds: 6600
+- id: ci_check
+ title: CI verdict
+ expected_duration: null
+ inputs: null
+ outputs: null
+ cache: null
+ type: condition
+ max_loops: 4
+- id: ci_fix
+ title: Fix the red CI checks and push
+ expected_duration: 40m
+ inputs: null
+ outputs:
+ files: []
+ extract: node_output
+ cache: null
+ success_check: scripts/check-pr.sh
+ type: agent_task
+ prompt: |
+ Standing brief: {{params.brief}}
+ Commit trailer: {{params.commit_trailer}}
+ CI output: {{nodes.ci_wait.output}}
+
+ Diagnose each failed check from the job logs above (`gh run view
+ --job <id> --log` for more). Reproduce it locally when the platform
+ allows (the windows job cannot run here: reason from the log and
+ the Windows notes in install/windows.md and CLAUDE.md). A flaky
+ timing failure unrelated to the branch is re-run once with
+ `gh run rerun <run-id> --failed` instead of a code change, and
+ named as such; a rerun is only for failures outside the
+ repository's code. An HTTP 429 or 5xx from an external service
+ inside a repository script is fixed at the cause: a bounded retry
+ in that script (a fixed attempt count and backoff, then the error
+ by name), not a rerun. Otherwise fix at the cause, run the
+ affected local gates and commit per the brief. A code fix (not a
+ pure formatting or mirror sync) goes through the convergence table
+ of the dev-quality-cycle skill before the push: usually OCR on your
+ fix commits only (`<skill>/scripts/cycle.sh --range
+ <before-fix>..HEAD --steps ocr`); verify its findings like the
+ cycle_review node does, then write `<branch> <git rev-parse HEAD>`
+ to <git-dir>/osb-pr-prepare/cycle-reviewed. Push only when that is
+ clean, the same way push_pr did (SSH when .github/workflows/
+ changed). The bot_review node after you handles the bot's findings
+ on the new head. Do not edit the PR text unless the fix changes
+ what it claims.
+
+ Wrap ONLY the result in <node_output> and </node_output>: each failed
+ check, the cause, the fix commit or the rerun, and the cycle pass on
+ the fix commits (range, findings, decision).
+ profile: null
+ max_retries: null
+ timeout_seconds: null
+ workdir: null
+ isolation: null
+ connectors: []
+ interactive: false
+- id: bot_review
+ title: Handle the bot review (CodeRabbit)
+ expected_duration: 30m
+ inputs: null
+ outputs: null
+ cache: null
+ success_check: scripts/check-pr.sh
+ type: agent_task
+ prompt: |-
+ Standing brief: {{params.brief}}
+ Commit trailer: {{params.commit_trailer}}
+ PR: read the number from <git-dir>/osb-pr-prepare/pr.env.
+
+ This node starts IMMEDIATELY after the push, while CI is still running.
+ Do not wait for the checks to conclude and do not watch them; the
+ ci_wait node after you waits for the checks. Start the review work now.
+
+ First wait for CodeRabbit's review OF THE CURRENT HEAD to be POSTED:
+ it usually arrives minutes after the push, long before the checks
+ end. Take the head with `git rev-parse HEAD` and poll
+ `gh api --paginate --slurp repos/<owner>/<repo>/pulls/<n>/reviews` in one blocking loop
+ (sleep 60 between calls, at most 10 minutes) until a CodeRabbit
+ review's `commit_id` equals that head; an earlier review does not
+ count. Then read what it said (`gh api --paginate --slurp .../pulls/<n>/comments` and `gh pr
+ view <n> --comments`). If no review of the head appears in that
+ window, say so in the reply and continue. Handle only comments you have not already
+ answered in an earlier pass of this node.
+
+ The operator may hand external review documents to the orchestrator
+ mid-wave (paths under .reviews/ or pasted text). When this task's
+ response carries them, treat every finding in them exactly like a
+ CodeRabbit finding: verify against the current code, then fix or
+ answer. Such findings are worked on immediately, never held back for
+ CI.
+
+ - Skipped (for example "files exceed the limit"): post one PR
+ comment saying which internal review compensated (the
+ dev quality cycle of this run: OpenCodeReview, Codex review,
+ /security-review, security-audit and test-audit), in neutral terms.
+ - Each finding: verify it against the current code with the
+ receiving-code-review discipline. Valid: fix with the smallest
+ diff. Not valid or no longer applicable: reply on the thread with
+ a one-sentence technical reason. Valid fixes get a reply naming
+ the commit.
+ - Fixes go through the convergence table of the dev-quality-cycle
+ skill (references/convergence.md, section 5): usually OCR on the
+ fix commits only (`<skill>/scripts/cycle.sh --range
+ <before-fix>..HEAD --steps ocr`), never a full cycle restart by
+ itself. A code fix also passes the QA and architecture gates on
+ the fix head: `sh .apb/playbooks/osb-pr-prepare/$(cat
+ .apb/playbooks/osb-pr-prepare/current)/scripts/final-gates.sh`. Push only when both are
+ clean.
+ - Commit fixes per the brief (for example `fix: address CodeRabbit
+ review feedback`) and push the same way push_pr did. A push here
+ restarts CI; that is expected, because the ci_wait node after you
+ waits for the new run.
+ One pass per call; do not wait for a second bot pass.
+
+ Write your verdict to $APB_STATUS_FILE with outputs
+ {pushed: "yes" if you pushed commits, else "no", findings: <count>,
+ fixed: [shas], answered: <count>, skipped_reason: <text or "">}.
+ profile: null
+ max_retries: 1
+ timeout_seconds: null
+ workdir: null
+ isolation: null
+ connectors: []
+ interactive: false
+- id: ready
+ title: null
+ expected_duration: 3m
+ inputs: null
+ outputs: null
+ cache: null
+ type: finish
+ outcome: success
+ prompt: |
+ Compose the final answer for the operator from the run context:
+ first line `PR: #<number> <url>`; then CI state as
+ `gh pr checks <n>` reports it NOW (run it once; say green, or name
+ what is red or pending); the kind, the version bump or none; a
+ five-line summary of what the PR ships; what the dev quality cycle did (per step:
+ findings, fixed, declined; security only "clean" or the count of
+ fixed items and advisory drafts, never details; rounds and the
+ convergence decision), the architecture gate and the final gates did; and a "Left for a human" list: gates that ended on their
+ loop budget, known environment-only test failures, bot findings
+ answered but not fixed, cycle findings declined or deferred, advisory drafts to publish, the merge
+ itself. Plain text, English.
+ profile: null
+- id: blocked
+ title: null
+ expected_duration: 3m
+ inputs: null
+ outputs: null
+ cache: null
+ type: finish
+ outcome: failure
+ prompt: |
+ The PR preparation stopped before a PR with green CI existed.
+ Compose the answer from the run context: the node that stopped it
+ and its last output (the reason, verbatim where short), whether a
+ PR exists (`PR: #<n> <url>` or `PR: none`), what was already
+ committed and pushed, and the exact next step a human should take.
+ Plain text, English. No security details.
+ profile: null
+edges:
+- from: start
+ to: intake
+ condition: null
+ fallback: false
+ join: null
+- from: intake
+ to: zg_index
+ condition: null
+ fallback: false
+ join: null
+- from: zg_index
+ to: docs_version
+ condition:
+ type: node_status
+ node: zg_index
+ equals: success
+ fallback: false
+ join: null
+- from: zg_index
+ to: docs_version
+ condition:
+ type: node_status
+ node: zg_index
+ equals: failure
+ fallback: false
+ join: null
+- from: docs_version
+ to: qa_gates
+ condition: null
+ fallback: false
+ join: null
+- from: qa_gates
+ to: qa_check
+ condition: null
+ fallback: false
+ join: null
+- from: qa_check
+ to: arch_gate
+ condition:
+ type: node_status
+ node: qa_gates
+ equals: success
+ fallback: false
+ join: null
+- from: qa_check
+ to: qa_fix
+ condition:
+ type: output_match
+ node: qa_gates
+ pattern: 'QA-GATE: red'
+ fallback: false
+ join: null
+- from: qa_check
+ to: blocked
+ condition: null
+ fallback: true
+ join: null
+- from: qa_fix
+ to: qa_gates
+ condition: null
+ fallback: false
+ join: null
+- from: arch_gate
+ to: arch_check
+ condition: null
+ fallback: false
+ join: null
+- from: arch_check
+ to: cycle_run
+ condition:
+ type: node_status
+ node: arch_gate
+ equals: success
+ fallback: false
+ join: null
+- from: arch_check
+ to: arch_fix
+ condition:
+ type: output_match
+ node: arch_gate
+ pattern: 'ARCH-GATE: violations'
+ fallback: false
+ join: null
+- from: arch_check
+ to: blocked
+ condition: null
+ fallback: true
+ join: null
+- from: arch_fix
+ to: arch_gate
+ condition: null
+ fallback: false
+ join: null
+- from: final_gates
+ to: final_check
+ condition: null
+ fallback: false
+ join: null
+- from: final_check
+ to: push_approval
+ condition:
+ type: node_status
+ node: final_gates
+ equals: success
+ fallback: false
+ join: null
+- from: final_check
+ to: final_fix
+ condition:
+ type: output_match
+ node: final_gates
+ pattern: 'FINAL-GATES: red'
+ fallback: false
+ join: null
+- from: final_check
+ to: blocked
+ condition: null
+ fallback: true
+ join: null
+- from: final_fix
+ to: final_gates
+ condition: null
+ fallback: false
+ join: null
+- from: push_pr
+ to: bot_review
+ condition: null
+ fallback: false
+ join: null
+- from: ci_wait
+ to: ci_check
+ condition: null
+ fallback: false
+ join: null
+- from: ci_check
+ to: ci_fix
+ condition:
+ type: output_match
+ node: ci_wait
+ pattern: 'CI-GATE: red'
+ fallback: false
+ join: null
+- from: ci_check
+ to: blocked
+ condition:
+ type: node_status
+ node: ci_wait
+ equals: failure
+ fallback: false
+ join: null
+- from: ci_check
+ to: bot_review
+ condition:
+ type: output_field
+ node: bot_review
+ field: pushed
+ equals: 'yes'
+ fallback: false
+ join: null
+- from: ci_check
+ to: ready
+ condition:
+ type: output_field
+ node: bot_review
+ field: pushed
+ equals: 'no'
+ fallback: false
+ join: null
+- from: ci_check
+ to: blocked
+ condition: null
+ fallback: true
+ join: null
+- from: ci_fix
+ to: bot_review
+ condition: null
+ fallback: false
+ join: null
+- from: bot_review
+ to: ci_wait
+ condition: null
+ fallback: false
+ join: null
+ max_traversals: 2
+- from: bot_review
+ to: ci_wait_final
+ condition: null
+ fallback: true
+ join: null
+- from: ci_wait_final
+ to: ready
+ condition:
+ type: node_status
+ node: ci_wait_final
+ equals: success
+ fallback: false
+ join: null
+- from: ci_wait_final
+ to: blocked
+ condition: null
+ fallback: true
+ join: null
+- from: cycle_run
+ to: cycle_review
+ condition: null
+ fallback: false
+ join: null
+- from: cycle_review
+ to: final_gates
+ condition: null
+ fallback: false
+ join: null
+- from: push_approval
+ to: push_pr
+ condition:
+ type: review_status
+ equals: approve
+ fallback: false
+ join: null
+- from: push_approval
+ to: blocked
+ condition:
+ type: review_status
+ equals: reject
+ fallback: false
+ join: null
diff --git a/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/arch-gate.sh b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/arch-gate.sh
new file mode 100755
index 00000000..772c5a8a
--- /dev/null
+++ b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/arch-gate.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Architecture gate: code-ranker in baseline mode. The merge base with
+# origin/<base> is analyzed as the baseline and the committed HEAD as the
+# candidate (both from `git archive`, so untracked files and local tool
+# directories never enter the graph); only violations the branch introduces
+# fail the gate. Pre-existing debt on the base is not this PR's to fix.
+#
+# Exit 0: no new violation. Exit 1: new violations (the output starts with
+# `ARCH-GATE: violations`, followed by code-ranker's fix prompt). Exit 2: the
+# tool itself failed (`ERROR:`), which no code change in the branch can fix.
+[ -n "${BASH_VERSION:-}" ] || exec bash "$0" "$@"
+set -euo pipefail
+. "$(dirname "$0")/lib.sh"
+
+root=$(repo_root)
+cd "$root"
+load_ctx
+command -v code-ranker >/dev/null 2>&1 || die "code-ranker is not on PATH"
+
+mb=$(git merge-base "origin/$OSB_BASE" HEAD) || die "no merge base with origin/$OSB_BASE"
+work=$(mktemp -d "${TMPDIR:-/tmp}/osb-arch-gate.XXXXXX")
+trap 'rm -rf "$work"' EXIT
+mkdir -p "$work/base" "$work/head"
+git archive "$mb" | tar -x -C "$work/base"
+git archive HEAD | tar -x -C "$work/head"
+
+# Explicit plugins so base and head are analyzed with the same languages.
+plugins=(--plugins ts --plugins python --plugins md)
+cd "$work" # code-ranker writes its default HTML viewer under the cwd
+code-ranker report base "${plugins[@]}" --output.mode quiet \
+ --output.json.path "$work/base.json" --output.html.path "$work/base.html" >/dev/null 2>"$work/report.err" ||
+ die "code-ranker report on the merge base failed: $(cat "$work/report.err")"
+
+set +e
+code-ranker check head "${plugins[@]}" --baseline "$work/base.json" \
+ --output-format prompt --output.mode summary >"$work/check.out" 2>&1
+rc=$?
+set -e
+
+if [ "$rc" -eq 0 ]; then
+ cat "$work/check.out"
+ # final-gates.sh skips its re-run only while HEAD is still this commit.
+ git -C "$root" rev-parse HEAD >"$CTX_DIR/arch-green-head"
+ echo "ARCH-GATE: pass (no new violation against $mb)"
+ exit 0
+fi
+if grep -q 'new violation(s) vs baseline' "$work/check.out"; then
+ echo "ARCH-GATE: violations (new against merge base $mb)"
+ sed "s#$work/##g" "$work/check.out"
+ exit 1
+fi
+cat "$work/check.out"
+die "code-ranker check failed without a violation verdict (exit $rc)"
diff --git a/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/check-context.sh b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/check-context.sh
new file mode 100755
index 00000000..31d5df6d
--- /dev/null
+++ b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/check-context.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# success_check of `intake`: the recorded PR context is complete and true.
+# apb runs every script through `sh`; re-exec under bash for pipefail.
+[ -n "${BASH_VERSION:-}" ] || exec bash "$0" "$@"
+set -euo pipefail
+. "$(dirname "$0")/lib.sh"
+
+cd "$(repo_root)"
+load_ctx
+
+case " $OSB_KINDS " in *" $OSB_KIND "*) ;; *) die "OSB_KIND=$OSB_KIND is not one of: $OSB_KINDS" ;; esac
+case " $OSB_RELEASES " in *" $OSB_RELEASE "*) ;; *) die "OSB_RELEASE=$OSB_RELEASE is not one of: $OSB_RELEASES" ;; esac
+
+branch=$(git symbolic-ref --quiet --short HEAD) || die "HEAD is detached; the PR needs a branch"
+[ "$branch" = "$OSB_BRANCH" ] || die "checked-out branch $branch differs from OSB_BRANCH=$OSB_BRANCH"
+[ "$branch" != "$OSB_BASE" ] || die "the PR branch is the base branch $OSB_BASE"
+git rev-parse --verify --quiet "origin/$OSB_BASE" >/dev/null || die "origin/$OSB_BASE does not exist; fetch it"
+mb=$(git merge-base "origin/$OSB_BASE" HEAD) || die "no merge base between origin/$OSB_BASE and HEAD"
+git diff --quiet "$mb" HEAD && die "the branch carries no change against origin/$OSB_BASE"
+git diff --quiet || die "tracked files have unstaged changes; the intake commits the implementation first"
+git diff --cached --quiet || die "the index holds staged, uncommitted changes"
+untracked=$(git ls-files --others --exclude-standard)
+[ -z "$untracked" ] ||
+ die "untracked files are not in HEAD (commit or ignore them): $(printf '%s' "$untracked" | tr '\n' ' ')"
+
+echo "context ok: kind=$OSB_KIND release=$OSB_RELEASE base=$OSB_BASE branch=$OSB_BRANCH merge-base=$mb"
+echo "commits: $(git rev-list --count "$mb"..HEAD), files: $(git diff --name-only "$mb" HEAD | wc -l)"
diff --git a/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/check-pr.sh b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/check-pr.sh
new file mode 100755
index 00000000..2450e8be
--- /dev/null
+++ b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/check-pr.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# success_check of `push_pr` (and of the fix nodes that push): the PR recorded
+# in pr.env is open, not merged, targets the base branch, and its head is
+# exactly the local HEAD, which the remote branch also carries.
+[ -n "${BASH_VERSION:-}" ] || exec bash "$0" "$@"
+set -euo pipefail
+. "$(dirname "$0")/lib.sh"
+
+cd "$(repo_root)"
+load_ctx
+load_pr
+
+head=$(git rev-parse HEAD)
+git diff --quiet && git diff --cached --quiet || die "uncommitted tracked changes: commit and push them"
+remote=$(git ls-remote origin "refs/heads/$OSB_BRANCH" | cut -f1)
+[ "$remote" = "$head" ] || die "origin/$OSB_BRANCH is '${remote:-absent}', local HEAD is $head: push"
+
+info=$(gh pr view "$OSB_PR_NUMBER" --json state,headRefOid,baseRefName,headRefName,url \
+ -q '[.state,.headRefOid,.baseRefName,.headRefName,.url]|@tsv') || die "gh pr view $OSB_PR_NUMBER failed"
+IFS=$'\t' read -r state pr_head pr_base pr_branch url <<<"$info"
+[ "$state" = OPEN ] || die "PR #$OSB_PR_NUMBER is $state, expected OPEN (this playbook never merges)"
+[ "$pr_base" = "$OSB_BASE" ] || die "PR #$OSB_PR_NUMBER targets $pr_base, expected $OSB_BASE"
+[ "$pr_branch" = "$OSB_BRANCH" ] || die "PR #$OSB_PR_NUMBER is from $pr_branch, expected $OSB_BRANCH"
+[ "$pr_head" = "$head" ] || die "PR #$OSB_PR_NUMBER head is $pr_head, local HEAD is $head"
+auto=$(gh pr view "$OSB_PR_NUMBER" --json autoMergeRequest -q '.autoMergeRequest != null')
+[ "$auto" = false ] || die "PR #$OSB_PR_NUMBER has auto-merge armed; merging is the operator's call: gh pr merge --disable-auto $OSB_PR_NUMBER"
+echo "PR ok: #$OSB_PR_NUMBER $url open on $OSB_BASE at $head"
diff --git a/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/check-release.sh b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/check-release.sh
new file mode 100755
index 00000000..6e0aff1c
--- /dev/null
+++ b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/check-release.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+# success_check of `docs_version`: the version and CHANGELOG state match what
+# the change kind decided (CLAUDE.md "Versioning").
+#
+# Release-bearing PR (OSB_RELEASE major|minor|patch):
+# - package.json carries the expected bump of the base version;
+# - the first `## [` heading of CHANGELOG.md is `## [X.Y.Z] - YYYY-MM-DD`
+# (no `[Unreleased]` left above it);
+# - the `[X.Y.Z]: .../compare/vPREV...vX.Y.Z` link reference exists;
+# - `sync-version --check` passes and everything is committed.
+# No-release PR (OSB_RELEASE none): package.json still carries the base version.
+[ -n "${BASH_VERSION:-}" ] || exec bash "$0" "$@"
+set -euo pipefail
+. "$(dirname "$0")/lib.sh"
+
+cd "$(repo_root)"
+load_ctx
+
+prev=$(git show "origin/$OSB_BASE:package.json" | json_version)
+now=$(json_version <package.json)
+
+if [ "$OSB_RELEASE" = none ]; then
+ [ "$now" = "$prev" ] || die "kind $OSB_KIND ships no release, but package.json moved $prev -> $now"
+ base_first=$(git show "origin/$OSB_BASE:CHANGELOG.md" | grep -m1 -E '^## \[' || true)
+ head_first=$(grep -m1 -E '^## \[' CHANGELOG.md || true)
+ [ "$head_first" = "$base_first" ] ||
+ die "kind $OSB_KIND ships no release, but the first CHANGELOG heading moved '$base_first' -> '$head_first'"
+ git diff --quiet && git diff --cached --quiet || die "documentation or CHANGELOG changes are not committed"
+ echo "release check ok: no release, version stays $now"
+ exit 0
+fi
+
+expected=$(python3 - "$prev" "$OSB_RELEASE" <<'PY'
+import sys
+major, minor, patch = (int(p) for p in sys.argv[1].split("."))
+bump = sys.argv[2]
+if bump == "major":
+ major, minor, patch = major + 1, 0, 0
+elif bump == "minor":
+ minor, patch = minor + 1, 0
+else:
+ patch += 1
+print(f"{major}.{minor}.{patch}")
+PY
+)
+[ "$now" = "$expected" ] || die "package.json is $now; a $OSB_RELEASE bump of $prev is $expected"
+
+first=$(grep -m1 -E '^## \[' CHANGELOG.md || true)
+printf '%s\n' "$first" | grep -qE "^## \[$expected\] - [0-9]{4}-[0-9]{2}-[0-9]{2}\$" ||
+ die "the first CHANGELOG heading is '$first', expected '## [$expected] - <date>'"
+grep -qE "^\[$expected\]: https://github\.com/itechmeat/open-second-brain/compare/v$prev\.\.\.v$expected\$" CHANGELOG.md ||
+ die "CHANGELOG.md lacks the link reference [$expected]: https://github.com/itechmeat/open-second-brain/compare/v$prev...v$expected"
+
+bun run scripts/sync-version.ts --check >/dev/null 2>&1 || die "sync-version --check fails: run bun run scripts/sync-version.ts"
+git diff --quiet && git diff --cached --quiet || die "version or CHANGELOG changes are not committed"
+echo "release check ok: $prev -> $expected ($OSB_RELEASE), CHANGELOG heading and link reference present"
diff --git a/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/ci-wait.sh b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/ci-wait.sh
new file mode 100755
index 00000000..03eff323
--- /dev/null
+++ b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/ci-wait.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+# Waits for the PR's checks on the current head with ONE blocking command,
+# `gh pr checks --watch` (no polling loop of our own), then prints the verdict.
+# The checks include CodeRabbit's status, so a green result also means the bot
+# review has finished (or was skipped).
+#
+# The watch runs WITHOUT --fail-fast: the verdict waits until every check has a
+# terminal state. A fast failure (a scan failing in seconds) must not start the
+# fix round while a slow job (windows) is still running, or a late failure of
+# that job needs a second fix round. The red verdict lists every failed check.
+#
+# Before the watch, the script makes sure the CI workflow run for THIS head
+# commit exists. Right after a push, `gh pr checks` can still show the previous
+# commit's finished checks and would return at once with a stale verdict. That
+# registration wait is bounded (REGISTRATION_TRIES x REGISTRATION_SLEEP) and
+# ends as soon as GitHub lists the run.
+#
+# Exit 0 green, 1 red (failed-job logs follow), 2 setup error.
+[ -n "${BASH_VERSION:-}" ] || exec bash "$0" "$@"
+set -euo pipefail
+. "$(dirname "$0")/lib.sh"
+
+REGISTRATION_TRIES=18
+REGISTRATION_SLEEP=10
+WATCH_TIMEOUT=6000 # the windows job alone has taken 45 minutes on a slow runner
+WATCH_INTERVAL=60 # gh's own refresh period while it blocks
+LOG_TAIL=250
+CI_WORKFLOW=ci.yml
+
+cd "$(repo_root)"
+load_ctx
+load_pr
+
+head=$(git rev-parse HEAD)
+pr_head=$(gh pr view "$OSB_PR_NUMBER" --json headRefOid -q .headRefOid)
+[ "$pr_head" = "$head" ] || die "PR #$OSB_PR_NUMBER head $pr_head is not local HEAD $head: push first"
+
+run_id=""
+for _ in $(seq "$REGISTRATION_TRIES"); do
+ run_id=$(gh run list --commit "$head" --workflow "$CI_WORKFLOW" --limit 1 --json databaseId -q '.[0].databaseId // empty')
+ [ -n "$run_id" ] && break
+ sleep "$REGISTRATION_SLEEP"
+done
+[ -n "$run_id" ] || die "no $CI_WORKFLOW run registered for $head after $((REGISTRATION_TRIES * REGISTRATION_SLEEP))s"
+
+set +e
+timeout "$WATCH_TIMEOUT" gh pr checks "$OSB_PR_NUMBER" --watch --interval "$WATCH_INTERVAL" >/dev/null 2>&1
+rc=$?
+set -e
+echo "checks for PR #$OSB_PR_NUMBER at $head (CI run $run_id):"
+gh pr checks "$OSB_PR_NUMBER" 2>&1 || true
+
+if [ "$rc" -eq 0 ]; then
+ # `--watch` exits 0 with a cancelled check: a cancelled job validated nothing.
+ cancelled=$(gh pr checks "$OSB_PR_NUMBER" --json name,bucket -q '[.[] | select(.bucket == "cancel") | .name] | join(", ")') ||
+ die "the check list could not be read after the watch"
+ if [ -z "$cancelled" ]; then
+ echo "CI-GATE: green"
+ exit 0
+ fi
+ echo "CI-GATE: red (cancelled: $cancelled)"
+ exit 1
+fi
+if [ "$rc" -eq 124 ]; then
+ echo "CI-GATE: red (checks still pending after ${WATCH_TIMEOUT}s)"
+ exit 1
+fi
+# 125-127: timeout or gh could not run, so CI was never observed.
+[ "$rc" -lt 125 ] || die "the checks watch could not run (exit $rc)"
+failed=$(gh pr checks "$OSB_PR_NUMBER" --json name,bucket -q '[.[] | select(.bucket == "fail" or .bucket == "cancel") | .name] | join(", ")' 2>/dev/null || true)
+echo "CI-GATE: red (failed: ${failed:-the check list could not be read, see the checks above})"
+# Per failed job, not `--log-failed` on the run: the job logs stay readable
+# even when another workflow run on the same head is still in progress.
+for job in $(gh run view "$run_id" --json jobs -q '.jobs[] | select(.conclusion == "failure") | .databaseId'); do
+ echo "--- failed job $job of run $run_id (log tail) ---"
+ gh run view --job "$job" --log 2>&1 | tail -n "$LOG_TAIL" || true
+done
+exit 1
diff --git a/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/cycle-run.sh b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/cycle-run.sh
new file mode 100755
index 00000000..d663d369
--- /dev/null
+++ b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/cycle-run.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+# Steps 1-3 of the dev quality cycle (skill dev-quality-cycle): OpenCodeReview
+# on the claude-code provider, the read-only Codex review and Claude Code's
+# /security-review, through the skill's own runner `scripts/cycle.sh`. The
+# skill owns the commands, flags, effort levels and failure detection; this
+# script only picks the range and records where the run folder is.
+#
+# Range: what the cycle has not reviewed yet, never what was merely pushed. The
+# cycle_review and final_fix nodes record the head the cycle reviewed in
+# <git-dir>/osb-pr-prepare/cycle-reviewed as "<branch> <sha>". When that record
+# names this branch and its sha is an ancestor of HEAD, the range is <sha>..HEAD;
+# otherwise it is the whole branch against origin/<base>. The runner exits 4
+# when the range is empty (HEAD already reviewed).
+#
+# The skill lives in $DEV_QUALITY_CYCLE_DIR, default ~/.agents/skills/dev-quality-cycle.
+#
+# Output: the runner's log, then one marker line
+# `CYCLE-RUN: ok|failed|resumable|nothing-new exit=<n> summary=<path>`
+# Exit 0 for every marker: the cycle_review node reads the outputs and decides.
+# Exit 2: setup error (`ERROR:`), which no code change can fix.
+[ -n "${BASH_VERSION:-}" ] || exec bash "$0" "$@"
+set -uo pipefail
+. "$(dirname "$0")/lib.sh"
+
+cd "$(repo_root)"
+load_ctx
+
+skill="${DEV_QUALITY_CYCLE_DIR:-$HOME/.agents/skills/dev-quality-cycle}"
+runner="$skill/scripts/cycle.sh"
+[ -x "$runner" ] || die "the dev-quality-cycle skill runner is missing: $runner"
+
+git rev-parse -q --verify "origin/$OSB_BASE^{commit}" >/dev/null ||
+ die "origin/$OSB_BASE is unknown: fetch it first"
+range_args=(--base "origin/$OSB_BASE")
+reviewed_file="$CTX_DIR/cycle-reviewed"
+if [ -s "$reviewed_file" ]; then
+ read -r reviewed_branch reviewed_sha <"$reviewed_file"
+ if [ "$reviewed_branch" = "$OSB_BRANCH" ] && [ -n "${reviewed_sha:-}" ] &&
+ git merge-base --is-ancestor "$reviewed_sha" HEAD 2>/dev/null; then
+ range_args=(--range "$reviewed_sha..HEAD")
+ fi
+fi
+
+# What the change is for: OCR --background-file and the Codex prompt.
+intent="$CTX_DIR/cycle-intent.md"
+{
+ printf 'Open Second Brain change of kind %s on branch %s against %s.\n' "$OSB_KIND" "$OSB_BRANCH" "$OSB_BASE"
+ printf 'Commits:\n'
+ git log --no-merges --format='- %s' "origin/$OSB_BASE..HEAD"
+} >"$intent"
+
+log="$CTX_DIR/cycle-run.log"
+"$runner" "${range_args[@]}" --context-file "$intent" --exclude 'bun.lock,uv.lock' . >"$log" 2>&1
+rc=$?
+cat "$log"
+summary=$(sed -n 's/^Summary: //p' "$log" | tail -1)
+case "$rc" in
+ 0) status=ok ;;
+ 1) status=failed ;;
+ 3) status=resumable ;;
+ 4) status=nothing-new ;;
+ *) die "the cycle runner exited $rc (usage or setup error); see $log" ;;
+esac
+echo "CYCLE-RUN: $status exit=$rc summary=${summary:-none}"
+exit 0
diff --git a/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/final-gates.sh b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/final-gates.sh
new file mode 100755
index 00000000..be2e4a86
--- /dev/null
+++ b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/final-gates.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Final gates before the push: the QA gates (qa-gates.sh) and the
+# architecture gate (arch-gate.sh) again, after the OpenCodeReview pass may
+# have committed fixes. When HEAD is still the commit the QA gates last
+# passed on AND the commit the architecture gate last passed on (each gate
+# records its own green HEAD), nothing changed since both were green, so the
+# re-run is skipped. A red architecture gate leaves no marker, so it runs again.
+#
+# Exit 0: both green, or skipped (`FINAL-GATES: pass`). Exit 1: a red gate
+# (`FINAL-GATES: red`, followed by the markers and output of the red gates).
+# Exit 2: a setup or tool error (`ERROR:`), which no code change can fix.
+[ -n "${BASH_VERSION:-}" ] || exec bash "$0" "$@"
+set -uo pipefail
+here=$(dirname "$0")
+. "$here/lib.sh"
+
+cd "$(repo_root)"
+load_ctx
+
+head=$(git rev-parse HEAD)
+green="$CTX_DIR/qa-green-head"
+arch_green="$CTX_DIR/arch-green-head"
+if [ -f "$green" ] && [ "$(cat "$green")" = "$head" ] &&
+ [ -f "$arch_green" ] && [ "$(cat "$arch_green")" = "$head" ]; then
+ echo "FINAL-GATES: pass (HEAD $head unchanged since the green QA and architecture gates)"
+ exit 0
+fi
+
+qa_out=$(sh "$here/qa-gates.sh" 2>&1)
+qa_rc=$?
+arch_out=$(sh "$here/arch-gate.sh" 2>&1)
+arch_rc=$?
+
+if [ "$qa_rc" -eq 0 ] && [ "$arch_rc" -eq 0 ]; then
+ printf '%s\n%s\n' "$qa_out" "$arch_out"
+ echo "FINAL-GATES: pass (QA and architecture gates green at $head)"
+ exit 0
+fi
+if [ "$qa_rc" -eq 2 ] || [ "$arch_rc" -eq 2 ]; then
+ printf '%s\n%s\n' "$qa_out" "$arch_out"
+ die "a gate could not run (qa exit $qa_rc, arch exit $arch_rc)"
+fi
+echo "FINAL-GATES: red (qa exit $qa_rc, arch exit $arch_rc)"
+printf '%s\n%s\n' "$qa_out" "$arch_out"
+exit 1
diff --git a/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/lib.sh b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/lib.sh
new file mode 100755
index 00000000..63bec8c3
--- /dev/null
+++ b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/lib.sh
@@ -0,0 +1,95 @@
+# Shared helpers for the osb-pr-prepare script nodes. Sourced, never run.
+#
+# apb hands a script node no parameters and no environment of its own, so the
+# per-run facts (base branch, change kind, release bump, PR number) travel in
+# files under the repository's git directory, which git never tracks:
+#
+# $(git rev-parse --git-path osb-pr-prepare)/context.env written by `intake`
+# $(git rev-parse --git-path osb-pr-prepare)/pr.env written by `push_pr`
+# $(git rev-parse --git-path osb-pr-prepare)/known-test-failures.txt
+# written by `qa_fix`
+#
+# A missing file is an explicit error naming the node that should have written
+# it, never a silent default.
+
+# The CI toolchain pin (.github/workflows/ci.yml, `bun-version`).
+OSB_CI_BUN_VERSION=1.4.4
+# The CI Python pin (.github/workflows/ci.yml, `python-version`).
+OSB_CI_PYTHON_VERSION=3.11
+# The only local embedding model the zg index uses: no remote provider, no key.
+OSB_ZG_MODEL=local/potion-code-16m-v2
+OSB_KINDS="feature fix refactor chore docs deps"
+OSB_RELEASES="major minor patch none"
+
+die() {
+ printf 'ERROR: %s\n' "$*"
+ exit 2
+}
+
+repo_root() {
+ git rev-parse --show-toplevel 2>/dev/null || die "not inside a git work tree"
+}
+
+ctx_dir() {
+ git rev-parse --path-format=absolute --git-path osb-pr-prepare
+}
+
+load_ctx() {
+ CTX_DIR=$(ctx_dir)
+ [ -f "$CTX_DIR/context.env" ] ||
+ die "$CTX_DIR/context.env is missing: the intake node did not record the PR context"
+ # shellcheck disable=SC1091
+ . "$CTX_DIR/context.env"
+ for v in OSB_BASE OSB_KIND OSB_RELEASE OSB_BRANCH; do
+ eval "val=\${$v:-}"
+ [ -n "$val" ] || die "$v is not set in $CTX_DIR/context.env"
+ done
+}
+
+load_pr() {
+ [ -f "$CTX_DIR/pr.env" ] ||
+ die "$CTX_DIR/pr.env is missing: the push_pr node did not record the PR number"
+ # shellcheck disable=SC1091
+ . "$CTX_DIR/pr.env"
+ [ -n "${OSB_PR_NUMBER:-}" ] || die "OSB_PR_NUMBER is not set in $CTX_DIR/pr.env"
+}
+
+json_version() {
+ # Reads the "version" field of a package.json given on stdin.
+ python3 -c 'import json,sys; print(json.load(sys.stdin)["version"])'
+}
+
+# Puts the CI-pinned Bun first on PATH. The Linux release zip is cached under
+# ~/.cache/osb-pr-prepare; the download happens once and needs no sudo. Local
+# Bun (1.4.x newer than the pin) bundles openclaw/index.js differently, so the
+# bundle-in-sync gate is only meaningful with the pinned build.
+use_ci_bun() {
+ cache="${XDG_CACHE_HOME:-$HOME/.cache}/osb-pr-prepare/bun-$OSB_CI_BUN_VERSION"
+ case "$(uname -m)" in
+ x86_64) asset=bun-linux-x64 ;;
+ aarch64 | arm64) asset=bun-linux-aarch64 ;;
+ *) die "no Bun $OSB_CI_BUN_VERSION release asset known for $(uname -m)" ;;
+ esac
+ bin="$cache/$asset/bun"
+ if [ ! -x "$bin" ]; then
+ mkdir -p "$cache"
+ url="https://github.com/oven-sh/bun/releases/download/bun-v$OSB_CI_BUN_VERSION/$asset.zip"
+ curl -fsSL -o "$cache/$asset.zip" "$url" || die "download failed: $url"
+ python3 -m zipfile -e "$cache/$asset.zip" "$cache" || die "unzip failed: $cache/$asset.zip"
+ chmod +x "$bin"
+ fi
+ got=$("$bin" --version) || die "cached Bun at $bin does not run"
+ [ "$got" = "$OSB_CI_BUN_VERSION" ] || die "cached Bun at $bin reports $got, expected $OSB_CI_BUN_VERSION"
+ PATH="$(dirname "$bin"):$PATH"
+ export PATH
+}
+
+# Prints the interpreter path of the CI-pinned Python, installing it through uv
+# (user-level, no sudo) when missing.
+ci_python() {
+ command -v uv >/dev/null 2>&1 || die "uv is not on PATH; it provides Python $OSB_CI_PYTHON_VERSION"
+ uv python find "$OSB_CI_PYTHON_VERSION" 2>/dev/null && return 0
+ uv python install "$OSB_CI_PYTHON_VERSION" >/dev/null 2>&1 ||
+ die "uv could not install Python $OSB_CI_PYTHON_VERSION"
+ uv python find "$OSB_CI_PYTHON_VERSION"
+}
diff --git a/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/qa-gates.sh b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/qa-gates.sh
new file mode 100755
index 00000000..3ce93b07
--- /dev/null
+++ b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/qa-gates.sh
@@ -0,0 +1,144 @@
+#!/bin/sh
+# Open Second Brain's own QA gates, as the CI `validate` job runs them
+# (.github/workflows/ci.yml), in the same order and with the same toolchain
+# pins: Bun 1.4.4 (cached release binary) and Python 3.11 (uv). Every step
+# runs even after a failure, so one pass shows the whole picture; the full
+# log of each step lands in <git-dir>/osb-pr-prepare/qa-logs/<step>.log and
+# only the tail of a failing step is printed.
+#
+# Known environment-only test failures: a test named in
+# <git-dir>/osb-pr-prepare/known-test-failures.txt (one exact `bun test` name
+# per line) does not fail the gate. Only `qa_fix` adds a name there, and only
+# after proving the same test fails on the merge base in this environment.
+#
+# On green, the tested HEAD is recorded in <git-dir>/osb-pr-prepare/qa-green-head
+# for final-gates.sh.
+#
+# The CI `windows` job cannot run here; CI covers it after the push.
+[ -n "${BASH_VERSION:-}" ] || exec bash "$0" "$@"
+set -uo pipefail
+. "$(dirname "$0")/lib.sh"
+
+root=$(repo_root)
+cd "$root"
+load_ctx
+command -v bun >/dev/null 2>&1 || die "bun is not on PATH"
+use_ci_bun
+py=$(ci_python) || exit 2
+
+logs="$CTX_DIR/qa-logs"
+rm -rf "$logs"
+mkdir -p "$logs"
+known="$CTX_DIR/known-test-failures.txt"
+test_home=$(mktemp -d "${TMPDIR:-/tmp}/osb-qa-home.XXXXXX")
+bundle=$(mktemp "${TMPDIR:-/tmp}/osb-openclaw-rebuild.XXXXXX.js")
+trap 'rm -rf "$test_home" "$bundle"' EXIT
+TAIL_LINES=80
+failed=()
+
+step() {
+ # step <name> <command...>: runs one gate, records PASS/FAIL.
+ name=$1
+ shift
+ if "$@" >"$logs/$name.log" 2>&1; then
+ echo "PASS $name"
+ else
+ echo "FAIL $name (log: $logs/$name.log)"
+ tail -n "$TAIL_LINES" "$logs/$name.log" | sed 's/^/ /'
+ failed+=("$name")
+ fi
+}
+
+report_only() {
+ name=$1
+ shift
+ "$@" >"$logs/$name.log" 2>&1
+ echo "INFO $name (report-only, exit $?; log: $logs/$name.log)"
+}
+
+openclaw_bundle_in_sync() {
+ bun build src/openclaw/index.ts --outfile "$bundle" --target=node --format=esm \
+ --external openclaw/plugin-sdk/plugin-entry &&
+ diff -q "$bundle" openclaw/index.js
+}
+
+bun_test() {
+ # Throwaway HOME, as the project's test discipline requires.
+ HOME="$test_home" bun test >"$logs/bun-test.raw" 2>&1
+ rc=$?
+ cat "$logs/bun-test.raw"
+ [ "$rc" -eq 0 ] && return 0
+ # An error outside a named test (an unhandled rejection while a file loads)
+ # is never covered by the known-failure list, whatever else failed.
+ if grep -qE '^# Unhandled error|^ *[1-9][0-9]* errors?$' "$logs/bun-test.raw"; then
+ echo "bun test reported an error outside a named test: not a known failure"
+ return 1
+ fi
+ sed -n 's/^(fail) \(.*\) \[[0-9.]*m\{0,1\}s\]$/\1/p; t; s/^(fail) \(.*\)$/\1/p' "$logs/bun-test.raw" |
+ LC_ALL=C sort -u >"$logs/bun-test.failed"
+ [ -s "$logs/bun-test.failed" ] || {
+ echo "bun test exited $rc without a (fail) line: a crash, not a test failure"
+ return 1
+ }
+ # The list holds only failures proven on one merge base; a moved base voids it.
+ if [ -f "$known" ] && [ "$(cat "$known.base" 2>/dev/null)" != "$(git merge-base "origin/$OSB_BASE" HEAD 2>/dev/null)" ]; then
+ echo "known-test-failures.txt was proven on another merge base: ignored"
+ unknown=$(cat "$logs/bun-test.failed")
+ elif [ -f "$known" ]; then
+ unknown=$(LC_ALL=C sort -u "$known" | LC_ALL=C comm -23 "$logs/bun-test.failed" -)
+ else
+ unknown=$(cat "$logs/bun-test.failed")
+ fi
+ if [ -z "$unknown" ]; then
+ echo "only known environment-only failures failed:"
+ sed 's/^/ known: /' "$logs/bun-test.failed"
+ return 0
+ fi
+ echo "failing tests not on the known list:"
+ printf '%s\n' "$unknown" | sed 's/^/ /'
+ return 1
+}
+
+python_tests() {
+ PATH="$root/scripts:$PATH" HOME="$test_home" "$py" -m unittest discover -s tests/python -v
+}
+
+anti_drift_ran() {
+ (
+ cd tests/python || exit 1
+ PATH="$root/scripts:$PATH" HOME="$test_home" "$py" -m unittest test_static_schemas -v >"$logs/anti-drift.raw" 2>&1
+ rc=$?
+ cat "$logs/anti-drift.raw"
+ [ "$rc" -eq 0 ] || exit "$rc"
+ grep -q "test_static_schemas_match_live_tools_list" "$logs/anti-drift.raw" || exit 1
+ if grep -qE 'test_static_schemas_match_live_tools_list.* \.\.\. skipped' "$logs/anti-drift.raw"; then
+ echo "anti-drift skipped itself; the live server was not reachable"
+ exit 1
+ fi
+ )
+}
+
+echo "QA gates for $OSB_BRANCH ($(git rev-parse --short HEAD)), Bun $(bun --version), $("$py" --version)"
+step install bun install --frozen-lockfile
+step sync-version bun run sync-version:check
+step sync-plugin-mirrors bun run sync-plugin-mirrors:check
+step openclaw-bundle openclaw_bundle_in_sync
+step link-ratchet bun run link-ratchet:check
+report_only check-paths bun run check:paths
+step fmt bun run fmt:check
+step lint bun run lint
+step typecheck bun run typecheck
+step bun-test bun_test
+step python-tests python_tests
+step anti-drift anti_drift_ran
+step python-compile "$py" -m compileall -q plugins/hermes
+step hermes-scan bun run check:hermes-scan
+
+if [ "${#failed[@]}" -eq 0 ]; then
+ # final-gates.sh skips its re-run while HEAD is still this commit.
+ git rev-parse HEAD >"$CTX_DIR/qa-green-head"
+ echo "QA-GATE: green"
+ exit 0
+fi
+echo "QA-GATE: red (${failed[*]})"
+exit 1
diff --git a/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/zg-index.sh b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/zg-index.sh
new file mode 100755
index 00000000..0b789280
--- /dev/null
+++ b/.apb/playbooks/osb-pr-prepare/1.4.2/scripts/zg-index.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+# Idempotent: makes sure the workspace has a ready zg (zvec-grep) index built
+# with a LOCAL embedding model. A missing index is created, an existing one is
+# refreshed incrementally and keeps its stored model (the env default only
+# applies to a new index). No remote provider, no credential, no daemon
+# (`--mode direct`). The index lives in <root>/.zvec-grep, which the repository
+# .gitignore lists, so neither git nor oxfmt sees it.
+[ -n "${BASH_VERSION:-}" ] || exec bash "$0" "$@"
+set -euo pipefail
+. "$(dirname "$0")/lib.sh"
+
+cd "$(repo_root)"
+command -v zg >/dev/null 2>&1 || die "zg is not on PATH"
+git check-ignore -q .zvec-grep/ || die ".zvec-grep/ is not ignored: add it to the repository .gitignore"
+
+export ZVEC_GREP_EMBEDDING="$OSB_ZG_MODEL"
+export ZVEC_GREP_DEVICE=cpu
+zg --index --mode direct 2>&1
+zg --status --mode direct --check-ready 2>&1
+echo "ZG-INDEX: ready"
diff --git a/.apb/playbooks/osb-pr-prepare/current b/.apb/playbooks/osb-pr-prepare/current
index 13175fdc..c9929e36 100644
--- a/.apb/playbooks/osb-pr-prepare/current
+++ b/.apb/playbooks/osb-pr-prepare/current
@@ -1 +1 @@
-1.4.1
\ No newline at end of file
+1.4.2
\ No newline at end of file
diff --git a/.apb/playbooks/osb-pr-prepare/meta/1.4.2.yaml b/.apb/playbooks/osb-pr-prepare/meta/1.4.2.yaml
new file mode 100644
index 00000000..7b000642
--- /dev/null
+++ b/.apb/playbooks/osb-pr-prepare/meta/1.4.2.yaml
@@ -0,0 +1,3 @@
+created_by: user
+run_id: null
+classification: null
diff --git a/.github/scripts/test-watchdog.sh b/.github/scripts/test-watchdog.sh
new file mode 100755
index 00000000..85331db3
--- /dev/null
+++ b/.github/scripts/test-watchdog.sh
@@ -0,0 +1,106 @@
+#!/usr/bin/env bash
+# Run the test suite with a wall-clock bound, and when the bound is hit,
+# name what was still running before stopping it.
+#
+# Usage: test-watchdog.sh <seconds> <command> [args...]
+#
+# A test that blocks its process synchronously (a busy loop, or a runtime
+# call that never returns) cannot be stopped by bun's per-test timeout (the
+# timer runs on the blocked thread), and under
+# `--parallel` the run then waits on that worker in silence until the job
+# timeout cancels it, with nothing in the log that says which file it was.
+# This wrapper:
+#
+# 1. points O2B_TEST_INFLIGHT_DIR at a fresh directory, where the test
+# preload (`tests/helpers/inflight-recorder.ts`) keeps one line per
+# test process: the file and the test number it is running;
+# 2. runs the command in a session of its own (bun's `--parallel`
+# workers take process groups of their own, but stay in the session);
+# 3. past <seconds>, prints those lines and the process tree of the
+# session (so a stuck `tar` or a worker blocked in a wait shows up),
+# stops every process of the session, and exits 124.
+#
+# The exit status is otherwise the command's own, so the gate is unchanged.
+set -uo pipefail
+
+if [ "$#" -lt 2 ]; then
+ echo "usage: $0 <seconds> <command> [args...]" >&2
+ exit 2
+fi
+limit="$1"
+shift
+case "$limit" in
+ '' | *[!0-9]*)
+ echo "test-watchdog: the bound must be a whole number of seconds, got '$limit'" >&2
+ exit 2
+ ;;
+esac
+
+dir="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/test-inflight"
+rm -rf "$dir"
+mkdir -p "$dir" || echo "::warning::cannot create the in-flight record directory $dir" >&2
+export O2B_TEST_INFLIGHT_DIR="$dir"
+
+report() {
+ echo "::error::the test suite was still running after ${limit}s; stopping it"
+ echo "Test processes and what each was doing last (pid: state):"
+ local found=0
+ for record in "$dir"/*.txt; do
+ [ -e "$record" ] || continue
+ found=1
+ local pid line
+ pid="$(basename "$record" .txt)"
+ line="$(cat "$record")"
+ # Only processes still alive matter: a finished worker's last line is
+ # history, not the hang.
+ if kill -0 "$pid" 2>/dev/null; then
+ case "$line" in
+ running* | loading*) echo "::error::still running in pid $pid: $line" ;;
+ *) echo " pid $pid (alive): $line" ;;
+ esac
+ fi
+ done
+ [ "$found" = 1 ] || echo " (no records: the preload never ran)"
+ echo "Process tree of the run (session $pid_run):"
+ ps -eo pid,ppid,sid,etimes,stat,wchan:32,args --forest \
+ | awk -v s="$pid_run" 'NR == 1 || $3 == s'
+}
+
+session_pids() {
+ ps -eo pid=,sid= | awk -v s="$pid_run" '$2 == s { print $1 }'
+}
+
+stop_session() {
+ local pids
+ pids="$(session_pids)"
+ [ -n "$pids" ] || return 0
+ # shellcheck disable=SC2086 # one pid per word
+ kill -TERM $pids 2>/dev/null
+ for _ in 1 2 3 4 5 6 7 8 9 10; do
+ pids="$(session_pids)"
+ [ -n "$pids" ] || return 0
+ sleep 1
+ done
+ # shellcheck disable=SC2086
+ kill -KILL $pids 2>/dev/null
+}
+
+# A non-interactive shell does not make background jobs group leaders, so
+# setsid starts the command as the leader of a new session without forking:
+# $! is the command itself and its pid is the session id.
+setsid "$@" &
+pid_run=$!
+# A cancelled step signals this shell only; pass it on to the session.
+trap 'stop_session; exit 143' INT TERM
+
+deadline=$((SECONDS + limit))
+while kill -0 "$pid_run" 2>/dev/null; do
+ if [ "$SECONDS" -ge "$deadline" ]; then
+ report
+ stop_session
+ wait "$pid_run" 2>/dev/null
+ exit 124
+ fi
+ sleep 5
+done
+wait "$pid_run"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index de9a3b9b..d8063645 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -59,7 +59,7 @@ jobs:
- name: Set up Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
- bun-version: 1.4.0
+ bun-version: 1.4.4
- name: Set up Python (Hermes plugin tests)
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
@@ -144,8 +144,19 @@ jobs:
# implies `--isolate`): serially the suite was five to seven minutes,
# the whole length of this job. The run rewrites the timings file the
# next runs on main and on pull requests start from.
+ #
+ # The watchdog bounds the suite at 25 minutes (a healthy run is about
+ # 8) and, past it, prints which test file and test every worker was
+ # still running before it stops the run: a test that blocks its worker
+ # synchronously is out of reach of bun's per-test timeout, and four
+ # runs on Bun 1.4.0 sat silent until the 45-minute job timeout that
+ # way (a `spawnSync` that spun forever under `--isolate`, fixed in Bun
+ # 1.4.3). The step bound is the backstop if the wrapper itself sticks.
- name: TypeScript test suite
- run: bun test --parallel --timings=.bun-timings.json --update-timings
+ timeout-minutes: 30
+ run: >-
+ .github/scripts/test-watchdog.sh 1500
+ bun test --parallel --timings=.bun-timings.json --update-timings
- name: Wait for the Python plugin tests
wait: python-tests
@@ -202,7 +213,7 @@ jobs:
- name: Set up Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
- bun-version: 1.4.0
+ bun-version: 1.4.4
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
@@ -278,7 +289,7 @@ jobs:
- name: Set up Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
- bun-version: 1.4.0
+ bun-version: 1.4.4
- name: Set up Python (Hermes plugin tests)
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
@@ -360,6 +371,8 @@ jobs:
- name: Hang watchdog
id: watchdog
background: true
+ env:
+ O2B_TEST_INFLIGHT_DIR: ${{ runner.temp }}/test-inflight
# `cancel` may end it with exit code 1; a diagnostic must never fail the job.
continue-on-error: true
shell: pwsh
@@ -367,13 +380,18 @@ jobs:
Start-Sleep -Seconds 720
$out = Join-Path $env:RUNNER_TEMP 'telemetry\hang-dump.txt'
New-Item -ItemType Directory -Force (Split-Path $out) | Out-Null
+ # The test preload keeps one line per test process naming the
+ # file and test it is running (`tests/helpers/inflight-recorder.ts`).
+ Get-ChildItem -Path $env:O2B_TEST_INFLIGHT_DIR -Filter '*.txt' -ErrorAction SilentlyContinue |
+ ForEach-Object { "test process $($_.BaseName): $(Get-Content -Raw $_.FullName)" } |
+ Tee-Object -FilePath $out
Get-CimInstance Win32_Process |
Where-Object { $_.Name -match '^(bun|node|python)' } |
Select-Object ProcessId, ParentProcessId,
@{ n = 'Minutes'; e = { [int]((Get-Date) - $_.CreationDate).TotalMinutes } },
CommandLine |
Format-Table -AutoSize -Wrap | Out-String -Width 400 |
- Tee-Object -FilePath $out
+ Tee-Object -FilePath $out -Append
"::warning::shard still running after 12 minutes; process dump in the windows-telemetry artifact"
- name: Wait for Defender to be off
@@ -383,6 +401,8 @@ jobs:
# so Bun's 5 s default - which also bounds beforeEach/afterEach hooks -
# times out tests that pass locally. Tests with their own timeout keep it.
- name: TypeScript test suite (shard ${{ matrix.shard }}/10)
+ env:
+ O2B_TEST_INFLIGHT_DIR: ${{ runner.temp }}/test-inflight
run: >-
bun test --shard=${{ matrix.shard }}/10
--timings=${{ runner.temp }}/timings/windows-timings.json --update-timings
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 1e40c54b..f1641941 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -63,7 +63,7 @@ jobs:
- name: Set up Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
- bun-version: 1.4.0
+ bun-version: 1.4.4
- name: Set up Python (Hermes plugin tests)
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
@@ -147,7 +147,7 @@ jobs:
- name: Set up Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
- bun-version: 1.4.0
+ bun-version: 1.4.4
- name: Resolve release version
id: version
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7554693e..2305f741 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
+- **A snapshot or restore can no longer hang forever on a stuck `tar` or `zstd`.** The snapshot module is synchronous, so a child that never exited froze the hook, CLI verb or MCP call that took the recovery point, with nothing able to interrupt it. Every `tar` and `zstd` run of a snapshot, a derived-store archive and a restore now has a timeout (fifteen minutes by default, `OPEN_SECOND_BRAIN_SNAPSHOT_TIMEOUT_MS` to change it); a run that hits it is killed and the snapshot fails with an error that names the tool and the bound, leaving no partial archive.
- **Token callers are attributed to their token on `brain_note` and `brain_expire` even without an `agent` argument.** Both handlers refused a cross-agent claim but then let an omitted agent resolve through the process config, so a token-minted caller's log line and expiration audit stamp could name the config identity instead of the credential's agent; both now fall back to the request identity after the claim check only when the caller arrived by token, and a shared-key caller keeps the config-path resolution it always had.
- **A retried `brain_feedback` force-confirmed capture no longer stays unwritten - and a replay can no longer resurrect a forgotten rule.** A first call that failed after its signal landed left an idempotency receipt whose retry answered `deduped` and never created the confirmed rule; the call now leaves a pending capture marker in the idempotency ledger before the preference write and a completion marker after it, and a deduped retry resumes only on that pending marker, with the same capture payload (the marker hash names `force_confirmed` and the expiration, so a forced retry of an unforced capture and a retry with a different lifetime both stay true no-ops) and with the signal still present. A crash that landed after the preference write but before the completion marker leaves the rule already active, so a replay that finds an active rule matching the captured slug and payload now closes the ledger and answers deduped instead of attempting the write a second time and refusing on the existing rule - and only a rule this capture can prove it wrote: the rule must read `confirmed` and name the deduped signal under `evidenced_by`, so a pre-existing same-slug same-payload rule falls through and surfaces its conflict instead of being adopted. A capture completed once, a capture whose signal `delete-by-source` later forgot, and a first call made without `force_confirmed` all stay true no-ops on replay; receipts written before the marker existed simply never resume, so old keys stay readable. The marker keys are digests of the trimmed client key rather than the key plus a suffix, so a key near the ledger's 256-character limit still captures fresh and replays deduped instead of failing its marker lookup, and a retry whose key differs only in surrounding whitespace finds the original capture's marker just as it dedupes its signal; the resume also answers a signal that moved since the failed write (the dream pass files inbox pages under `Brain/inbox/processed/`, an applied staged signal moves out of `Brain/pending/` into `Brain/inbox/`) by looking the id up in those folders, honors the server's config path when it consults the store, and stands down when the rule was retired in the crash window. The ledger's per-shard lock guarantees sequential retries dedupe exactly once on a device and, once synced, across devices; two truly concurrent retries can both pass the marker check, narrowed to a same-slug preference merge.
- **`brain_foresight` withholds private continuity records below local reach.** The extract fold read the raw continuity store, whose private records the read model drops, and served a private record's text as an item title with its source refs; the fold now takes the same withholding flag every other report fold takes, and local reach is unchanged. The recurring projection takes the flag too: a recurrence event the writer classified private - its source, or its scope, can name a private page whose name the projected item title carries - has its support dropped before the cadences are built, so no private-derived routine, support count or commitment reaches a caller below local reach.
diff --git a/docs/cli-reference.md b/docs/cli-reference.md
index 0c33ba2c..bcb15a5e 100644
--- a/docs/cli-reference.md
+++ b/docs/cli-reference.md
@@ -1809,13 +1809,15 @@ For the two verbs that do hold a handle, a second interrupt is not intercepted a
## Lock and cache overrides (since v1.61.0)
-Three environment variables tune how long a writer waits for a shared lock
-and where the machine-local dedup cache lives. None of them has a
+Four environment variables tune how long a writer waits for a shared lock,
+how long a snapshot tool may run, and where the machine-local dedup cache
+lives. None of them has a
`_brain.yaml` key: they describe the host, not the vault.
| Variable | Default | Effect |
| ----------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `OPEN_SECOND_BRAIN_LOCK_WAIT_MS` | `5000` | How long a write to shared ingest state (content manifest, plan checkpoint, session ledger, git record store) waits for its lock before it is refused with `ELOCKED`. A whole number of milliseconds; `0` means one attempt; anything else is an error. The one-second interactive wait is not affected. See [Source pipeline integrity](#source-pipeline-integrity-and-operator-tooling-since-v1340). |
+| `OPEN_SECOND_BRAIN_SNAPSHOT_TIMEOUT_MS` | `900000` (fifteen minutes) | How long one `tar` or `zstd` run of a Brain snapshot, a derived-store archive or a restore may take before it is killed and the snapshot fails naming the tool. A whole number of milliseconds above zero; anything else is an error. |
| `OPEN_SECOND_BRAIN_DEDUP_CACHE_DIR` | the user cache directory, `open-second-brain/dedup-index/` | Where the signal dedup index cache is kept, one `<vault-digest>.json` per vault, outside the vault. |
| `OPEN_SECOND_BRAIN_DEDUP_CACHE` | on | `0` turns the dedup index cache off; every capture then walks the inbox, `processed/` and `archived/` in full. |
diff --git a/openclaw/index.js b/openclaw/index.js
index 783ae779..b2e01c9e 100644
--- a/openclaw/index.js
+++ b/openclaw/index.js
@@ -19,7 +19,7 @@ var __toESM = (mod, isNodeMode, target) => {
return cached;
}
target = mod != null ? __create(__getProtoOf(mod)) : {};
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
+ const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
if (mod && typeof mod === "object" || typeof mod === "function") {
for (let key of __getOwnPropNames(mod))
if (!__hasOwnProp.call(to, key))
@@ -63,7 +63,17 @@ var __export = (target, all) => {
set: __exportSetter.bind(all, name)
});
};
-var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
+var __esm = (fn, res, err) => () => {
+ if (fn)
+ try {
+ res = fn(fn = 0);
+ } catch (e) {
+ err = [e];
+ }
+ if (err)
+ throw err[0];
+ return res;
+};
var __require = /* @__PURE__ */ createRequire(import.meta.url);
// node_modules/graceful-fs/polyfills.js
@@ -193,82 +203,82 @@ var require_polyfills = __commonJS(function(exports, module) {
}
};
}(fs.readSync);
- function patchLchmod(fs2) {
- fs2.lchmod = function(path, mode, callback) {
- fs2.open(path, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
+ function patchLchmod(fs) {
+ fs.lchmod = function(path, mode, callback) {
+ fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
if (err) {
if (callback)
callback(err);
return;
}
- fs2.fchmod(fd, mode, function(err2) {
- fs2.close(fd, function(err22) {
+ fs.fchmod(fd, mode, function(err) {
+ fs.close(fd, function(err2) {
if (callback)
- callback(err2 || err22);
+ callback(err || err2);
});
});
});
};
- fs2.lchmodSync = function(path, mode) {
- var fd = fs2.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
+ fs.lchmodSync = function(path, mode) {
+ var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
var threw = true;
var ret;
try {
- ret = fs2.fchmodSync(fd, mode);
+ ret = fs.fchmodSync(fd, mode);
threw = false;
} finally {
if (threw) {
try {
- fs2.closeSync(fd);
+ fs.closeSync(fd);
} catch (er) {}
} else {
- fs2.closeSync(fd);
+ fs.closeSync(fd);
}
}
return ret;
};
}
- function patchLutimes(fs2) {
- if (constants.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
- fs2.lutimes = function(path, at, mt, cb) {
- fs2.open(path, constants.O_SYMLINK, function(er, fd) {
+ function patchLutimes(fs) {
+ if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
+ fs.lutimes = function(path, at, mt, cb) {
+ fs.open(path, constants.O_SYMLINK, function(er, fd) {
if (er) {
if (cb)
cb(er);
return;
}
- fs2.futimes(fd, at, mt, function(er2) {
- fs2.close(fd, function(er22) {
+ fs.futimes(fd, at, mt, function(er) {
+ fs.close(fd, function(er2) {
if (cb)
- cb(er2 || er22);
+ cb(er || er2);
});
});
});
};
- fs2.lutimesSync = function(path, at, mt) {
- var fd = fs2.openSync(path, constants.O_SYMLINK);
+ fs.lutimesSync = function(path, at, mt) {
+ var fd = fs.openSync(path, constants.O_SYMLINK);
var ret;
var threw = true;
try {
- ret = fs2.futimesSync(fd, at, mt);
+ ret = fs.futimesSync(fd, at, mt);
threw = false;
} finally {
if (threw) {
try {
- fs2.closeSync(fd);
+ fs.closeSync(fd);
} catch (er) {}
} else {
- fs2.closeSync(fd);
+ fs.closeSync(fd);
}
}
return ret;
};
- } else if (fs2.futimes) {
- fs2.lutimes = function(_a, _b, _c, cb) {
+ } else if (fs.futimes) {
+ fs.lutimes = function(_a, _b, _c, cb) {
if (cb)
process.nextTick(cb);
};
- fs2.lutimesSync = function() {};
+ fs.lutimesSync = function() {};
}
}
function chmodFix(orig) {
@@ -503,10 +513,10 @@ var require_graceful_fs = __commonJS(function(exports, module) {
previousSymbol = "___graceful-fs.previous";
}
function noop() {}
- function publishQueue(context, queue2) {
+ function publishQueue(context, queue) {
Object.defineProperty(context, gracefulQueue, {
get: function() {
- return queue2;
+ return queue;
}
});
}
@@ -564,101 +574,101 @@ GFS4: `);
module.exports = patch(fs);
fs.__patched = true;
}
- function patch(fs2) {
- polyfills(fs2);
- fs2.gracefulify = patch;
- fs2.createReadStream = createReadStream;
- fs2.createWriteStream = createWriteStream;
- var fs$readFile = fs2.readFile;
- fs2.readFile = readFile;
+ function patch(fs) {
+ polyfills(fs);
+ fs.gracefulify = patch;
+ fs.createReadStream = createReadStream;
+ fs.createWriteStream = createWriteStream;
+ var fs$readFile = fs.readFile;
+ fs.readFile = readFile;
function readFile(path, options, cb) {
if (typeof options === "function")
cb = options, options = null;
return go$readFile(path, options, cb);
- function go$readFile(path2, options2, cb2, startTime) {
- return fs$readFile(path2, options2, function(err) {
+ function go$readFile(path, options, cb, startTime) {
+ return fs$readFile(path, options, function(err) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
- enqueue([go$readFile, [path2, options2, cb2], err, startTime || Date.now(), Date.now()]);
+ enqueue([go$readFile, [path, options, cb], err, startTime || Date.now(), Date.now()]);
else {
- if (typeof cb2 === "function")
- cb2.apply(this, arguments);
+ if (typeof cb === "function")
+ cb.apply(this, arguments);
}
});
}
}
- var fs$writeFile = fs2.writeFile;
- fs2.writeFile = writeFile;
+ var fs$writeFile = fs.writeFile;
+ fs.writeFile = writeFile;
function writeFile(path, data, options, cb) {
if (typeof options === "function")
cb = options, options = null;
return go$writeFile(path, data, options, cb);
- function go$writeFile(path2, data2, options2, cb2, startTime) {
- return fs$writeFile(path2, data2, options2, function(err) {
+ function go$writeFile(path, data, options, cb, startTime) {
+ return fs$writeFile(path, data, options, function(err) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
- enqueue([go$writeFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
+ enqueue([go$writeFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()]);
else {
- if (typeof cb2 === "function")
- cb2.apply(this, arguments);
+ if (typeof cb === "function")
+ cb.apply(this, arguments);
}
});
}
}
- var fs$appendFile = fs2.appendFile;
+ var fs$appendFile = fs.appendFile;
if (fs$appendFile)
- fs2.appendFile = appendFile;
+ fs.appendFile = appendFile;
function appendFile(path, data, options, cb) {
if (typeof options === "function")
cb = options, options = null;
return go$appendFile(path, data, options, cb);
- function go$appendFile(path2, data2, options2, cb2, startTime) {
- return fs$appendFile(path2, data2, options2, function(err) {
+ function go$appendFile(path, data, options, cb, startTime) {
+ return fs$appendFile(path, data, options, function(err) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
- enqueue([go$appendFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
+ enqueue([go$appendFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()]);
else {
- if (typeof cb2 === "function")
- cb2.apply(this, arguments);
+ if (typeof cb === "function")
+ cb.apply(this, arguments);
}
});
}
}
- var fs$copyFile = fs2.copyFile;
+ var fs$copyFile = fs.copyFile;
if (fs$copyFile)
- fs2.copyFile = copyFile;
+ fs.copyFile = copyFile;
function copyFile(src, dest, flags, cb) {
if (typeof flags === "function") {
cb = flags;
flags = 0;
}
return go$copyFile(src, dest, flags, cb);
- function go$copyFile(src2, dest2, flags2, cb2, startTime) {
- return fs$copyFile(src2, dest2, flags2, function(err) {
+ function go$copyFile(src, dest, flags, cb, startTime) {
+ return fs$copyFile(src, dest, flags, function(err) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
- enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
+ enqueue([go$copyFile, [src, dest, flags, cb], err, startTime || Date.now(), Date.now()]);
else {
- if (typeof cb2 === "function")
- cb2.apply(this, arguments);
+ if (typeof cb === "function")
+ cb.apply(this, arguments);
}
});
}
}
- var fs$readdir = fs2.readdir;
- fs2.readdir = readdir;
+ var fs$readdir = fs.readdir;
+ fs.readdir = readdir;
var noReaddirOptionVersions = /^v[0-5]\./;
function readdir(path, options, cb) {
if (typeof options === "function")
cb = options, options = null;
- var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path2, options2, cb2, startTime) {
- return fs$readdir(path2, fs$readdirCallback(path2, options2, cb2, startTime));
- } : function go$readdir2(path2, options2, cb2, startTime) {
- return fs$readdir(path2, options2, fs$readdirCallback(path2, options2, cb2, startTime));
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir(path, options, cb, startTime) {
+ return fs$readdir(path, fs$readdirCallback(path, options, cb, startTime));
+ } : function go$readdir(path, options, cb, startTime) {
+ return fs$readdir(path, options, fs$readdirCallback(path, options, cb, startTime));
};
return go$readdir(path, options, cb);
- function fs$readdirCallback(path2, options2, cb2, startTime) {
+ function fs$readdirCallback(path, options, cb, startTime) {
return function(err, files) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
enqueue([
go$readdir,
- [path2, options2, cb2],
+ [path, options, cb],
err,
startTime || Date.now(),
Date.now()
@@ -666,28 +676,28 @@ GFS4: `);
else {
if (files && files.sort)
files.sort();
- if (typeof cb2 === "function")
- cb2.call(this, err, files);
+ if (typeof cb === "function")
+ cb.call(this, err, files);
}
};
}
}
if (process.version.substr(0, 4) === "v0.8") {
- var legStreams = legacy(fs2);
+ var legStreams = legacy(fs);
ReadStream = legStreams.ReadStream;
WriteStream = legStreams.WriteStream;
}
- var fs$ReadStream = fs2.ReadStream;
+ var fs$ReadStream = fs.ReadStream;
if (fs$ReadStream) {
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
ReadStream.prototype.open = ReadStream$open;
}
- var fs$WriteStream = fs2.WriteStream;
+ var fs$WriteStream = fs.WriteStream;
if (fs$WriteStream) {
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
WriteStream.prototype.open = WriteStream$open;
}
- Object.defineProperty(fs2, "ReadStream", {
+ Object.defineProperty(fs, "ReadStream", {
get: function() {
return ReadStream;
},
@@ -697,7 +707,7 @@ GFS4: `);
enumerable: true,
configurable: true
});
- Object.defineProperty(fs2, "WriteStream", {
+ Object.defineProperty(fs, "WriteStream", {
get: function() {
return WriteStream;
},
@@ -708,7 +718,7 @@ GFS4: `);
configurable: true
});
var FileReadStream = ReadStream;
- Object.defineProperty(fs2, "FileReadStream", {
+ Object.defineProperty(fs, "FileReadStream", {
get: function() {
return FileReadStream;
},
@@ -719,7 +729,7 @@ GFS4: `);
configurable: true
});
var FileWriteStream = WriteStream;
- Object.defineProperty(fs2, "FileWriteStream", {
+ Object.defineProperty(fs, "FileWriteStream", {
get: function() {
return FileWriteStream;
},
@@ -768,29 +778,29 @@ GFS4: `);
});
}
function createReadStream(path, options) {
- return new fs2.ReadStream(path, options);
+ return new fs.ReadStream(path, options);
}
function createWriteStream(path, options) {
- return new fs2.WriteStream(path, options);
+ return new fs.WriteStream(path, options);
}
- var fs$open = fs2.open;
- fs2.open = open;
+ var fs$open = fs.open;
+ fs.open = open;
function open(path, flags, mode, cb) {
if (typeof mode === "function")
cb = mode, mode = null;
return go$open(path, flags, mode, cb);
- function go$open(path2, flags2, mode2, cb2, startTime) {
- return fs$open(path2, flags2, mode2, function(err, fd) {
+ function go$open(path, flags, mode, cb, startTime) {
+ return fs$open(path, flags, mode, function(err, fd) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
- enqueue([go$open, [path2, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
+ enqueue([go$open, [path, flags, mode, cb], err, startTime || Date.now(), Date.now()]);
else {
- if (typeof cb2 === "function")
- cb2.apply(this, arguments);
+ if (typeof cb === "function")
+ cb.apply(this, arguments);
}
});
}
}
- return fs2;
+ return fs;
}
function enqueue(elem) {
debug("ENQUEUE", elem[0].name, elem[1]);
@@ -1035,7 +1045,7 @@ var require_retry = __commonJS(function(exports) {
for (var i = 0;i < methods.length; i++) {
var method = methods[i];
var original = obj[method];
- obj[method] = function retryWrapper(original2) {
+ obj[method] = function retryWrapper(original) {
var op = exports.operation(options);
var args = Array.prototype.slice.call(arguments, 1);
var callback = args.pop();
@@ -1049,7 +1059,7 @@ var require_retry = __commonJS(function(exports) {
callback.apply(this, arguments);
});
op.attempt(function() {
- original2.apply(obj, args);
+ original.apply(obj, args);
});
}.bind(obj, original);
obj[method].options = options;
@@ -1077,8 +1087,8 @@ var require_signals = __commonJS(function(exports, module) {
// node_modules/signal-exit/index.js
var require_signal_exit = __commonJS(function(exports, module) {
var process2 = global.process;
- var processOk = function(process3) {
- return process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
+ var processOk = function(process2) {
+ return process2 && typeof process2 === "object" && typeof process2.removeListener === "function" && typeof process2.emit === "function" && typeof process2.reallyExit === "function" && typeof process2.listeners === "function" && typeof process2.kill === "function" && typeof process2.pid === "number" && typeof process2.on === "function";
};
if (!processOk(process2)) {
module.exports = function() {
@@ -1124,7 +1134,7 @@ var require_signal_exit = __commonJS(function(exports, module) {
emitter.on(ev, cb);
return remove;
};
- unload = function unload2() {
+ unload = function unload() {
if (!loaded || !processOk(global.process)) {
return;
}
@@ -1139,7 +1149,7 @@ var require_signal_exit = __commonJS(function(exports, module) {
emitter.count -= 1;
};
module.exports.unload = unload;
- emit = function emit2(event, code, signal) {
+ emit = function emit(event, code, signal) {
if (emitter.emitted[event]) {
return;
}
@@ -1168,7 +1178,7 @@ var require_signal_exit = __commonJS(function(exports, module) {
return signals;
};
loaded = false;
- load = function load2() {
+ load = function load() {
if (loaded || !processOk(global.process)) {
return;
}
@@ -1187,7 +1197,7 @@ var require_signal_exit = __commonJS(function(exports, module) {
};
module.exports.load = load;
originalProcessReallyExit = process2.reallyExit;
- processReallyExit = function processReallyExit2(code) {
+ processReallyExit = function processReallyExit(code) {
if (!processOk(global.process)) {
return;
}
@@ -1197,7 +1207,7 @@ var require_signal_exit = __commonJS(function(exports, module) {
originalProcessReallyExit.call(process2, process2.exitCode);
};
originalProcessEmit = process2.emit;
- processEmit = function processEmit2(ev, arg) {
+ processEmit = function processEmit(ev, arg) {
if (ev === "exit" && processOk(global.process)) {
if (arg !== undefined) {
process2.exitCode = arg;
@@ -1245,9 +1255,9 @@ var require_mtime_precision = __commonJS(function(exports, module) {
if (err) {
return callback(err);
}
- fs.stat(file, (err2, stat) => {
- if (err2) {
- return callback(err2);
+ fs.stat(file, (err, stat) => {
+ if (err) {
+ return callback(err);
}
const precision = stat.mtime.getTime() % 1000 === 0 ? "s" : "ms";
Object.defineProperty(fs, cacheSymbol, { value: precision });
@@ -1287,12 +1297,12 @@ var require_lockfile = __commonJS(function(exports, module) {
const lockfilePath = getLockFile(file, options);
options.fs.mkdir(lockfilePath, (err) => {
if (!err) {
- return mtimePrecision.probe(lockfilePath, options.fs, (err2, mtime, mtimePrecision2) => {
- if (err2) {
+ return mtimePrecision.probe(lockfilePath, options.fs, (err, mtime, mtimePrecision) => {
+ if (err) {
options.fs.rmdir(lockfilePath, () => {});
- return callback(err2);
+ return callback(err);
}
- callback(null, mtime, mtimePrecision2);
+ callback(null, mtime, mtimePrecision);
});
}
if (err.code !== "EEXIST") {
@@ -1301,19 +1311,19 @@ var require_lockfile = __commonJS(function(exports, module) {
if (options.stale <= 0) {
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
}
- options.fs.stat(lockfilePath, (err2, stat) => {
- if (err2) {
- if (err2.code === "ENOENT") {
+ options.fs.stat(lockfilePath, (err, stat) => {
+ if (err) {
+ if (err.code === "ENOENT") {
return acquireLock(file, { ...options, stale: 0 }, callback);
}
- return callback(err2);
+ return callback(err);
}
if (!isLockStale(stat, options)) {
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
}
- removeLock(file, options, (err3) => {
- if (err3) {
- return callback(err3);
+ removeLock(file, options, (err) => {
+ if (err) {
+ return callback(err);
}
acquireLock(file, { ...options, stale: 0 }, callback);
});
@@ -1332,59 +1342,59 @@ var require_lockfile = __commonJS(function(exports, module) {
});
}
function updateLock(file, options) {
- const lock2 = locks[file];
- if (lock2.updateTimeout) {
+ const lock = locks[file];
+ if (lock.updateTimeout) {
return;
}
- lock2.updateDelay = lock2.updateDelay || options.update;
- lock2.updateTimeout = setTimeout(() => {
- lock2.updateTimeout = null;
- options.fs.stat(lock2.lockfilePath, (err, stat) => {
- const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
+ lock.updateDelay = lock.updateDelay || options.update;
+ lock.updateTimeout = setTimeout(() => {
+ lock.updateTimeout = null;
+ options.fs.stat(lock.lockfilePath, (err, stat) => {
+ const isOverThreshold = lock.lastUpdate + options.stale < Date.now();
if (err) {
if (err.code === "ENOENT" || isOverThreshold) {
- return setLockAsCompromised(file, lock2, Object.assign(err, { code: "ECOMPROMISED" }));
+ return setLockAsCompromised(file, lock, Object.assign(err, { code: "ECOMPROMISED" }));
}
- lock2.updateDelay = 1000;
+ lock.updateDelay = 1000;
return updateLock(file, options);
}
- const isMtimeOurs = lock2.mtime.getTime() === stat.mtime.getTime();
+ const isMtimeOurs = lock.mtime.getTime() === stat.mtime.getTime();
if (!isMtimeOurs) {
- return setLockAsCompromised(file, lock2, Object.assign(new Error("Unable to update lock within the stale threshold"), { code: "ECOMPROMISED" }));
+ return setLockAsCompromised(file, lock, Object.assign(new Error("Unable to update lock within the stale threshold"), { code: "ECOMPROMISED" }));
}
- const mtime = mtimePrecision.getMtime(lock2.mtimePrecision);
- options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err2) => {
- const isOverThreshold2 = lock2.lastUpdate + options.stale < Date.now();
- if (lock2.released) {
+ const mtime = mtimePrecision.getMtime(lock.mtimePrecision);
+ options.fs.utimes(lock.lockfilePath, mtime, mtime, (err) => {
+ const isOverThreshold = lock.lastUpdate + options.stale < Date.now();
+ if (lock.released) {
return;
}
- if (err2) {
- if (err2.code === "ENOENT" || isOverThreshold2) {
- return setLockAsCompromised(file, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
+ if (err) {
+ if (err.code === "ENOENT" || isOverThreshold) {
+ return setLockAsCompromised(file, lock, Object.assign(err, { code: "ECOMPROMISED" }));
}
- lock2.updateDelay = 1000;
+ lock.updateDelay = 1000;
return updateLock(file, options);
}
- lock2.mtime = mtime;
- lock2.lastUpdate = Date.now();
- lock2.updateDelay = null;
+ lock.mtime = mtime;
+ lock.lastUpdate = Date.now();
+ lock.updateDelay = null;
updateLock(file, options);
});
});
- }, lock2.updateDelay);
- if (lock2.updateTimeout.unref) {
- lock2.updateTimeout.unref();
+ }, lock.updateDelay);
+ if (lock.updateTimeout.unref) {
+ lock.updateTimeout.unref();
}
}
- function setLockAsCompromised(file, lock2, err) {
- lock2.released = true;
- if (lock2.updateTimeout) {
- clearTimeout(lock2.updateTimeout);
+ function setLockAsCompromised(file, lock, err) {
+ lock.released = true;
+ if (lock.updateTimeout) {
+ clearTimeout(lock.updateTimeout);
}
- if (locks[file] === lock2) {
+ if (locks[file] === lock) {
delete locks[file];
}
- lock2.options.onCompromised(err);
+ lock.options.onCompromised(err);
}
function lock(file, options, callback) {
options = {
@@ -1403,32 +1413,32 @@ var require_lockfile = __commonJS(function(exports, module) {
options.stale = Math.max(options.stale || 0, 2000);
options.update = options.update == null ? options.stale / 2 : options.update || 0;
options.update = Math.max(Math.min(options.update, options.stale / 2), 1000);
- resolveCanonicalPath(file, options, (err, file2) => {
+ resolveCanonicalPath(file, options, (err, file) => {
if (err) {
return callback(err);
}
- const operation = retry.operation(options.retries);
- operation.attempt(() => {
- acquireLock(file2, options, (err2, mtime, mtimePrecision2) => {
- if (operation.retry(err2)) {
+ const operation2 = retry.operation(options.retries);
+ operation2.attempt(() => {
+ acquireLock(file, options, (err, mtime, mtimePrecision) => {
+ if (operation2.retry(err)) {
return;
}
- if (err2) {
- return callback(operation.mainError());
+ if (err) {
+ return callback(operation2.mainError());
}
- const lock2 = locks[file2] = {
- lockfilePath: getLockFile(file2, options),
+ const lock = locks[file] = {
+ lockfilePath: getLockFile(file, options),
mtime,
- mtimePrecision: mtimePrecision2,
+ mtimePrecision,
options,
lastUpdate: Date.now()
};
- updateLock(file2, options);
+ updateLock(file, options);
callback(null, (releasedCallback) => {
- if (lock2.released) {
+ if (lock.released) {
return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
}
- unlock(file2, { ...options, realpath: false }, releasedCallback);
+ unlock(file, { ...options, realpath: false }, releasedCallback);
});
});
});
@@ -1440,18 +1450,18 @@ var require_lockfile = __commonJS(function(exports, module) {
realpath: true,
...options
};
- resolveCanonicalPath(file, options, (err, file2) => {
+ resolveCanonicalPath(file, options, (err, file) => {
if (err) {
return callback(err);
}
- const lock2 = locks[file2];
- if (!lock2) {
+ const lock = locks[file];
+ if (!lock) {
return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
}
- lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
- lock2.released = true;
- delete locks[file2];
- removeLock(file2, options, callback);
+ lock.updateTimeout && clearTimeout(lock.updateTimeout);
+ lock.released = true;
+ delete locks[file];
+ removeLock(file, options, callback);
});
}
function check(file, options, callback) {
@@ -1462,13 +1472,13 @@ var require_lockfile = __commonJS(function(exports, module) {
...options
};
options.stale = Math.max(options.stale || 0, 2000);
- resolveCanonicalPath(file, options, (err, file2) => {
+ resolveCanonicalPath(file, options, (err, file) => {
if (err) {
return callback(err);
}
- options.fs.stat(getLockFile(file2, options), (err2, stat) => {
- if (err2) {
- return err2.code === "ENOENT" ? callback(null, false) : callback(err2);
+ options.fs.stat(getLockFile(file, options), (err, stat) => {
+ if (err) {
+ return err.code === "ENOENT" ? callback(null, false) : callback(err);
}
return callback(null, !isLockStale(stat, options));
});
@@ -1494,15 +1504,15 @@ var require_lockfile = __commonJS(function(exports, module) {
// node_modules/proper-lockfile/lib/adapter.js
var require_adapter = __commonJS(function(exports, module) {
var fs = require_graceful_fs();
- function createSyncFs(fs2) {
+ function createSyncFs(fs) {
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
- const newFs = { ...fs2 };
+ const newFs = { ...fs };
methods.forEach((method) => {
newFs[method] = (...args) => {
const callback = args.pop();
let ret;
try {
- ret = fs2[`${method}Sync`](...args);
+ ret = fs[`${method}Sync`](...args);
} catch (err) {
return callback(err);
}
@@ -3493,23 +3503,23 @@ function scanRawOutput(text, opts = {}) {
return `${keyPart}"${PLACEHOLDER}"`;
return `${keyPart}${PLACEHOLDER}`;
});
- out = out.replace(ENV_RE, (_match, key, sep2) => {
- return `${key}${sep2}${PLACEHOLDER}`;
+ out = out.replace(ENV_RE, (_match, key, sep) => {
+ return `${key}${sep}${PLACEHOLDER}`;
});
out = out.replace(BEARER_RE, (_match, prefix) => `${prefix}${PLACEHOLDER}`);
out = out.replace(JWT_RE, PLACEHOLDER);
out = out.replace(YAML_SECRET_BLOCK_RE, (_match, indent, key) => `${indent}${key}: "${PLACEHOLDER}"
`);
- out = out.replace(COLON_VALUE_RE, (match, key, sep2, value) => {
+ out = out.replace(COLON_VALUE_RE, (match, key, sep, value) => {
if (value.includes(PLACEHOLDER))
return match;
if (value.startsWith('"') && value.endsWith('"')) {
- return `${key}${sep2}"${PLACEHOLDER}"`;
+ return `${key}${sep}"${PLACEHOLDER}"`;
}
if (value.startsWith("'") && value.endsWith("'")) {
- return `${key}${sep2}'${PLACEHOLDER}'`;
+ return `${key}${sep}'${PLACEHOLDER}'`;
}
- return `${key}${sep2}"${PLACEHOLDER}"`;
+ return `${key}${sep}"${PLACEHOLDER}"`;
});
if (opts.redactTokens)
out = redactBareTokens(out);
@@ -6727,14 +6737,14 @@ function locate(vault, configPath, settle) {
if (!mode.storeOnly)
return { relocated: false, root: vault };
if (mode.reason === "no-legacy-tree") {
- const storeId2 = configuredStoreId(configPath);
- const root2 = join20(deviceStateDir(storeId2), freshVaultRel(vault));
+ const storeId = configuredStoreId(configPath);
+ const root = join20(deviceStateDir(storeId), freshVaultRel(vault));
if (!settle)
- return { relocated: true, root: root2 };
- if (storeId2 !== null)
- adoptOnce(join20(deviceStateDir(null), freshVaultRel(vault)), root2);
- seedFromVaultOnce(vault, root2);
- return { relocated: true, root: root2 };
+ return { relocated: true, root };
+ if (storeId !== null)
+ adoptOnce(join20(deviceStateDir(null), freshVaultRel(vault)), root);
+ seedFromVaultOnce(vault, root);
+ return { relocated: true, root };
}
}
const storeId = configuredStoreId(configPath);
@@ -7450,9 +7460,9 @@ function listVaultPages(vaultDir, opts) {
return pages;
}
function walk(root, dir, skipDirs, skipFiles, out, notices) {
- let entries2;
+ let entries;
try {
- entries2 = readdirSync5(dir, { withFileTypes: true });
+ entries = readdirSync5(dir, { withFileTypes: true });
} catch (err) {
if (notices.sink !== undefined) {
emitDegradationNotice(notices.sink, {
@@ -7464,7 +7474,7 @@ function walk(root, dir, skipDirs, skipFiles, out, notices) {
}
return;
}
- for (const entry of entries2) {
+ for (const entry of entries) {
const full = join24(dir, entry.name);
if (entry.isDirectory()) {
if (skipDirs.has(entry.name))
@@ -7664,19 +7674,19 @@ function foldSignals(input) {
});
continue;
}
- const entry2 = building(byId, id);
- if (entry2.removed) {
- removedCounts.set(id, (removedCounts.get(id) ?? 0) + entry2.history.length);
- for (const old of entry2.history)
+ const entry = building(byId, id);
+ if (entry.removed) {
+ removedCounts.set(id, (removedCounts.get(id) ?? 0) + entry.history.length);
+ for (const old of entry.history)
voided.add(old.id);
- entry2.state = null;
- entry2.stateRecord = null;
- entry2.patches.clear();
- entry2.history = [];
+ entry.state = null;
+ entry.stateRecord = null;
+ entry.patches.clear();
+ entry.history = [];
}
- entry2.signal = record;
- entry2.removed = false;
- entry2.history.push(record);
+ entry.signal = record;
+ entry.removed = false;
+ entry.history.push(record);
continue;
}
if (record.kind === SIGNAL_REMOVED_KIND) {
@@ -7689,16 +7699,16 @@ function foldSignals(input) {
});
continue;
}
- const entry2 = building(byId, id);
- removedCounts.set(id, (removedCounts.get(id) ?? 0) + entry2.history.length);
- for (const old of entry2.history)
+ const entry = building(byId, id);
+ removedCounts.set(id, (removedCounts.get(id) ?? 0) + entry.history.length);
+ for (const old of entry.history)
voided.add(old.id);
- entry2.signal = null;
- entry2.state = null;
- entry2.stateRecord = null;
- entry2.patches.clear();
- entry2.history = [];
- entry2.removed = true;
+ entry.signal = null;
+ entry.state = null;
+ entry.stateRecord = null;
+ entry.patches.clear();
+ entry.history = [];
+ entry.removed = true;
continue;
}
if (record.kind !== SIGNAL_STATE_KIND)
@@ -8431,11 +8441,11 @@ function readDualWriteStatus(path = dualWriteStatusPath()) {
return EMPTY_STATUS;
}
}
-function bumpStatus(update3) {
+function bumpStatus(update) {
try {
const path = dualWriteStatusPath();
withLocalLock(path, () => {
- const next = update3(readDualWriteStatus(path));
+ const next = update(readDualWriteStatus(path));
atomicWriteFileSync(path, `${JSON.stringify(next, null, 2)}
`);
});
@@ -8508,8 +8518,8 @@ function defaultAgent() {
return "agent";
}
}
-function builtRecords(build2) {
- const built = build2();
+function builtRecords(build) {
+ const built = build();
if (built === null)
return [];
return Array.isArray(built) ? built : [built];
@@ -8563,7 +8573,7 @@ function failedOnlyInShared(err) {
}
return false;
}
-function dualWrite(build2, context = {}) {
+function dualWrite(build, context = {}) {
if (!isDualWriteEnabled(context.configPath))
return;
try {
@@ -8572,7 +8582,7 @@ function dualWrite(build2, context = {}) {
recordNoDevice();
return;
}
- const records = builtRecords(build2);
+ const records = builtRecords(build);
if (records.length === 0)
return;
let store;
@@ -8755,10 +8765,10 @@ function writerDevice(configPath) {
}
return device;
}
-function storeWrite(build2, context = {}) {
+function storeWrite(build, context = {}) {
try {
const device = writerDevice(context.configPath);
- const records = builtRecords(build2);
+ const records = builtRecords(build);
if (records.length === 0)
return [];
const store = storeFor(device, context);
@@ -9382,13 +9392,13 @@ function loadOrCreateKey(keyPath) {
}
}
ensureSyncExclusionMarker(keyDir);
- const key2 = readFileSync22(keyPath);
- if (isEnvelopeBytes(key2))
+ const key = readFileSync22(keyPath);
+ if (isEnvelopeBytes(key))
return heldKeyOrRefusal(keyPath);
- if (key2.length !== KEY_BYTES) {
+ if (key.length !== KEY_BYTES) {
throw new Error(`secrets keyfile is corrupt (expected ${KEY_BYTES} bytes): ${keyPath}`);
}
- return key2;
+ return key;
}
mkdirSync18(keyDir, { recursive: true, mode: 448 });
restrictToOwner(keyDir, "directory");
@@ -10232,14 +10242,14 @@ function findCodeProjects(opts) {
consider(opts.cwd);
const vaultParent = dirname22(resolve17(opts.vault));
if (isDir(vaultParent)) {
- let entries2 = [];
+ let entries = [];
try {
- entries2 = readdirSync7(vaultParent);
+ entries = readdirSync7(vaultParent);
} catch {
- entries2 = [];
+ entries = [];
}
- entries2.sort((a, b) => a.localeCompare(b));
- for (const name of entries2) {
+ entries.sort((a, b) => a.localeCompare(b));
+ for (const name of entries) {
if (scanned >= limit)
break;
consider(join31(vaultParent, name));
@@ -10309,8 +10319,8 @@ function defaultRunStatusJson(projectPath, timeoutMs = CODEGRAPH_PARTNER_TIMEOUT
if (!proc.success) {
if (stdout) {
try {
- const parsed2 = JSON.parse(stdout);
- return { ok: true, data: parsed2 };
+ const parsed = JSON.parse(stdout);
+ return { ok: true, data: parsed };
} catch {}
}
return {
diff --git a/openspec/project.md b/openspec/project.md
index ab3109fe..bf290b93 100644
--- a/openspec/project.md
+++ b/openspec/project.md
@@ -56,4 +56,4 @@ bun run scripts/sync-version.ts --check
```
When `src/` code that the OpenClaw bundle includes changes, rebuild it with
-`bunx [email protected] run build:openclaw` and commit `openclaw/index.js`.
+`bunx [email protected] run build:openclaw` (the Bun version CI pins) and commit `openclaw/index.js`.
diff --git a/src/core/brain/snapshot.ts b/src/core/brain/snapshot.ts
index 6e70ba3f..ca642928 100644
--- a/src/core/brain/snapshot.ts
+++ b/src/core/brain/snapshot.ts
@@ -85,7 +85,7 @@
*/
import { Database } from "bun:sqlite";
-import { spawnSync } from "node:child_process";
+import { spawnSync, type SpawnSyncOptions, type SpawnSyncReturns } from "node:child_process";
import { randomBytes } from "node:crypto";
import { gunzipSync, gzipSync } from "node:zlib";
import {
@@ -1488,6 +1488,72 @@ type CompressionSource = { readonly kind: "file"; readonly path: string };
*/
const SUBPROCESS_MAX_BUFFER_BYTES = 256 * 1024 * 1024;
+/** Environment variable that overrides {@link SNAPSHOT_TOOL_TIMEOUT_MS}. */
+export const SNAPSHOT_TOOL_TIMEOUT_ENV = "OPEN_SECOND_BRAIN_SNAPSHOT_TIMEOUT_MS";
+
+/**
+ * How long one `tar` or `zstd` run of a snapshot or a restore may take
+ * before it is killed and the snapshot fails.
+ *
+ * The whole module is synchronous by contract, so a child that never
+ * exits used to block the calling process forever: nothing else in the
+ * process can run, not even a timer that would notice. Fifteen minutes is
+ * far above what `zstd -19` needs for a `Brain/` tree of a few hundred
+ * megabytes, and finite, so a wedged tool turns into a named failure
+ * instead of a frozen hook, CLI or MCP call.
+ */
+export const SNAPSHOT_TOOL_TIMEOUT_MS = 15 * 60 * 1000;
+
+/**
+ * The tool timeout in force: {@link SNAPSHOT_TOOL_TIMEOUT_ENV} when it is a
+ * whole number of milliseconds above zero, {@link SNAPSHOT_TOOL_TIMEOUT_MS}
+ * when it is unset or empty. Any other value is an error rather than a
+ * silent fallback, so a typo cannot quietly change the bound.
+ */
+export function resolveSnapshotToolTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {
+ const raw = env[SNAPSHOT_TOOL_TIMEOUT_ENV];
+ if (raw === undefined || raw.trim() === "") return SNAPSHOT_TOOL_TIMEOUT_MS;
+ const text = raw.trim();
+ const parsed = /^\d+$/.test(text) ? Number(text) : Number.NaN;
+ if (!Number.isSafeInteger(parsed) || parsed <= 0) {
+ throw new Error(
+ `${SNAPSHOT_TOOL_TIMEOUT_ENV}=${raw} is not a timeout; set it to a whole number of ` +
+ `milliseconds > 0 (the default is ${SNAPSHOT_TOOL_TIMEOUT_MS}), or unset it`,
+ );
+ }
+ return parsed;
+}
+
+/**
+ * `spawnSync` with the snapshot tool timeout. A run that hits it is killed
+ * (SIGKILL: a tool that ignored its input closing will not honour a polite
+ * signal either) and reported as a {@link BrainSnapshotError} that names
+ * the tool and the bound. Every other outcome is returned unchanged for
+ * the caller's own status handling.
+ */
+function spawnSnapshotTool(
+ cmd: string,
+ args: ReadonlyArray<string>,
+ options: SpawnSyncOptions,
+ runId: string,
+): SpawnSyncReturns<Buffer> {
+ const timeoutMs = resolveSnapshotToolTimeoutMs();
+ const r = spawnSync(cmd, [...args], {
+ ...options,
+ timeout: timeoutMs,
+ killSignal: "SIGKILL",
+ }) as SpawnSyncReturns<Buffer>;
+ if ((r.error as NodeJS.ErrnoException | undefined)?.code === "ETIMEDOUT") {
+ throw new BrainSnapshotError(
+ `${cmd} did not finish within ${timeoutMs} ms and was stopped; ` +
+ `no archive was published (raise ${SNAPSHOT_TOOL_TIMEOUT_ENV} for a very large tree)`,
+ runId,
+ { cause: r.error },
+ );
+ }
+ return r;
+}
+
/**
* Run one compressor that writes the destination named after its `-o`
* itself, so only its stderr is captured. Every destination handed to it
@@ -1496,10 +1562,12 @@ const SUBPROCESS_MAX_BUFFER_BYTES = 256 * 1024 * 1024;
* name is detected by {@link publishArchive}, not here.
*/
function runCompressor(cmd: string, args: ReadonlyArray<string>, runId: string): void {
- const r = spawnSync(cmd, [...args], {
- stdio: ["ignore", "ignore", "pipe"],
- maxBuffer: SUBPROCESS_MAX_BUFFER_BYTES,
- });
+ const r = spawnSnapshotTool(
+ cmd,
+ args,
+ { stdio: ["ignore", "ignore", "pipe"], maxBuffer: SUBPROCESS_MAX_BUFFER_BYTES },
+ runId,
+ );
if (r.error) {
throw new BrainSnapshotError(`${cmd} failed to start: ${r.error.message}`, runId);
}
@@ -1536,12 +1604,14 @@ function runArchiveProducer(
runId: string,
): void {
const fd = openSync(outFile, "wx");
- let r: ReturnType<typeof spawnSync>;
+ let r: SpawnSyncReturns<Buffer>;
try {
- r = spawnSync(cmd, [...args], {
- maxBuffer: SUBPROCESS_MAX_BUFFER_BYTES,
- stdio: ["ignore", fd, "pipe"],
- });
+ r = spawnSnapshotTool(
+ cmd,
+ args,
+ { maxBuffer: SUBPROCESS_MAX_BUFFER_BYTES, stdio: ["ignore", fd, "pipe"] },
+ runId,
+ );
} finally {
closeSync(fd);
}
@@ -1928,14 +1998,17 @@ export function extractSnapshotToTemp(vault: string, runId: string): ExtractSnap
const tarball = join(staging, "brain.tar");
runCompressor("zstd", ["-d", "-q", "-o", tarball, archive], runId);
const input = openSync(tarball, "r");
- let tar: ReturnType<typeof spawnSync>;
+ let tar: SpawnSyncReturns<Buffer>;
try {
// `-f -` is explicit stdin: GNU tar defaults to stdin without
// it, but BSD tar and busybox tar do not, so passing the flag
// keeps the extraction portable across hosts.
- tar = spawnSync("tar", ["-x", "-f", "-", "-C", tarPathArg(tmp)], {
- stdio: [input, "inherit", "pipe"],
- });
+ tar = spawnSnapshotTool(
+ "tar",
+ ["-x", "-f", "-", "-C", tarPathArg(tmp)],
+ { stdio: [input, "inherit", "pipe"] },
+ runId,
+ );
} finally {
closeSync(input);
}
@@ -1964,10 +2037,12 @@ export function extractSnapshotToTemp(vault: string, runId: string): ExtractSnap
runId,
);
}
- const tar = spawnSync("tar", ["-x", "-f", "-", "-C", tarPathArg(tmp)], {
- input: tarball,
- stdio: ["pipe", "inherit", "pipe"],
- });
+ const tar = spawnSnapshotTool(
+ "tar",
+ ["-x", "-f", "-", "-C", tarPathArg(tmp)],
+ { input: tarball, stdio: ["pipe", "inherit", "pipe"] },
+ runId,
+ );
if (tar.error || tar.status !== 0) {
const stderr = (tar.stderr ?? Buffer.from("")).toString("utf8").trim();
throw new BrainSnapshotError(`tar extract failed: ${tar.error?.message ?? stderr}`, runId);
diff --git a/tests/cli/advisory-claim-truth.test.ts b/tests/cli/advisory-claim-truth.test.ts
index c0ae0baf..76a45e1f 100644
--- a/tests/cli/advisory-claim-truth.test.ts
+++ b/tests/cli/advisory-claim-truth.test.ts
@@ -14,7 +14,7 @@
* property and the half that regresses silently is the other one.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -27,6 +27,10 @@ import { resolveSearchConfig } from "../../src/core/search/index.ts";
import { indexVault } from "../../src/core/search/indexer.ts";
import { STORE_ROOT_ENV } from "../../src/core/store/constants.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/advisory-rail.test.ts b/tests/cli/advisory-rail.test.ts
index 01aa2088..f1ef821b 100644
--- a/tests/cli/advisory-rail.test.ts
+++ b/tests/cli/advisory-rail.test.ts
@@ -13,7 +13,7 @@
* is the reason its raw-argv scan had to become grammar-faithful.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -38,6 +38,10 @@ import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { DIAGNOSTIC_SIGNALS } from "../../src/core/brain/diagnostics.ts";
import { runCli } from "../helpers/run-cli.ts";
import { useUnshardedLegacyLog } from "../helpers/device-id.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
// The legacy day log and ledgers are read under their un-sharded names.
useUnshardedLegacyLog();
diff --git a/tests/cli/agent-scope-flags.test.ts b/tests/cli/agent-scope-flags.test.ts
index 9fc628fe..ee725db7 100644
--- a/tests/cli/agent-scope-flags.test.ts
+++ b/tests/cli/agent-scope-flags.test.ts
@@ -14,12 +14,16 @@
* merely parsing without error.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const OWNER_A = "agent-a";
const OWNER_B = "agent-b";
diff --git a/tests/cli/bank-bundle-cli.test.ts b/tests/cli/bank-bundle-cli.test.ts
index fe7364ee..36aa6885 100644
--- a/tests/cli/bank-bundle-cli.test.ts
+++ b/tests/cli/bank-bundle-cli.test.ts
@@ -16,13 +16,17 @@
* `tests/core/brain/portability/redacted-identity-restore.test.ts`.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { REDACTION_PLACEHOLDER } from "../../src/core/redactor.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/bootstrap.test.ts b/tests/cli/bootstrap.test.ts
index f725ca8c..794b603e 100644
--- a/tests/cli/bootstrap.test.ts
+++ b/tests/cli/bootstrap.test.ts
@@ -17,7 +17,7 @@
* that shells out on a real host.
*/
-import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, mock, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -53,6 +53,10 @@ import { JSONRPC_VERSION } from "../../src/mcp/protocol.ts";
// in a forwarding mock (captured before the mock is installed, or the
// forward would recurse) that fails only while a flag is set.
import * as payloadModule from "../../src/core/install/payload.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const realBuildPayload = payloadModule.buildPayload;
let failPayloadBuild = false;
diff --git a/tests/cli/brain-activation.test.ts b/tests/cli/brain-activation.test.ts
index c92dccdd..45f3d2fd 100644
--- a/tests/cli/brain-activation.test.ts
+++ b/tests/cli/brain-activation.test.ts
@@ -3,13 +3,17 @@
* Suite, t_2bc79017): status and sweep over the activation event store.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { recordAccessEvent } from "../../src/core/search/activation/store.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-agent-source-cli.test.ts b/tests/cli/brain-agent-source-cli.test.ts
index a36992f0..52afeeb9 100644
--- a/tests/cli/brain-agent-source-cli.test.ts
+++ b/tests/cli/brain-agent-source-cli.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -7,6 +7,10 @@ import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { writePreference } from "../../src/core/brain/preference.ts";
import { writeSignal } from "../../src/core/brain/signal.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-architect-progress.test.ts b/tests/cli/brain-architect-progress.test.ts
index c79ced70..c43cee09 100644
--- a/tests/cli/brain-architect-progress.test.ts
+++ b/tests/cli/brain-architect-progress.test.ts
@@ -14,7 +14,7 @@
* test that pressed Ctrl-C at the right moment would be a lottery.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -23,6 +23,10 @@ import { generateArchDocs } from "../../src/core/brain/architect/generate.ts";
import { createSafeguard, OPERATION, SafeguardAbortError } from "../../src/core/brain/safeguard.ts";
import { progressRecords, STAGE_IDENTIFIER } from "../helpers/progress-records.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let project: string;
diff --git a/tests/cli/brain-architect.test.ts b/tests/cli/brain-architect.test.ts
index 074c44d4..dbb85c4b 100644
--- a/tests/cli/brain-architect.test.ts
+++ b/tests/cli/brain-architect.test.ts
@@ -2,12 +2,16 @@
* `o2b brain architect` CLI surface (Project History Suite, t_929da8a2).
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let project: string;
diff --git a/tests/cli/brain-attr.test.ts b/tests/cli/brain-attr.test.ts
index 719c313d..3a37f158 100644
--- a/tests/cli/brain-attr.test.ts
+++ b/tests/cli/brain-attr.test.ts
@@ -5,12 +5,16 @@
* show renders the current map.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-audit.test.ts b/tests/cli/brain-audit.test.ts
index 18118cee..72fea045 100644
--- a/tests/cli/brain-audit.test.ts
+++ b/tests/cli/brain-audit.test.ts
@@ -8,13 +8,17 @@
* its own unit coverage.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { writePreference } from "../../src/core/brain/preference.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-authored-at-backfill-cli.test.ts b/tests/cli/brain-authored-at-backfill-cli.test.ts
index e94e3867..da22d434 100644
--- a/tests/cli/brain-authored-at-backfill-cli.test.ts
+++ b/tests/cli/brain-authored-at-backfill-cli.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -6,6 +6,10 @@ import { join } from "node:path";
import { writeSignal } from "../../src/core/brain/signal.ts";
import { parseFrontmatter } from "../../src/core/vault.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-backlinks-reporting.test.ts b/tests/cli/brain-backlinks-reporting.test.ts
index 95b9b9f8..b7a92a6e 100644
--- a/tests/cli/brain-backlinks-reporting.test.ts
+++ b/tests/cli/brain-backlinks-reporting.test.ts
@@ -10,13 +10,17 @@
* change removed, one layer up.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { brainDirs } from "../../src/core/brain/paths.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-bank-export.test.ts b/tests/cli/brain-bank-export.test.ts
index 6e2cc69d..bf593749 100644
--- a/tests/cli/brain-bank-export.test.ts
+++ b/tests/cli/brain-bank-export.test.ts
@@ -12,7 +12,7 @@
* override run too, not only the default arm's.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -23,6 +23,10 @@ import {
CONTENT_CLASS_FIELD,
} from "../../src/core/brain/provenance/content-class.ts";
import { EGRESS_CONTENT_CLASS_INCLUDE_NOTICE } from "../../src/core/egress/guard.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-batch-plan-forget-source.test.ts b/tests/cli/brain-batch-plan-forget-source.test.ts
index 5041ddb3..e3f3299b 100644
--- a/tests/cli/brain-batch-plan-forget-source.test.ts
+++ b/tests/cli/brain-batch-plan-forget-source.test.ts
@@ -4,8 +4,12 @@
* #2 `brain forget-source --json` must emit a JSON error envelope (not
* plain-text) when a runtime failure is caught, so automation can parse it.
*/
-import { expect, test } from "bun:test";
+import { expect, setDefaultTimeout, test } from "bun:test";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
test("batch-plan without <source-dir> exits 2 (usage error) — CR #127.1", async () => {
const r = await runCli(["brain", "batch-plan"]);
diff --git a/tests/cli/brain-batch-plan-ignore-warnings.test.ts b/tests/cli/brain-batch-plan-ignore-warnings.test.ts
index 430d50b3..ec06f3ef 100644
--- a/tests/cli/brain-batch-plan-ignore-warnings.test.ts
+++ b/tests/cli/brain-batch-plan-ignore-warnings.test.ts
@@ -6,7 +6,7 @@
* `skippedNonExtractable`.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { tmpdir } from "node:os";
@@ -14,6 +14,10 @@ import { tmpdir } from "node:os";
import { INGEST_TOOLS } from "../../src/mcp/brain/ingest-tools.ts";
import { CHMOD_CANNOT_DENY } from "../helpers/platform.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
let configHome: string;
diff --git a/tests/cli/brain-batch-plan-reconcile.test.ts b/tests/cli/brain-batch-plan-reconcile.test.ts
index 60b22c0c..2464902a 100644
--- a/tests/cli/brain-batch-plan-reconcile.test.ts
+++ b/tests/cli/brain-batch-plan-reconcile.test.ts
@@ -5,13 +5,17 @@
* the JSON output, and omitting the flag leaves the output unchanged.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { tmpdir } from "node:os";
import { hashFile, manifestPath } from "../../src/core/brain/ingest/content-manifest.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
let configHome: string;
diff --git a/tests/cli/brain-batch-plan-scoping.test.ts b/tests/cli/brain-batch-plan-scoping.test.ts
index 9c71824a..f5aefe9c 100644
--- a/tests/cli/brain-batch-plan-scoping.test.ts
+++ b/tests/cli/brain-batch-plan-scoping.test.ts
@@ -4,12 +4,16 @@
* this asserts the flags reach the planner and that omitting them is unchanged.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { tmpdir } from "node:os";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
let configHome: string;
diff --git a/tests/cli/brain-bench.test.ts b/tests/cli/brain-bench.test.ts
index b14fd10c..08354123 100644
--- a/tests/cli/brain-bench.test.ts
+++ b/tests/cli/brain-bench.test.ts
@@ -5,7 +5,7 @@
* operator's configured vault.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -23,6 +23,10 @@ import {
import { parseBenchFixture } from "../../src/core/bench/fixture.ts";
import type { BenchSuiteLoadOptions } from "../../src/core/bench/types.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let runsDir: string;
diff --git a/tests/cli/brain-benchmark.test.ts b/tests/cli/brain-benchmark.test.ts
index d0203bf4..2ea4102c 100644
--- a/tests/cli/brain-benchmark.test.ts
+++ b/tests/cli/brain-benchmark.test.ts
@@ -5,7 +5,7 @@
* status, and resets; search --expand reaches the expansion path.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -14,6 +14,10 @@ import { indexVault } from "../../src/core/search/indexer.ts";
import { listMetrics } from "../../src/core/brain/metrics.ts";
import { makeConfig } from "../helpers/search-fixtures.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-bridges-progress.test.ts b/tests/cli/brain-bridges-progress.test.ts
index 30157330..62bdf8cb 100644
--- a/tests/cli/brain-bridges-progress.test.ts
+++ b/tests/cli/brain-bridges-progress.test.ts
@@ -8,7 +8,7 @@
* caller parses does not move by one byte because someone asked to watch.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -18,6 +18,10 @@ import { OPERATION } from "../../src/core/brain/safeguard.ts";
import { makeConfig } from "../helpers/search-fixtures.ts";
import { progressRecords, STAGE_IDENTIFIER } from "../helpers/progress-records.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-bridges.test.ts b/tests/cli/brain-bridges.test.ts
index db990ec9..3509009e 100644
--- a/tests/cli/brain-bridges.test.ts
+++ b/tests/cli/brain-bridges.test.ts
@@ -5,7 +5,7 @@
* Fail-soft paths (no index, no embeddings) exit 0 with a reason.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -14,6 +14,10 @@ import { indexVault } from "../../src/core/search/indexer.ts";
import { listMetrics } from "../../src/core/brain/metrics.ts";
import { makeConfig } from "../helpers/search-fixtures.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-capture.test.ts b/tests/cli/brain-capture.test.ts
index 7f88b37b..ae899aff 100644
--- a/tests/cli/brain-capture.test.ts
+++ b/tests/cli/brain-capture.test.ts
@@ -20,7 +20,7 @@
* surface - never a bare stack trace and never exit 0.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -29,6 +29,10 @@ import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { listStagedCaptures } from "../../src/core/brain/capture/capture-note.ts";
import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-changes.test.ts b/tests/cli/brain-changes.test.ts
index f0ddfe10..dab94775 100644
--- a/tests/cli/brain-changes.test.ts
+++ b/tests/cli/brain-changes.test.ts
@@ -6,7 +6,7 @@
* returns a neighbour's record under its topic and scope after the
* watermark it printed.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
@@ -20,6 +20,10 @@ import {
type StoreIndexFixture,
} from "../core/search/fixtures/brain-store-index.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let fx: StoreIndexFixture;
let env: Record<string, string>;
diff --git a/tests/cli/brain-clusters-progress.test.ts b/tests/cli/brain-clusters-progress.test.ts
index ba4de439..7a8d2fba 100644
--- a/tests/cli/brain-clusters-progress.test.ts
+++ b/tests/cli/brain-clusters-progress.test.ts
@@ -8,7 +8,7 @@
* The records land on stderr and the payload does not move.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -18,6 +18,10 @@ import { OPERATION } from "../../src/core/brain/safeguard.ts";
import { makeConfig } from "../helpers/search-fixtures.ts";
import { progressRecords, STAGE_IDENTIFIER } from "../helpers/progress-records.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-clusters.test.ts b/tests/cli/brain-clusters.test.ts
index f03955fd..4e38ffdb 100644
--- a/tests/cli/brain-clusters.test.ts
+++ b/tests/cli/brain-clusters.test.ts
@@ -5,7 +5,7 @@
* bridges and clusters tasks under its lease.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import {
mkdirSync,
mkdtempSync,
@@ -23,6 +23,10 @@ import { indexVault } from "../../src/core/search/indexer.ts";
import { listMetrics } from "../../src/core/brain/metrics.ts";
import { makeConfig } from "../helpers/search-fixtures.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-co-occurrence.test.ts b/tests/cli/brain-co-occurrence.test.ts
index c5b159e0..9b136f4b 100644
--- a/tests/cli/brain-co-occurrence.test.ts
+++ b/tests/cli/brain-co-occurrence.test.ts
@@ -4,13 +4,17 @@
* graph, read-only by default, optionally persisted with --write.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-context-pack.test.ts b/tests/cli/brain-context-pack.test.ts
index 53fcdea5..cb712e90 100644
--- a/tests/cli/brain-context-pack.test.ts
+++ b/tests/cli/brain-context-pack.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -6,6 +6,10 @@ import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { listContextReceipts } from "../../src/core/brain/context-receipts.ts";
import { listRecallTelemetry } from "../../src/core/brain/recall-telemetry.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
diff --git a/tests/cli/brain-context-presets.test.ts b/tests/cli/brain-context-presets.test.ts
index 295c2eef..5f2d0a97 100644
--- a/tests/cli/brain-context-presets.test.ts
+++ b/tests/cli/brain-context-presets.test.ts
@@ -1,6 +1,10 @@
-import { expect, test } from "bun:test";
+import { expect, setDefaultTimeout, test } from "bun:test";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
test("brain context-presets show/suggest/diff returns dry-run diagnostics", async () => {
const show = await runCli(["brain", "context-presets", "show", "tight-context", "--json"]);
diff --git a/tests/cli/brain-context-receipts.test.ts b/tests/cli/brain-context-receipts.test.ts
index cceb4362..646712f1 100644
--- a/tests/cli/brain-context-receipts.test.ts
+++ b/tests/cli/brain-context-receipts.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -6,6 +6,10 @@ import { join } from "node:path";
import { emitContextReceipt } from "../../src/core/brain/context-receipts.ts";
import { appendContinuityRecord } from "../../src/core/brain/continuity/store.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
diff --git a/tests/cli/brain-continuity-promote.test.ts b/tests/cli/brain-continuity-promote.test.ts
index bb9b20a0..5c8345c2 100644
--- a/tests/cli/brain-continuity-promote.test.ts
+++ b/tests/cli/brain-continuity-promote.test.ts
@@ -4,7 +4,7 @@
* pages, sealed with an approval digest an apply must carry back.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -12,6 +12,10 @@ import { join } from "node:path";
import { recordHostMemoryWrite } from "../../src/core/brain/host-memory-write.ts";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-continuity.test.ts b/tests/cli/brain-continuity.test.ts
index 84d0ac19..deda5cd8 100644
--- a/tests/cli/brain-continuity.test.ts
+++ b/tests/cli/brain-continuity.test.ts
@@ -3,7 +3,7 @@
* t_51959aeb): read-only ATOF/ATIF export of the continuity store.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -12,6 +12,10 @@ import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { appendContinuityRecord } from "../../src/core/brain/continuity/store.ts";
import { emitRecallTelemetry, RECALL_CHANNEL } from "../../src/core/brain/recall-telemetry.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-dead-end.test.ts b/tests/cli/brain-dead-end.test.ts
index ddd6a2aa..7eeac33d 100644
--- a/tests/cli/brain-dead-end.test.ts
+++ b/tests/cli/brain-dead-end.test.ts
@@ -3,13 +3,17 @@
* negative-knowledge registry.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { listDeadEnds } from "../../src/core/brain/dead-ends.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-dead-letters.test.ts b/tests/cli/brain-dead-letters.test.ts
index 32a28afd..1d2843a5 100644
--- a/tests/cli/brain-dead-letters.test.ts
+++ b/tests/cli/brain-dead-letters.test.ts
@@ -21,7 +21,7 @@
* diagnostic entry resolves to the verb.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -55,6 +55,10 @@ import {
import { buildReconciliationReport } from "../../src/core/reconciliation-report.ts";
import { sessionMiningLedgerPath } from "../../src/core/brain/session-mining-ledger.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const NOW = new Date("2026-08-23T10:15:00Z");
const SESSION = "sess-cli-recover";
diff --git a/tests/cli/brain-decision.test.ts b/tests/cli/brain-decision.test.ts
index eba05391..a92fe0f5 100644
--- a/tests/cli/brain-decision.test.ts
+++ b/tests/cli/brain-decision.test.ts
@@ -3,13 +3,17 @@
* suite, Track B anchor, t_ac03214d).
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { VERB_HELP } from "../../src/cli/brain/help-text.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let configDir: string;
diff --git a/tests/cli/brain-deep-synthesis.test.ts b/tests/cli/brain-deep-synthesis.test.ts
index 7e2086b0..a7b03c29 100644
--- a/tests/cli/brain-deep-synthesis.test.ts
+++ b/tests/cli/brain-deep-synthesis.test.ts
@@ -4,7 +4,7 @@
* `--json` payload alongside the prior pre-S1 fields.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -12,6 +12,10 @@ import { join } from "node:path";
import { indexVault } from "../../src/core/search/indexer.ts";
import { makeConfig } from "../helpers/search-fixtures.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-design-note.test.ts b/tests/cli/brain-design-note.test.ts
index 52c251bf..fc338fe8 100644
--- a/tests/cli/brain-design-note.test.ts
+++ b/tests/cli/brain-design-note.test.ts
@@ -15,7 +15,7 @@
* the absolute host path.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -24,6 +24,10 @@ import { recordDecision } from "../../src/core/brain/decisions/record.ts";
import { buildToolTable, findTool } from "../../src/mcp/tools.ts";
import type { ServerContext } from "../../src/mcp/tool-contract.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const TOPIC = "vector index storage";
let tmp: string;
diff --git a/tests/cli/brain-diarize.test.ts b/tests/cli/brain-diarize.test.ts
index 8453b809..a8d49a02 100644
--- a/tests/cli/brain-diarize.test.ts
+++ b/tests/cli/brain-diarize.test.ts
@@ -6,12 +6,16 @@
* stays plain-text on stderr otherwise.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-distill.test.ts b/tests/cli/brain-distill.test.ts
index 5469f999..285ce306 100644
--- a/tests/cli/brain-distill.test.ts
+++ b/tests/cli/brain-distill.test.ts
@@ -3,7 +3,7 @@
* with block-level provenance, supplied as JSON.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -21,6 +21,10 @@ import { readExcerptSection } from "../../src/core/brain/provenance/capture-scop
import { BRAIN_DISTILLATIONS_REL } from "../../src/core/brain/path-constants.ts";
import { PAYLOAD_UNPARSEABLE_MESSAGE } from "../../src/core/brain/payload-json.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-doctor-next-step.test.ts b/tests/cli/brain-doctor-next-step.test.ts
index 828c29c9..85a7de28 100644
--- a/tests/cli/brain-doctor-next-step.test.ts
+++ b/tests/cli/brain-doctor-next-step.test.ts
@@ -16,7 +16,7 @@
* be chrome, not a next step.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -26,6 +26,10 @@ import { DIAGNOSTIC_SIGNALS } from "../../src/core/brain/diagnostics.ts";
import { DOCTOR_EXIT_EXCLUSIONS } from "../../src/core/brain/doctor-exits.ts";
import { writePreference } from "../../src/core/brain/preference.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** Two registered doctor codes that share one structural command. */
const REPAIR_COMMAND = DIAGNOSTIC_SIGNALS.get("broken-wikilink")!.nextCommand;
diff --git a/tests/cli/brain-doctor-parse-error-path.test.ts b/tests/cli/brain-doctor-parse-error-path.test.ts
index f576f5a8..c98ca2e0 100644
--- a/tests/cli/brain-doctor-parse-error-path.test.ts
+++ b/tests/cli/brain-doctor-parse-error-path.test.ts
@@ -14,13 +14,17 @@
* exactly once, on both the human and the machine surface.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-dream-operator-surface.test.ts b/tests/cli/brain-dream-operator-surface.test.ts
index 08c3e007..37f5179b 100644
--- a/tests/cli/brain-dream-operator-surface.test.ts
+++ b/tests/cli/brain-dream-operator-surface.test.ts
@@ -24,7 +24,7 @@
* true.
*/
-import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, spyOn, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -39,6 +39,10 @@ import { TRANSPORT_REACH } from "../../src/core/graph/transport-reach.ts";
import { JSONRPC_VERSION, MCPServer, PROTOCOL_VERSION } from "../../src/mcp/index.ts";
import { cmdBrainDream } from "../../src/cli/brain/verbs/dream.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-dream-progress.test.ts b/tests/cli/brain-dream-progress.test.ts
index 2cc0cfdd..895257ec 100644
--- a/tests/cli/brain-dream-progress.test.ts
+++ b/tests/cli/brain-dream-progress.test.ts
@@ -15,7 +15,7 @@
* does; Ctrl-C keeps its default meaning and kills the process.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -28,6 +28,10 @@ import { writeSignal } from "../../src/core/brain/signal.ts";
import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { runCli } from "../helpers/run-cli.ts";
import { progressRecords } from "../helpers/progress-records.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
let configHome: string;
diff --git a/tests/cli/brain-dream-retriage.test.ts b/tests/cli/brain-dream-retriage.test.ts
index b93a1161..53cfcd07 100644
--- a/tests/cli/brain-dream-retriage.test.ts
+++ b/tests/cli/brain-dream-retriage.test.ts
@@ -28,7 +28,7 @@
* into a NaN that reports a phantom fold-set change.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -44,6 +44,10 @@ import {
} from "../../src/core/brain/types.ts";
import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const NOW = "2026-06-01T00:00:00Z";
const LOUD = "loud";
diff --git a/tests/cli/brain-dream-stage.test.ts b/tests/cli/brain-dream-stage.test.ts
index 7680f52f..90d1fcb1 100644
--- a/tests/cli/brain-dream-stage.test.ts
+++ b/tests/cli/brain-dream-stage.test.ts
@@ -6,7 +6,7 @@
* positional-free.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -14,6 +14,10 @@ import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { writeSignal } from "../../src/core/brain/signal.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-entity.test.ts b/tests/cli/brain-entity.test.ts
index 6d2e71ea..5ee928f3 100644
--- a/tests/cli/brain-entity.test.ts
+++ b/tests/cli/brain-entity.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -18,6 +18,10 @@ import { HYGIENE_AUDIT_DIR } from "../../src/core/brain/audit-dirs.ts";
import { VERB_HELP } from "../../src/cli/brain/help-text.ts";
import { runCli } from "../helpers/run-cli.ts";
import { splitPosixShellWords } from "../helpers/posix-shell-words.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-event-trace.test.ts b/tests/cli/brain-event-trace.test.ts
index 22a3a054..f716ebbf 100644
--- a/tests/cli/brain-event-trace.test.ts
+++ b/tests/cli/brain-event-trace.test.ts
@@ -4,12 +4,16 @@
* from the exit-1 runtime-failure path. A clean run over an empty log exits 0.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-expiration.test.ts b/tests/cli/brain-expiration.test.ts
index 5aa6c777..940c42c7 100644
--- a/tests/cli/brain-expiration.test.ts
+++ b/tests/cli/brain-expiration.test.ts
@@ -20,7 +20,7 @@
* a successful no-op.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -28,6 +28,10 @@ import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-explorer.test.ts b/tests/cli/brain-explorer.test.ts
index b5686c89..e1e4d10d 100644
--- a/tests/cli/brain-explorer.test.ts
+++ b/tests/cli/brain-explorer.test.ts
@@ -6,7 +6,7 @@
* spawn so the SIGINT shutdown path is verified end-to-end.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -27,6 +27,9 @@ import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
import { runCli } from "../helpers/run-cli.ts";
import { fakeCredential } from "../helpers/fake-credentials.ts";
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
+
/**
* A vendor-prefixed credential shape, synthesised for this test. Caught by
* shape rather than by a word list, which is why an obviously fake body is
diff --git a/tests/cli/brain-export.test.ts b/tests/cli/brain-export.test.ts
index 92087dbb..28783f4e 100644
--- a/tests/cli/brain-export.test.ts
+++ b/tests/cli/brain-export.test.ts
@@ -2,7 +2,7 @@
* CLI tests for `o2b brain export` (§28).
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -18,6 +18,10 @@ import { join } from "node:path";
import { EXPORT_FORMAT, EXPORT_FORMATS } from "../../src/core/brain/export.ts";
import { runCli } from "../helpers/run-cli.ts";
import { fakeCredential } from "../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-extract-signals.test.ts b/tests/cli/brain-extract-signals.test.ts
index 60cba903..c5a980aa 100644
--- a/tests/cli/brain-extract-signals.test.ts
+++ b/tests/cli/brain-extract-signals.test.ts
@@ -16,7 +16,7 @@
* failure, in --json and in text.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
@@ -25,6 +25,10 @@ import { AUTO_EXTRACT_PER_SESSION_CAP } from "../../src/core/brain/extract-signa
import { sessionMiningLedgerPath } from "../../src/core/brain/session-mining-ledger.ts";
import { importSessionRecall } from "../../src/core/brain/session-recall.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const SESSION = "sess-cli";
let tmp: string;
diff --git a/tests/cli/brain-extract.test.ts b/tests/cli/brain-extract.test.ts
index bbe2bd6a..39675a3d 100644
--- a/tests/cli/brain-extract.test.ts
+++ b/tests/cli/brain-extract.test.ts
@@ -6,7 +6,7 @@
* answer exits 0.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawnSync } from "node:child_process";
import { mkdtempSync, rmSync, symlinkSync, truncateSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -16,6 +16,10 @@ import { CLI_COMMAND_MANIFEST, type CliCommandManifest } from "../../src/cli/com
import { HTML_EXTRACT_MAX_SOURCE_BYTES } from "../../src/core/brain/ingest/extract-html.ts";
import { IS_WINDOWS } from "../helpers/platform.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** The fixture files of the expected-output document. */
const PAGE_HTML =
diff --git a/tests/cli/brain-feedback-advisory.test.ts b/tests/cli/brain-feedback-advisory.test.ts
index 39554917..45c605b2 100644
--- a/tests/cli/brain-feedback-advisory.test.ts
+++ b/tests/cli/brain-feedback-advisory.test.ts
@@ -6,13 +6,17 @@
* confirmed same-scope preference. The write always proceeds regardless.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-feedback-race.test.ts b/tests/cli/brain-feedback-race.test.ts
index 3e7a5455..67d67f71 100644
--- a/tests/cli/brain-feedback-race.test.ts
+++ b/tests/cli/brain-feedback-race.test.ts
@@ -15,7 +15,7 @@
* helper refuses), so this uses `{ subprocess: true }`.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, readdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -24,6 +24,10 @@ import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { brainDirs } from "../../src/core/brain/paths.ts";
import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const WRITERS = 8;
diff --git a/tests/cli/brain-feedback-routing-hint.test.ts b/tests/cli/brain-feedback-routing-hint.test.ts
index 9bcad3ec..ba0b67b9 100644
--- a/tests/cli/brain-feedback-routing-hint.test.ts
+++ b/tests/cli/brain-feedback-routing-hint.test.ts
@@ -9,7 +9,7 @@
* it as a field instead of a line.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -18,6 +18,10 @@ import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { resolveNextStep } from "../../src/core/brain/next-step.ts";
import { CAPTURE_ROUTING_HINT_CODE } from "../../src/core/brain/write-advisory.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-foresight.test.ts b/tests/cli/brain-foresight.test.ts
index aa5de2b9..c583776c 100644
--- a/tests/cli/brain-foresight.test.ts
+++ b/tests/cli/brain-foresight.test.ts
@@ -2,7 +2,7 @@
* `o2b brain foresight` CLI surface (t_08a79c81).
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -11,6 +11,10 @@ import { applyRecurrenceEvidence } from "../../src/core/brain/recurrence.ts";
import { runCli } from "../helpers/run-cli.ts";
import { switchDevice } from "../core/brain/store-only/fixtures.ts";
import { makeStoreEnv } from "../core/store/fixtures/store-env.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-freeze.test.ts b/tests/cli/brain-freeze.test.ts
index 8a9ffb5f..48e3518f 100644
--- a/tests/cli/brain-freeze.test.ts
+++ b/tests/cli/brain-freeze.test.ts
@@ -8,7 +8,7 @@
* way out.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -16,6 +16,10 @@ import { join } from "node:path";
import { createSnapshot } from "../../src/core/brain/snapshot.ts";
import { BRAIN_SNAPSHOT_REASON } from "../../src/core/brain/types.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-generation-reports.test.ts b/tests/cli/brain-generation-reports.test.ts
index 2df52503..1af72351 100644
--- a/tests/cli/brain-generation-reports.test.ts
+++ b/tests/cli/brain-generation-reports.test.ts
@@ -1,10 +1,14 @@
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { listGenerationReports } from "../../src/core/brain/generation-reports.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
diff --git a/tests/cli/brain-git.test.ts b/tests/cli/brain-git.test.ts
index 85bd1671..298fee17 100644
--- a/tests/cli/brain-git.test.ts
+++ b/tests/cli/brain-git.test.ts
@@ -3,13 +3,17 @@
* (Project History Suite, t_c812752c + t_93d299bb).
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { execFileSync } from "node:child_process";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let repo: string;
diff --git a/tests/cli/brain-hallways.test.ts b/tests/cli/brain-hallways.test.ts
index 5940cea8..7679a663 100644
--- a/tests/cli/brain-hallways.test.ts
+++ b/tests/cli/brain-hallways.test.ts
@@ -7,7 +7,7 @@
* key. Ambient mining never writes an entity page - only promote does.
*/
-import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, spyOn, test } from "bun:test";
import {
existsSync,
mkdtempSync,
@@ -34,6 +34,10 @@ import {
__clearEntityLexiconCache,
} from "../../src/core/brain/entities/lexicon.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-health-baseline.test.ts b/tests/cli/brain-health-baseline.test.ts
index 798060b0..647b15ec 100644
--- a/tests/cli/brain-health-baseline.test.ts
+++ b/tests/cli/brain-health-baseline.test.ts
@@ -3,7 +3,7 @@
* watermark setter over `health.silence_before` in `_brain.yaml`.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -12,6 +12,10 @@ import { runCli } from "../helpers/run-cli.ts";
import { loadBrainConfig, resolveHealth } from "../../src/core/brain/policy.ts";
import { writePreference } from "../../src/core/brain/preference.ts";
import { BRAIN_PREFERENCE_STATUS } from "../../src/core/brain/types.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-health.test.ts b/tests/cli/brain-health.test.ts
index 3161eb0b..7eb18114 100644
--- a/tests/cli/brain-health.test.ts
+++ b/tests/cli/brain-health.test.ts
@@ -4,7 +4,7 @@
* `o2b brain doctor --remediate [--dry-run]`.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -15,6 +15,10 @@ import { computeContentHash } from "../../src/core/brain/content-hash.ts";
import { parsePreference, writePreference } from "../../src/core/brain/preference.ts";
import { brainDirs } from "../../src/core/brain/paths.ts";
import { BRAIN_PREFERENCE_STATUS } from "../../src/core/brain/types.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-help-write-honesty.test.ts b/tests/cli/brain-help-write-honesty.test.ts
index c637281e..cce710a7 100644
--- a/tests/cli/brain-help-write-honesty.test.ts
+++ b/tests/cli/brain-help-write-honesty.test.ts
@@ -14,13 +14,17 @@
* for that, this is the migrated verb's behaviour pin.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
describe("o2b brain claims --help", () => {
test("names the undated-quantity finding class and its structural hatches", async () => {
diff --git a/tests/cli/brain-hygiene.test.ts b/tests/cli/brain-hygiene.test.ts
index 89bcff5b..633409e7 100644
--- a/tests/cli/brain-hygiene.test.ts
+++ b/tests/cli/brain-hygiene.test.ts
@@ -13,7 +13,7 @@
* an apply is measured against the exact set of paths that changed.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -27,6 +27,10 @@ import { HYGIENE_TOOLS } from "../../src/mcp/brain/hygiene-tools.ts";
import { PROPERTY_DESCRIPTION_MAX, TOOL_DESCRIPTION_MAX } from "../../src/mcp/registry-guard.ts";
import { runCli } from "../helpers/run-cli.ts";
import { changedPaths, treeEntries, digestVaultTree } from "../helpers/vault-digest.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-import-claude-memory.test.ts b/tests/cli/brain-import-claude-memory.test.ts
index 83cd52b7..0663b27f 100644
--- a/tests/cli/brain-import-claude-memory.test.ts
+++ b/tests/cli/brain-import-claude-memory.test.ts
@@ -1,8 +1,12 @@
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
describe("o2b brain import-claude-memory CLI", () => {
test("dry-run prints plan summary, exit 0, no writes", async () => {
diff --git a/tests/cli/brain-inbox-drain.test.ts b/tests/cli/brain-inbox-drain.test.ts
index ac859bb0..675e9307 100644
--- a/tests/cli/brain-inbox-drain.test.ts
+++ b/tests/cli/brain-inbox-drain.test.ts
@@ -3,7 +3,7 @@
* Dry-run report by default, --apply to route and archive.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -11,6 +11,10 @@ import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { writeCaptureNote } from "../../src/core/brain/capture/capture-note.ts";
import { CAPTURE_OBLIGATION_MARKER } from "../../src/core/brain/capture/inbox-drain.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-intent-review.test.ts b/tests/cli/brain-intent-review.test.ts
index 897835b5..ac37d87d 100644
--- a/tests/cli/brain-intent-review.test.ts
+++ b/tests/cli/brain-intent-review.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -6,6 +6,10 @@ import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { writeSignal } from "../../src/core/brain/signal.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let root: string;
let vault: string;
diff --git a/tests/cli/brain-knowledge-gaps.test.ts b/tests/cli/brain-knowledge-gaps.test.ts
index f038c498..60d111a3 100644
--- a/tests/cli/brain-knowledge-gaps.test.ts
+++ b/tests/cli/brain-knowledge-gaps.test.ts
@@ -1,10 +1,14 @@
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { recordQueryDemand } from "../../src/core/brain/query-demand.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
diff --git a/tests/cli/brain-knowledge-pack.test.ts b/tests/cli/brain-knowledge-pack.test.ts
index 43bf9256..5b521ad7 100644
--- a/tests/cli/brain-knowledge-pack.test.ts
+++ b/tests/cli/brain-knowledge-pack.test.ts
@@ -6,13 +6,17 @@
* behaviour is covered in `tests/core/brain/portability/knowledge-pack.test.ts`.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { fakeCredential } from "../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** A GitHub personal-access-token shape the pack must never carry. */
const GITHUB_PAT = fakeCredential("ghp_", "abcdefghijklmnopqrstuvwxyz0123456789");
diff --git a/tests/cli/brain-label.test.ts b/tests/cli/brain-label.test.ts
index 12ed8ddb..9021f33a 100644
--- a/tests/cli/brain-label.test.ts
+++ b/tests/cli/brain-label.test.ts
@@ -4,12 +4,16 @@
* pack, remove drops one dimension, show renders the current set.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-lessons.test.ts b/tests/cli/brain-lessons.test.ts
index 62308969..16f1f857 100644
--- a/tests/cli/brain-lessons.test.ts
+++ b/tests/cli/brain-lessons.test.ts
@@ -15,7 +15,7 @@
* lesson by name, and stamps `lastPromotedAt` on what it wrote.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -34,6 +34,10 @@ import { writePreference } from "../../src/core/brain/preference.ts";
import { appendLogEvent } from "../../src/core/brain/log.ts";
import { BRAIN_LOG_EVENT_KIND } from "../../src/core/brain/types.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const SCOPE_ENV = "OPEN_SECOND_BRAIN_LESSONS_PROMOTION_SCOPES";
const PRINCIPLE = "Always run the full test suite before pushing to main";
diff --git a/tests/cli/brain-lifecycle-cli.test.ts b/tests/cli/brain-lifecycle-cli.test.ts
index 5a824e11..048d1e5f 100644
--- a/tests/cli/brain-lifecycle-cli.test.ts
+++ b/tests/cli/brain-lifecycle-cli.test.ts
@@ -6,13 +6,17 @@
* asserts the CLI verb wires it end to end.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { writeFrontmatter, parseFrontmatter } from "../../src/core/vault.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let configDir: string;
diff --git a/tests/cli/brain-lint.test.ts b/tests/cli/brain-lint.test.ts
index 0650a1fa..a0ec6ef2 100644
--- a/tests/cli/brain-lint.test.ts
+++ b/tests/cli/brain-lint.test.ts
@@ -15,7 +15,7 @@
* compared, not merely its size or the fact that something moved.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, relative, sep } from "node:path";
@@ -26,6 +26,10 @@ import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { resetVaultIdentityPins } from "../../src/core/brain/vault-identity.ts";
import { runCli } from "../helpers/run-cli.ts";
import { changedPaths, treeEntries, digestVaultTree } from "../helpers/vault-digest.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-log-append-warning.test.ts b/tests/cli/brain-log-append-warning.test.ts
index ada6e9b3..10560d42 100644
--- a/tests/cli/brain-log-append-warning.test.ts
+++ b/tests/cli/brain-log-append-warning.test.ts
@@ -11,12 +11,16 @@
* Windows shard that ran another fail-open store write first saw an empty
* stderr.
*/
-import { afterEach, expect, test } from "bun:test";
+import { afterEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { makeStoreEnv, type StoreEnv } from "../core/store/fixtures/store-env.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let env: StoreEnv | null = null;
afterEach(() => {
diff --git a/tests/cli/brain-log-verify.test.ts b/tests/cli/brain-log-verify.test.ts
index 58439d75..605a387f 100644
--- a/tests/cli/brain-log-verify.test.ts
+++ b/tests/cli/brain-log-verify.test.ts
@@ -8,7 +8,7 @@
* looks like its success is not a check.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -16,6 +16,10 @@ import { join } from "node:path";
import { appendLogEvent } from "../../src/core/brain/log.ts";
import { logJsonlPath, logShardJsonlPath } from "../../src/core/brain/paths.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const DATE = "2026-06-03";
diff --git a/tests/cli/brain-maintenance-progress.test.ts b/tests/cli/brain-maintenance-progress.test.ts
index 70877749..0e6ddf7d 100644
--- a/tests/cli/brain-maintenance-progress.test.ts
+++ b/tests/cli/brain-maintenance-progress.test.ts
@@ -10,7 +10,7 @@
* four steps would say "2 of 4" for twenty minutes and mean nothing.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -18,6 +18,10 @@ import { join } from "node:path";
import { OPERATION } from "../../src/core/brain/safeguard.ts";
import { progressRecords, STAGE_IDENTIFIER } from "../helpers/progress-records.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-maintenance.test.ts b/tests/cli/brain-maintenance.test.ts
index 226c3373..a41596ce 100644
--- a/tests/cli/brain-maintenance.test.ts
+++ b/tests/cli/brain-maintenance.test.ts
@@ -4,7 +4,7 @@
* must not alarm on a quiet hour), status renders lease + journal.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
appendFileSync,
existsSync,
@@ -54,6 +54,10 @@ import { FAKE_PROVIDER_KEY } from "../helpers/fake-credentials.ts";
import { homeEnv } from "../helpers/platform.ts";
import { runCli } from "../helpers/run-cli.ts";
import { useUnshardedLegacyLog } from "../helpers/device-id.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
// The legacy day log and ledgers are read under their un-sharded names.
useUnshardedLegacyLog();
diff --git a/tests/cli/brain-merge.test.ts b/tests/cli/brain-merge.test.ts
index 4a655039..3fdbfe0e 100644
--- a/tests/cli/brain-merge.test.ts
+++ b/tests/cli/brain-merge.test.ts
@@ -8,7 +8,7 @@
* failures.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -16,6 +16,10 @@ import { join } from "node:path";
import { writePreference } from "../../src/core/brain/preference.ts";
import { regenerateActive } from "../../src/core/brain/active.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-migrate-store-help.test.ts b/tests/cli/brain-migrate-store-help.test.ts
index 2a7db4d2..9e19efb7 100644
--- a/tests/cli/brain-migrate-store-help.test.ts
+++ b/tests/cli/brain-migrate-store-help.test.ts
@@ -4,9 +4,13 @@
* migration, with forms that exclude each other.
*/
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
describe("migrate-store help", () => {
test("the verb's help names every form and flag", async () => {
diff --git a/tests/cli/brain-migrate-store.test.ts b/tests/cli/brain-migrate-store.test.ts
index cfc5ec1a..88f25665 100644
--- a/tests/cli/brain-migrate-store.test.ts
+++ b/tests/cli/brain-migrate-store.test.ts
@@ -8,7 +8,7 @@
* `--rollback` returns the machine to it (and is refused with no migration
* on this machine). Conflicting flag combinations are usage errors.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
import { dirname, join } from "node:path";
@@ -20,6 +20,10 @@ import {
type LegacyVaultFixture,
} from "../core/store-migration/fixtures/legacy-vault.ts";
import { digestVaultTree } from "../helpers/vault-digest.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let fx: LegacyVaultFixture;
let env: Record<string, string>;
diff --git a/tests/cli/brain-moc-audit-cli.test.ts b/tests/cli/brain-moc-audit-cli.test.ts
index 1767e689..c6a32dfe 100644
--- a/tests/cli/brain-moc-audit-cli.test.ts
+++ b/tests/cli/brain-moc-audit-cli.test.ts
@@ -2,12 +2,16 @@
* CLI smoke test for `o2b brain moc-audit` (v0.10.17).
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-monthly.test.ts b/tests/cli/brain-monthly.test.ts
index e141ce70..941c2e27 100644
--- a/tests/cli/brain-monthly.test.ts
+++ b/tests/cli/brain-monthly.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -7,6 +7,10 @@ import { appendLogEvent } from "../../src/core/brain/log.ts";
import { brainDirs } from "../../src/core/brain/paths.ts";
import { BRAIN_LOG_EVENT_KIND } from "../../src/core/brain/types.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let root: string;
let vault: string;
diff --git a/tests/cli/brain-morning-brief-open.test.ts b/tests/cli/brain-morning-brief-open.test.ts
index b92fa5fb..e63ebc03 100644
--- a/tests/cli/brain-morning-brief-open.test.ts
+++ b/tests/cli/brain-morning-brief-open.test.ts
@@ -7,13 +7,17 @@
* named rather than hidden, and rendering mutates nothing.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { openDecision } from "../../src/core/brain/decisions/open-store.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let configDir: string;
diff --git a/tests/cli/brain-note-lifecycle-help.test.ts b/tests/cli/brain-note-lifecycle-help.test.ts
index 93740123..1f8af6d6 100644
--- a/tests/cli/brain-note-lifecycle-help.test.ts
+++ b/tests/cli/brain-note-lifecycle-help.test.ts
@@ -18,12 +18,16 @@
* the verb alone turns this red.
*/
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { join } from "node:path";
import { nestedCommand } from "../../src/cli/command-manifest.ts";
import { parsedFlagSchema } from "../helpers/parsed-flag-schema.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const VERBS = ["note-lifecycle", "scaffold-stub"] as const;
diff --git a/tests/cli/brain-note-lifecycle.test.ts b/tests/cli/brain-note-lifecycle.test.ts
index f957213b..53845bb5 100644
--- a/tests/cli/brain-note-lifecycle.test.ts
+++ b/tests/cli/brain-note-lifecycle.test.ts
@@ -14,7 +14,7 @@
* shape (the MCP test owns that).
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -22,6 +22,10 @@ import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-note.test.ts b/tests/cli/brain-note.test.ts
index 5316343e..4f180b91 100644
--- a/tests/cli/brain-note.test.ts
+++ b/tests/cli/brain-note.test.ts
@@ -5,13 +5,17 @@
* Brain-native milestone-log mirror of the MCP `brain_note` tool.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { useUnshardedLegacyLog } from "../helpers/device-id.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
// The legacy day log and ledgers are read under their un-sharded names.
useUnshardedLegacyLog();
diff --git a/tests/cli/brain-orphan-repair.test.ts b/tests/cli/brain-orphan-repair.test.ts
index 0813ec8c..d3c72ebe 100644
--- a/tests/cli/brain-orphan-repair.test.ts
+++ b/tests/cli/brain-orphan-repair.test.ts
@@ -9,7 +9,7 @@
* by an operator typing the command.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -19,6 +19,10 @@ import { ORPHAN_SESSION_REPAIR_COMMAND } from "../../src/core/brain/doctor/orpha
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { signalPath as brainSignalPath } from "../../src/core/brain/paths.ts";
import { writeSignal } from "../../src/core/brain/signal.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** Event date and slug of the single fixture signal; the production
* path builder composes the same file name from them. */
diff --git a/tests/cli/brain-page-dedup.test.ts b/tests/cli/brain-page-dedup.test.ts
index 2d5eede5..94ba1553 100644
--- a/tests/cli/brain-page-dedup.test.ts
+++ b/tests/cli/brain-page-dedup.test.ts
@@ -21,7 +21,7 @@
* still resolve every link to either of them.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -29,6 +29,10 @@ import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-panel.test.ts b/tests/cli/brain-panel.test.ts
index 8bee9b19..434c02eb 100644
--- a/tests/cli/brain-panel.test.ts
+++ b/tests/cli/brain-panel.test.ts
@@ -3,12 +3,16 @@
* t_0cc6fdff).
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-payload.test.ts b/tests/cli/brain-payload.test.ts
index 2e248fae..a255aa1f 100644
--- a/tests/cli/brain-payload.test.ts
+++ b/tests/cli/brain-payload.test.ts
@@ -6,7 +6,7 @@
* missing payloads, and a gc whose default is a dry run.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, readdirSync, rmSync, utimesSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -16,6 +16,10 @@ import { payloadPath, payloadsDir } from "../../src/core/brain/paths.ts";
import { PAYLOAD_GC_GRACE_MS, PayloadRegistry } from "../../src/core/brain/payload-registry.ts";
import { importSessionRecall } from "../../src/core/brain/session-recall.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-pending.test.ts b/tests/cli/brain-pending.test.ts
index 8bc5a358..3bde89b3 100644
--- a/tests/cli/brain-pending.test.ts
+++ b/tests/cli/brain-pending.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -8,6 +8,10 @@ import { brainDirs } from "../../src/core/brain/paths.ts";
import { stagePendingSignal } from "../../src/core/brain/pending.ts";
import { stageForReview } from "../../src/core/brain/pending/pending-lanes.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-permissions.test.ts b/tests/cli/brain-permissions.test.ts
index df8fd788..6b55a88f 100644
--- a/tests/cli/brain-permissions.test.ts
+++ b/tests/cli/brain-permissions.test.ts
@@ -10,13 +10,17 @@
* fault under `permissions-unreadable` - exactly once.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { appendDecisionLedger } from "../../src/core/brain/permissions/ledger.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-post-compact-audit.test.ts b/tests/cli/brain-post-compact-audit.test.ts
index 3f8217f9..63d4874d 100644
--- a/tests/cli/brain-post-compact-audit.test.ts
+++ b/tests/cli/brain-post-compact-audit.test.ts
@@ -1,10 +1,14 @@
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { writePinnedContext, readPinnedContext } from "../../src/core/brain/pinned.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
diff --git a/tests/cli/brain-pre-compact-extract.test.ts b/tests/cli/brain-pre-compact-extract.test.ts
index f4da4e6f..8025ca32 100644
--- a/tests/cli/brain-pre-compact-extract.test.ts
+++ b/tests/cli/brain-pre-compact-extract.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, readdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -6,6 +6,10 @@ import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { partitionRecords } from "../core/brain/store-only/fixtures.ts";
import { makeTestStore, type TestStore } from "../helpers/test-store.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
// A bare vault is store-only (design D14 item 1): the records land in a
diff --git a/tests/cli/brain-pre-extract.test.ts b/tests/cli/brain-pre-extract.test.ts
index df70000d..49c57cd2 100644
--- a/tests/cli/brain-pre-extract.test.ts
+++ b/tests/cli/brain-pre-extract.test.ts
@@ -5,13 +5,17 @@
* wired, emits deterministic JSON, and reports unknown languages as unextracted.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { tmpdir } from "node:os";
import { CLI_COMMAND_MANIFEST, type CliCommandManifest } from "../../src/cli/command-manifest.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** The manifest entry of `o2b brain pre-extract`. */
function preExtractManifest(): CliCommandManifest {
diff --git a/tests/cli/brain-procedural-learning.test.ts b/tests/cli/brain-procedural-learning.test.ts
index 594a3094..f2cadb08 100644
--- a/tests/cli/brain-procedural-learning.test.ts
+++ b/tests/cli/brain-procedural-learning.test.ts
@@ -1,10 +1,14 @@
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { appendContinuityRecord } from "../../src/core/brain/continuity/store.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
diff --git a/tests/cli/brain-query-as-of.test.ts b/tests/cli/brain-query-as-of.test.ts
index 1c738d0c..50bf4d40 100644
--- a/tests/cli/brain-query-as-of.test.ts
+++ b/tests/cli/brain-query-as-of.test.ts
@@ -16,7 +16,7 @@
* order, indentation or trailing newline fails here.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -24,6 +24,10 @@ import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { writeSignal, type WriteSignalInput } from "../../src/core/brain/signal.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const TOPIC = "deploy";
/** The lapsed signal's expiration; every probe instant is chosen around it. */
diff --git a/tests/cli/brain-recall-telemetry.test.ts b/tests/cli/brain-recall-telemetry.test.ts
index 068ca8aa..baea021b 100644
--- a/tests/cli/brain-recall-telemetry.test.ts
+++ b/tests/cli/brain-recall-telemetry.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -10,6 +10,10 @@ import { JSONRPC_VERSION, MCPServer, PROTOCOL_VERSION } from "../../src/mcp/inde
import { INVALID_PARAMS } from "../../src/mcp/protocol.ts";
import { buildToolTable } from "../../src/mcp/tools.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
diff --git a/tests/cli/brain-reject-log-shard.test.ts b/tests/cli/brain-reject-log-shard.test.ts
index 09699625..ff094c73 100644
--- a/tests/cli/brain-reject-log-shard.test.ts
+++ b/tests/cli/brain-reject-log-shard.test.ts
@@ -19,7 +19,7 @@
* file sets outlives a test.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, rmSync } from "node:fs";
import { join } from "node:path";
@@ -29,6 +29,10 @@ import { parseRetired, writePreference } from "../../src/core/brain/preference.t
import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { tempDirs } from "../helpers/temp-dir.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const DEVICE_ID = "fixturedev";
diff --git a/tests/cli/brain-reject-siblings.test.ts b/tests/cli/brain-reject-siblings.test.ts
index 2f6f57d5..02a3ce75 100644
--- a/tests/cli/brain-reject-siblings.test.ts
+++ b/tests/cli/brain-reject-siblings.test.ts
@@ -7,7 +7,7 @@
* the key off its output is exactly what it was before.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -16,6 +16,10 @@ import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { writePreference } from "../../src/core/brain/preference.ts";
import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const FLAG_ENV = "OPEN_SECOND_BRAIN_NEAR_DUPLICATE_RETIRE_SIBLINGS_ENABLED";
const RULE = "always run the formatter before every commit in this repository";
diff --git a/tests/cli/brain-reject-store-only.test.ts b/tests/cli/brain-reject-store-only.test.ts
index e344430a..9d69a045 100644
--- a/tests/cli/brain-reject-store-only.test.ts
+++ b/tests/cli/brain-reject-store-only.test.ts
@@ -2,11 +2,15 @@
* `o2b brain reject` on a store-only machine: a preference the store does
* not hold is not found there, and the refusal names no vault page.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { runCli } from "../helpers/run-cli.ts";
import { switchDevice } from "../core/brain/store-only/fixtures.ts";
import { makeStoreEnv, type StoreEnv } from "../core/store/fixtures/store-env.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let env: StoreEnv | null = null;
afterEach(() => {
diff --git a/tests/cli/brain-repair-lane-holdout-gate.test.ts b/tests/cli/brain-repair-lane-holdout-gate.test.ts
index 1eca0fb4..afeb23ae 100644
--- a/tests/cli/brain-repair-lane-holdout-gate.test.ts
+++ b/tests/cli/brain-repair-lane-holdout-gate.test.ts
@@ -15,7 +15,7 @@
* evidence.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -23,6 +23,10 @@ import { join } from "node:path";
import { buildContinuityRecord } from "../../src/core/brain/continuity/store.ts";
import { DIAGNOSTIC_SIGNALS } from "../../src/core/brain/diagnostics.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** The code the gate's refusal resolves its exit through. */
const HOLDOUT_GATE_CODE = "repair-holdout-unresolved";
diff --git a/tests/cli/brain-repair-lane.test.ts b/tests/cli/brain-repair-lane.test.ts
index 7163444f..2fc9860d 100644
--- a/tests/cli/brain-repair-lane.test.ts
+++ b/tests/cli/brain-repair-lane.test.ts
@@ -4,7 +4,7 @@
* written; a rerun after apply converges to zero writes.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { dirname } from "node:path";
import { tmpdir } from "node:os";
@@ -19,6 +19,10 @@ import {
IDENTITY_STRENGTH,
type RepairCandidate,
} from "../../src/core/brain/link-graph/repair-lane.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-report-delta.test.ts b/tests/cli/brain-report-delta.test.ts
index e5b0d23a..b6928dd1 100644
--- a/tests/cli/brain-report-delta.test.ts
+++ b/tests/cli/brain-report-delta.test.ts
@@ -7,7 +7,7 @@
* writes nothing.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -15,6 +15,10 @@ import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { writeSignal } from "../../src/core/brain/signal.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-retention.test.ts b/tests/cli/brain-retention.test.ts
index 9d0f9b1b..0672b29d 100644
--- a/tests/cli/brain-retention.test.ts
+++ b/tests/cli/brain-retention.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, renameSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -7,6 +7,10 @@ import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { processedSignalPath, signalPath } from "../../src/core/brain/paths.ts";
import { writeSignal } from "../../src/core/brain/signal.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let root: string;
let vault: string;
diff --git a/tests/cli/brain-scaffold-stub.test.ts b/tests/cli/brain-scaffold-stub.test.ts
index 8757f178..423821c4 100644
--- a/tests/cli/brain-scaffold-stub.test.ts
+++ b/tests/cli/brain-scaffold-stub.test.ts
@@ -14,7 +14,7 @@
* MCP test owns that).
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -22,6 +22,10 @@ import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-scan-inline-strict.test.ts b/tests/cli/brain-scan-inline-strict.test.ts
index c57d15fa..47f51fbb 100644
--- a/tests/cli/brain-scan-inline-strict.test.ts
+++ b/tests/cli/brain-scan-inline-strict.test.ts
@@ -9,7 +9,7 @@
* exactly as a malformed marker is, so both gate the exit.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -19,6 +19,10 @@ import { brainConfigPath } from "../../src/core/brain/paths.ts";
import { DEFAULT_BRAIN_CONFIG_YAML } from "../../src/core/brain/config-template.ts";
import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-schema-cli.test.ts b/tests/cli/brain-schema-cli.test.ts
index 7e4ff43e..c23616d0 100644
--- a/tests/cli/brain-schema-cli.test.ts
+++ b/tests/cli/brain-schema-cli.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
mkdirSync,
mkdtempSync,
@@ -19,6 +19,10 @@ import {
BRAIN_SIGNAL_SIGN,
} from "../../src/core/brain/types.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** Schema tokens used by the cases below. */
const EXTERNAL = "external";
diff --git a/tests/cli/brain-secret.test.ts b/tests/cli/brain-secret.test.ts
index e662a34e..e360a308 100644
--- a/tests/cli/brain-secret.test.ts
+++ b/tests/cli/brain-secret.test.ts
@@ -5,13 +5,17 @@
* removes irrecoverably.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { fakeCredential } from "../helpers/fake-credentials.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-semantics-backfill-cli.test.ts b/tests/cli/brain-semantics-backfill-cli.test.ts
index 79f41a25..4bb8411c 100644
--- a/tests/cli/brain-semantics-backfill-cli.test.ts
+++ b/tests/cli/brain-semantics-backfill-cli.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -14,6 +14,10 @@ import {
BRAIN_RETIRED_REASON,
} from "../../src/core/brain/types.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-session-hook.test.ts b/tests/cli/brain-session-hook.test.ts
index a78e6545..62c4b9ca 100644
--- a/tests/cli/brain-session-hook.test.ts
+++ b/tests/cli/brain-session-hook.test.ts
@@ -1,10 +1,14 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-session-recall.test.ts b/tests/cli/brain-session-recall.test.ts
index 9b4f932b..0cae09c0 100644
--- a/tests/cli/brain-session-recall.test.ts
+++ b/tests/cli/brain-session-recall.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -7,6 +7,10 @@ import { importSessionRecall } from "../../src/core/brain/session-recall.ts";
import { appendContinuityRecord } from "../../src/core/brain/continuity/store.ts";
import type { SessionTurn } from "../../src/core/brain/sessions/types.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
diff --git a/tests/cli/brain-session-summary.test.ts b/tests/cli/brain-session-summary.test.ts
index 75387f3e..ec683e96 100644
--- a/tests/cli/brain-session-summary.test.ts
+++ b/tests/cli/brain-session-summary.test.ts
@@ -15,7 +15,7 @@
* 5. `found: false` is byte-identical to the pre-change envelope.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -23,6 +23,10 @@ import { join } from "node:path";
import { appendSessionSummary } from "../../src/core/brain/session-summary.ts";
import { appendContinuityRecord } from "../../src/core/brain/continuity/store.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-session.test.ts b/tests/cli/brain-session.test.ts
index 3dc72a7d..8f211910 100644
--- a/tests/cli/brain-session.test.ts
+++ b/tests/cli/brain-session.test.ts
@@ -3,12 +3,16 @@
* t_bc36a8a2).
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-settings-cli.test.ts b/tests/cli/brain-settings-cli.test.ts
index 751379d5..0d8e46c7 100644
--- a/tests/cli/brain-settings-cli.test.ts
+++ b/tests/cli/brain-settings-cli.test.ts
@@ -2,7 +2,7 @@
* `o2b brain settings get|set|unset|list` and `o2b brain set-primary` on a
* store-only machine (with and without a vault) and on an unswitched one.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { readFileSync } from "node:fs";
import { brainConfigPath } from "../../src/core/brain/paths.ts";
@@ -14,6 +14,10 @@ import {
switchDevice,
} from "../core/brain/store-only/fixtures.ts";
import { makeStoreEnv, type StoreEnv } from "../core/store/fixtures/store-env.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let env: StoreEnv | null = null;
afterEach(() => {
diff --git a/tests/cli/brain-signal-retire.test.ts b/tests/cli/brain-signal-retire.test.ts
index ca819204..ff3d893d 100644
--- a/tests/cli/brain-signal-retire.test.ts
+++ b/tests/cli/brain-signal-retire.test.ts
@@ -6,7 +6,7 @@
* non-signal id exits 2 (never a silent no-op).
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -15,6 +15,10 @@ import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { brainDirs } from "../../src/core/brain/paths.ts";
import { writeSignal } from "../../src/core/brain/signal.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-skill-page-drafts.test.ts b/tests/cli/brain-skill-page-drafts.test.ts
index 6a7b8119..7f3f6e82 100644
--- a/tests/cli/brain-skill-page-drafts.test.ts
+++ b/tests/cli/brain-skill-page-drafts.test.ts
@@ -12,7 +12,7 @@
* skills root.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -21,6 +21,10 @@ import { appendContinuityRecord } from "../../src/core/brain/continuity/store.ts
import { buildToolTable, findTool } from "../../src/mcp/tools.ts";
import type { ServerContext } from "../../src/mcp/tool-contract.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const PAGE = "notes/release-ritual.md";
const DRAFT = {
diff --git a/tests/cli/brain-state.test.ts b/tests/cli/brain-state.test.ts
index 5861b466..a0617d1a 100644
--- a/tests/cli/brain-state.test.ts
+++ b/tests/cli/brain-state.test.ts
@@ -3,12 +3,16 @@
* exact-state lane - set overwrites, get/list read, clear removes.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-summary-cli.test.ts b/tests/cli/brain-summary-cli.test.ts
index 31d66d57..3cbd7a12 100644
--- a/tests/cli/brain-summary-cli.test.ts
+++ b/tests/cli/brain-summary-cli.test.ts
@@ -2,12 +2,16 @@
* CLI smoke test for `o2b brain summary` (v0.10.16).
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-synthesise-cli.test.ts b/tests/cli/brain-synthesise-cli.test.ts
index 2ef1e213..6acee9b3 100644
--- a/tests/cli/brain-synthesise-cli.test.ts
+++ b/tests/cli/brain-synthesise-cli.test.ts
@@ -2,12 +2,16 @@
* CLI smoke test for `o2b brain synthesise` (v0.10.17).
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-telegram-capture.test.ts b/tests/cli/brain-telegram-capture.test.ts
index 4aceffb3..49556d31 100644
--- a/tests/cli/brain-telegram-capture.test.ts
+++ b/tests/cli/brain-telegram-capture.test.ts
@@ -8,13 +8,17 @@
* injected transport.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { writeCaptureNote } from "../../src/core/brain/capture/capture-note.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-temporal-cli.test.ts b/tests/cli/brain-temporal-cli.test.ts
index b03c8fa0..0c95e5e2 100644
--- a/tests/cli/brain-temporal-cli.test.ts
+++ b/tests/cli/brain-temporal-cli.test.ts
@@ -5,12 +5,16 @@
* and that bad inputs surface as non-zero exit codes.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-tension.test.ts b/tests/cli/brain-tension.test.ts
index 5f11b061..7a40d8c3 100644
--- a/tests/cli/brain-tension.test.ts
+++ b/tests/cli/brain-tension.test.ts
@@ -3,7 +3,7 @@
* suite, S2, t_0e3f2bee).
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -11,6 +11,10 @@ import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { persistTension } from "../../src/core/brain/tensions.ts";
import type { NoteContradictionFinding } from "../../src/core/brain/health/contradiction.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let configDir: string;
diff --git a/tests/cli/brain-tiers.test.ts b/tests/cli/brain-tiers.test.ts
index e786d87d..3dda3a33 100644
--- a/tests/cli/brain-tiers.test.ts
+++ b/tests/cli/brain-tiers.test.ts
@@ -5,7 +5,7 @@
* snapshot baseline.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -13,6 +13,10 @@ import { join } from "node:path";
import { indexVault } from "../../src/core/search/indexer.ts";
import { resolveSearchConfig } from "../../src/core/search/index.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-timezone.test.ts b/tests/cli/brain-timezone.test.ts
index b4ec1c22..056a0c89 100644
--- a/tests/cli/brain-timezone.test.ts
+++ b/tests/cli/brain-timezone.test.ts
@@ -6,13 +6,17 @@
* timestamps inside every envelope remain canonical UTC.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { runCli, type RunResult } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-today.test.ts b/tests/cli/brain-today.test.ts
index 2a66b19c..a67eb0e8 100644
--- a/tests/cli/brain-today.test.ts
+++ b/tests/cli/brain-today.test.ts
@@ -12,12 +12,16 @@
* tests/core/brain/marker-writeback.test.ts.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-trigger.test.ts b/tests/cli/brain-trigger.test.ts
index bc1c90dd..cd9f6534 100644
--- a/tests/cli/brain-trigger.test.ts
+++ b/tests/cli/brain-trigger.test.ts
@@ -8,7 +8,7 @@
* suppressed summary, the usage string and the verb routing.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -18,6 +18,10 @@ import { writePreference } from "../../src/core/brain/preference.ts";
import { BRAIN_PREFERENCE_STATUS } from "../../src/core/brain/types.ts";
import type { InsightCandidate, TriggerRecord } from "../../src/core/brain/triggers/types.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-truth.test.ts b/tests/cli/brain-truth.test.ts
index f9fd006b..821d99b3 100644
--- a/tests/cli/brain-truth.test.ts
+++ b/tests/cli/brain-truth.test.ts
@@ -5,7 +5,7 @@
* decomposition with optional ledger ingest.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -14,6 +14,10 @@ import { appendClaimEvent, readClaimEvents } from "../../src/core/brain/truth/st
import { upsertEntity } from "../../src/core/brain/entities/registry.ts";
import { emitContextReceipt } from "../../src/core/brain/context-receipts.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-unlinked-cli.test.ts b/tests/cli/brain-unlinked-cli.test.ts
index 3e625dca..eee99570 100644
--- a/tests/cli/brain-unlinked-cli.test.ts
+++ b/tests/cli/brain-unlinked-cli.test.ts
@@ -2,12 +2,16 @@
* CLI smoke test for `o2b brain unlinked` (v0.10.17).
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-upgrade.test.ts b/tests/cli/brain-upgrade.test.ts
index d2e51d76..ca9863a0 100644
--- a/tests/cli/brain-upgrade.test.ts
+++ b/tests/cli/brain-upgrade.test.ts
@@ -7,7 +7,7 @@
* stdout shape, and (for `--apply`) post-state on disk.
*/
-import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, spyOn, test } from "bun:test";
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -16,6 +16,10 @@ import { cmdBrainUpgrade } from "../../src/cli/brain/verbs/upgrade.ts";
import * as upgradeModule from "../../src/core/brain/upgrade.ts";
import type { UpgradePlan } from "../../src/core/brain/upgrade.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-validate.test.ts b/tests/cli/brain-validate.test.ts
index 6c0567b2..43e743dd 100644
--- a/tests/cli/brain-validate.test.ts
+++ b/tests/cli/brain-validate.test.ts
@@ -22,13 +22,17 @@
* row (so the derived help surfaces list it).
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { execFileSync } from "node:child_process";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const CLEAN_PAGE = "---\ntitle: Clean\n---\n\nplain prose\n";
const ERROR_PAGE = "no frontmatter here\n";
diff --git a/tests/cli/brain-vitals.test.ts b/tests/cli/brain-vitals.test.ts
index 57626721..b19e0381 100644
--- a/tests/cli/brain-vitals.test.ts
+++ b/tests/cli/brain-vitals.test.ts
@@ -5,7 +5,7 @@
* `vault_vitals` metric.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -14,6 +14,10 @@ import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { writePreference } from "../../src/core/brain/preference.ts";
import { listMetrics } from "../../src/core/brain/metrics.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
diff --git a/tests/cli/brain-watchdog.test.ts b/tests/cli/brain-watchdog.test.ts
index 79e2a4ec..51a652e8 100644
--- a/tests/cli/brain-watchdog.test.ts
+++ b/tests/cli/brain-watchdog.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -6,6 +6,10 @@ import { join } from "node:path";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { brainDirs } from "../../src/core/brain/paths.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-writes-destinations.test.ts b/tests/cli/brain-writes-destinations.test.ts
index cf10f41e..c3ab3c21 100644
--- a/tests/cli/brain-writes-destinations.test.ts
+++ b/tests/cli/brain-writes-destinations.test.ts
@@ -5,7 +5,7 @@
* here never writes.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -14,6 +14,10 @@ import { appendLogEvent } from "../../src/core/brain/log.ts";
import { WRITE_DESTINATION_COVERAGE_NOTE } from "../../src/core/brain/notes/write-destinations.ts";
import { BRAIN_LOG_EVENT_KIND } from "../../src/core/brain/types.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain-writes.test.ts b/tests/cli/brain-writes.test.ts
index 298bb236..f096f2dc 100644
--- a/tests/cli/brain-writes.test.ts
+++ b/tests/cli/brain-writes.test.ts
@@ -6,7 +6,7 @@
* place a wrong verb in the output would cost real bytes.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
@@ -18,6 +18,10 @@ import { writeImagePath } from "../../src/core/brain/paths.ts";
import { BRAIN_LOG_EVENT_KIND } from "../../src/core/brain/types.ts";
import { runCli } from "../helpers/run-cli.ts";
import { splitPosixShellWords } from "../helpers/posix-shell-words.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain.snapshot-diff.test.ts b/tests/cli/brain.snapshot-diff.test.ts
index 4e728d93..229674dd 100644
--- a/tests/cli/brain.snapshot-diff.test.ts
+++ b/tests/cli/brain.snapshot-diff.test.ts
@@ -8,12 +8,16 @@
* markdown / JSON output channels.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain.snapshot-log.test.ts b/tests/cli/brain.snapshot-log.test.ts
index 69cf1b50..5860eb0e 100644
--- a/tests/cli/brain.snapshot-log.test.ts
+++ b/tests/cli/brain.snapshot-log.test.ts
@@ -15,7 +15,7 @@
* of the nine.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { chmodSync, mkdtempSync, rmSync, symlinkSync, utimesSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -28,6 +28,10 @@ import { BRAIN_SNAPSHOT_REASON } from "../../src/core/brain/types.ts";
import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { CHMOD_CANNOT_DENY } from "../helpers/platform.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain.test.ts b/tests/cli/brain.test.ts
index c88c8b45..ae0b9e4b 100644
--- a/tests/cli/brain.test.ts
+++ b/tests/cli/brain.test.ts
@@ -17,7 +17,7 @@
* renderers.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -35,6 +35,10 @@ import { runCli } from "../helpers/run-cli.ts";
import { listLogDates, readLogDay } from "../../src/core/brain/log-jsonl.ts";
import { regenerateActive } from "../../src/core/brain/active.ts";
import { hookAuditDir } from "../../src/core/brain/paths.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/brain/verbs/receipts.test.ts b/tests/cli/brain/verbs/receipts.test.ts
index 47035d87..258885a6 100644
--- a/tests/cli/brain/verbs/receipts.test.ts
+++ b/tests/cli/brain/verbs/receipts.test.ts
@@ -10,7 +10,7 @@
* same closed tuple, so the two surfaces cannot drift.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -32,6 +32,10 @@ import { RECEIPT_TOOLS } from "../../../../src/mcp/brain/receipt-tools.ts";
import { atomicWriteFileSync } from "../../../../src/core/fs-atomic.ts";
import { runCli } from "../../../helpers/run-cli.ts";
import { digestVaultTree } from "../../../helpers/vault-digest.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** The ledger month the fixtures write; safely past any fold cutoff. */
const LEDGER_MONTH = "2026-08";
diff --git a/tests/cli/brain/verbs/storage.test.ts b/tests/cli/brain/verbs/storage.test.ts
index 099e1102..dbbbf441 100644
--- a/tests/cli/brain/verbs/storage.test.ts
+++ b/tests/cli/brain/verbs/storage.test.ts
@@ -17,7 +17,15 @@
* answer as an empty vault.
*/
-import { afterEach, beforeEach, describe, expect, setSystemTime, test } from "bun:test";
+import {
+ afterEach,
+ beforeEach,
+ describe,
+ expect,
+ setDefaultTimeout,
+ setSystemTime,
+ test,
+} from "bun:test";
import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -40,6 +48,10 @@ import { measureStorageUsage } from "../../../../src/core/brain/storage/usage.ts
import { atomicWriteFileSync } from "../../../../src/core/fs-atomic.ts";
import { runCli } from "../../../helpers/run-cli.ts";
import { CHMOD_CANNOT_DENY } from "../../../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
let configHome: string;
diff --git a/tests/cli/completions.test.ts b/tests/cli/completions.test.ts
index c3443b01..ab43293e 100644
--- a/tests/cli/completions.test.ts
+++ b/tests/cli/completions.test.ts
@@ -1,8 +1,12 @@
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { nestedCommandGroups } from "../../src/cli/command-manifest.ts";
import { renderCompletions } from "../../src/cli/completions.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
describe("CLI command manifest", () => {
test("help --json lists root commands, nested verbs, and inherited json flag", async () => {
diff --git a/tests/cli/config-unreadable-verbs.test.ts b/tests/cli/config-unreadable-verbs.test.ts
index 1bafd728..0e93ce98 100644
--- a/tests/cli/config-unreadable-verbs.test.ts
+++ b/tests/cli/config-unreadable-verbs.test.ts
@@ -16,13 +16,17 @@
* reason the `*Safe` readers exist.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { brainConfigPath } from "../../src/core/brain/paths.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** Parses as YAML, fails validation, in a block neither verb reads. */
const BROKEN_CONFIG = `schema_version: 1\ndream:\n candidate_threshold: 0\n`;
diff --git a/tests/cli/context-receipts-verify-cli.test.ts b/tests/cli/context-receipts-verify-cli.test.ts
index 6583fe32..479c93ee 100644
--- a/tests/cli/context-receipts-verify-cli.test.ts
+++ b/tests/cli/context-receipts-verify-cli.test.ts
@@ -12,13 +12,17 @@
* what the verb module's own router answers.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { emitContextReceipt } from "../../src/core/brain/context-receipts.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const PAGE_BODY = "Prefer terse answers over long preambles.\n";
diff --git a/tests/cli/continuity-export-redaction.test.ts b/tests/cli/continuity-export-redaction.test.ts
index 42cb2fe6..c9392765 100644
--- a/tests/cli/continuity-export-redaction.test.ts
+++ b/tests/cli/continuity-export-redaction.test.ts
@@ -24,7 +24,7 @@
* this test seeds, deliberately, by writing the store file directly.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
import { writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -33,6 +33,10 @@ import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { REDACTION_PLACEHOLDER, MAX_REDACTOR_INPUT } from "../../src/core/redactor.ts";
import { fakeCredential } from "../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const VENDOR_TOKEN = "sk-live-CONTINUITY1111";
const BARE_TOKEN = fakeCredential("Zq7Xb2Kd9Lm4", "Np6Rt8Vw1Yc7");
diff --git a/tests/cli/decision-model-advisory-verbs.test.ts b/tests/cli/decision-model-advisory-verbs.test.ts
index 8a0e8b2d..e3138fc3 100644
--- a/tests/cli/decision-model-advisory-verbs.test.ts
+++ b/tests/cli/decision-model-advisory-verbs.test.ts
@@ -4,7 +4,16 @@
* off and enforced against a loopback fake server.
*/
-import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from "bun:test";
+import {
+ afterAll,
+ afterEach,
+ beforeAll,
+ beforeEach,
+ describe,
+ expect,
+ setDefaultTimeout,
+ test,
+} from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -15,6 +24,10 @@ import { FAKE_DECISION_KEY } from "../helpers/fake-credentials.ts";
import { choiceReply } from "../helpers/fake-choice-decision.ts";
import { startFakeSystemOne, type FakeSystemOne } from "../helpers/fake-decision-provider.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const KEY_VAR = "O2B_TEST_DECISION_CLI_KEY";
let server: FakeSystemOne;
diff --git a/tests/cli/decision-model-eval.test.ts b/tests/cli/decision-model-eval.test.ts
index b35268ff..65a8acb2 100644
--- a/tests/cli/decision-model-eval.test.ts
+++ b/tests/cli/decision-model-eval.test.ts
@@ -9,7 +9,16 @@
* the cached grade records and skips malformed ones with a named note.
*/
-import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from "bun:test";
+import {
+ afterAll,
+ afterEach,
+ beforeAll,
+ beforeEach,
+ describe,
+ expect,
+ setDefaultTimeout,
+ test,
+} from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -22,6 +31,10 @@ import {
import { FAKE_DECISION_KEY } from "../helpers/fake-credentials.ts";
import { startFakeSystemOne, type FakeSystemOne } from "../helpers/fake-decision-provider.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const KEY_VAR = "O2B_TEST_DECISION_EVAL_KEY";
diff --git a/tests/cli/decision-model-report-uses.test.ts b/tests/cli/decision-model-report-uses.test.ts
index 4be9e720..8d991d07 100644
--- a/tests/cli/decision-model-report-uses.test.ts
+++ b/tests/cli/decision-model-report-uses.test.ts
@@ -4,7 +4,7 @@
* ledger and on a ledger with one record per use, in JSON and text.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -15,6 +15,10 @@ import {
} from "../../src/core/decision-model/contract.ts";
import { emitDecisionModelCall } from "../../src/core/decision-model/record.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/decision-model-thresholds.test.ts b/tests/cli/decision-model-thresholds.test.ts
index e35fd9e7..2a8298c1 100644
--- a/tests/cli/decision-model-thresholds.test.ts
+++ b/tests/cli/decision-model-thresholds.test.ts
@@ -6,7 +6,7 @@
* vault's continuity log. No network, no credentials.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -24,6 +24,10 @@ import {
} from "../../src/core/decision-model/thresholds.ts";
import { emitDecisionModelCall } from "../../src/core/decision-model/record.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const KEY_VAR = "O2B_TEST_THR_CLI_KEY";
const MODEL = "self-hosted-cli-1";
diff --git a/tests/cli/decision-model.test.ts b/tests/cli/decision-model.test.ts
index a42e9b70..881f305f 100644
--- a/tests/cli/decision-model.test.ts
+++ b/tests/cli/decision-model.test.ts
@@ -4,7 +4,16 @@
* missing key; it names the variable and never prints its value.
*/
-import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from "bun:test";
+import {
+ afterAll,
+ afterEach,
+ beforeAll,
+ beforeEach,
+ describe,
+ expect,
+ setDefaultTimeout,
+ test,
+} from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -18,6 +27,10 @@ import {
type FakeSystemOne,
} from "../helpers/fake-decision-provider.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const KEY_VAR = "O2B_TEST_DECISION_CLI_KEY";
diff --git a/tests/cli/discipline-install.test.ts b/tests/cli/discipline-install.test.ts
index dd32a27c..49e7b9ac 100644
--- a/tests/cli/discipline-install.test.ts
+++ b/tests/cli/discipline-install.test.ts
@@ -10,13 +10,17 @@
* takes the environment and the home directory as arguments.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { HermesJobsPathError, resolveJobsFilePath } from "../../src/cli/discipline-install.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const CLI_ENTRY = join(import.meta.dir, "..", "..", "src", "cli", "main.ts");
const NO_HOME_PRELOAD = join(import.meta.dir, "..", "fixtures", "discipline-install", "no-home.ts");
diff --git a/tests/cli/discipline-report.test.ts b/tests/cli/discipline-report.test.ts
index edeb5b56..ad8a8f6d 100644
--- a/tests/cli/discipline-report.test.ts
+++ b/tests/cli/discipline-report.test.ts
@@ -6,12 +6,16 @@
* 2. Disabled config — enabled: false → exit 0, stderr contains "disabled"
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/distill-trust-lane.test.ts b/tests/cli/distill-trust-lane.test.ts
index 69a30651..7f5e21db 100644
--- a/tests/cli/distill-trust-lane.test.ts
+++ b/tests/cli/distill-trust-lane.test.ts
@@ -33,7 +33,7 @@
* becoming understated.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -42,6 +42,10 @@ import { runCli } from "../helpers/run-cli.ts";
import { DISTILL_TOOLS } from "../../src/mcp/brain/distill-tools.ts";
import { resolveSearchConfig } from "../../src/core/search/index.ts";
import { UNTRUSTED_SOURCE_FRONTMATTER_KEY } from "../../src/core/brain/trust/untrusted-provenance.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** The config key an operator sets to mount the retrieval trust gate. */
const TRUST_GATE_CONFIG_KEY = "search_trust_gate_enabled";
diff --git a/tests/cli/doctor-selftest.test.ts b/tests/cli/doctor-selftest.test.ts
index 1f47651c..d24a904a 100644
--- a/tests/cli/doctor-selftest.test.ts
+++ b/tests/cli/doctor-selftest.test.ts
@@ -14,7 +14,7 @@
* not move a single write outside the throwaway directory.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -36,6 +36,10 @@ import {
} from "../../src/core/doctor-selftest.ts";
import { SearchError } from "../../src/core/search/search-error.ts";
import { runCli, type RunResult } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let sandbox: string;
let canaryVault: string;
diff --git a/tests/cli/export-identifier-integrity.test.ts b/tests/cli/export-identifier-integrity.test.ts
index 57ccaa10..dddbdfdd 100644
--- a/tests/cli/export-identifier-integrity.test.ts
+++ b/tests/cli/export-identifier-integrity.test.ts
@@ -35,7 +35,7 @@
* identifies is never an acceptable answer.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -44,6 +44,10 @@ import { runCli } from "../helpers/run-cli.ts";
import { EGRESS_OUTCOME, redactForEgress } from "../../src/core/egress/guard.ts";
import { REDACTION_PLACEHOLDER } from "../../src/core/redactor.ts";
import { FAKE_VENDOR_KEY } from "../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** A vendor-prefixed credential token: caught by shape, not by a word list. */
const VENDOR_TOKEN = FAKE_VENDOR_KEY;
diff --git a/tests/cli/export-redaction.test.ts b/tests/cli/export-redaction.test.ts
index dc6144b8..3faadd3c 100644
--- a/tests/cli/export-redaction.test.ts
+++ b/tests/cli/export-redaction.test.ts
@@ -34,7 +34,7 @@
* unit exists to stop making.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -46,6 +46,10 @@ import { exportPreferencesLlmsTxt } from "../../src/core/brain/export.ts";
import { REDACTION_PLACEHOLDER } from "../../src/core/redactor.ts";
import { EGRESS_OUTCOME, redactForEgress } from "../../src/core/egress/guard.ts";
import { FAKE_VENDOR_KEY } from "../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** A vendor-prefixed credential token: caught by shape, not by a word list. */
const VENDOR_TOKEN = FAKE_VENDOR_KEY;
diff --git a/tests/cli/forward-pointer-rail.test.ts b/tests/cli/forward-pointer-rail.test.ts
index f3a55c77..918b4714 100644
--- a/tests/cli/forward-pointer-rail.test.ts
+++ b/tests/cli/forward-pointer-rail.test.ts
@@ -48,7 +48,7 @@
* rail.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, relative } from "node:path";
@@ -57,6 +57,10 @@ import { DIAGNOSTIC_SIGNALS } from "../../src/core/brain/diagnostics.ts";
import { resolveNextStep } from "../../src/core/brain/next-step.ts";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const REPO_ROOT = join(import.meta.dir, "..", "..");
const CLI_ROOT = join(REPO_ROOT, "src", "cli");
diff --git a/tests/cli/frontmatter-notices.test.ts b/tests/cli/frontmatter-notices.test.ts
index a91e2ead..e5f209b1 100644
--- a/tests/cli/frontmatter-notices.test.ts
+++ b/tests/cli/frontmatter-notices.test.ts
@@ -5,13 +5,17 @@
* the previous release (the new keys are conditional, never empty).
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { writeVaultIdentity } from "../../src/core/brain/vault-identity.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/help-surface-parity.test.ts b/tests/cli/help-surface-parity.test.ts
index d47554f4..79558c3a 100644
--- a/tests/cli/help-surface-parity.test.ts
+++ b/tests/cli/help-surface-parity.test.ts
@@ -18,7 +18,7 @@
* fail here.
*/
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import {
manifestForJson,
@@ -26,6 +26,10 @@ import {
type CliRootManifest,
} from "../../src/cli/command-manifest.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** ` <path> <summary>` - two-space indent, two-or-more-space gutter. */
const ENTRY_RE = /^ {2}(\S(?:.*?\S)?) {2,}(\S.*)$/;
diff --git a/tests/cli/import-session-roles.test.ts b/tests/cli/import-session-roles.test.ts
index cfbd811f..38ba8d01 100644
--- a/tests/cli/import-session-roles.test.ts
+++ b/tests/cli/import-session-roles.test.ts
@@ -4,12 +4,16 @@
* set; an explicit flag always wins.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/init-no-vault.test.ts b/tests/cli/init-no-vault.test.ts
index 5686b517..3da1c885 100644
--- a/tests/cli/init-no-vault.test.ts
+++ b/tests/cli/init-no-vault.test.ts
@@ -3,7 +3,7 @@
* D14 items 1 and 8, task 2.10): init creates the store and nothing else,
* a second run finds it, and the onboarding checklist walks the store.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -17,6 +17,10 @@ import {
} from "../../src/core/vault-adapter/vault-binding.ts";
import { readPartition } from "../../src/core/store/state-digest.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let parent: string;
let configPath: string;
diff --git a/tests/cli/install-json-shape.test.ts b/tests/cli/install-json-shape.test.ts
index 03e9f9d0..6baf1d42 100644
--- a/tests/cli/install-json-shape.test.ts
+++ b/tests/cli/install-json-shape.test.ts
@@ -23,13 +23,17 @@
* rename a deliberate act rather than an accident.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { INSTALL_JSON_SCHEMA_VERSION } from "../../src/cli/install/render.ts";
import { runCli as baseRunCli, type RunCliOptions, type RunResult } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
// Same reason as `install-verb.test.ts`: the adapters resolve the home
// directory at module-load time, so each call needs a fresh process to
diff --git a/tests/cli/install-ownership-close.test.ts b/tests/cli/install-ownership-close.test.ts
index 70015b0c..941e9023 100644
--- a/tests/cli/install-ownership-close.test.ts
+++ b/tests/cli/install-ownership-close.test.ts
@@ -14,12 +14,16 @@
* surface and not the other, which is exactly how the two drifted before.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli as baseRunCli, type RunCliOptions, type RunResult } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
function runCli(args: ReadonlyArray<string>, opts: RunCliOptions = {}): Promise<RunResult> {
return baseRunCli(args, { ...opts, subprocess: true });
diff --git a/tests/cli/install-vault-resolution.test.ts b/tests/cli/install-vault-resolution.test.ts
index b73e92b5..05ff0b60 100644
--- a/tests/cli/install-vault-resolution.test.ts
+++ b/tests/cli/install-vault-resolution.test.ts
@@ -16,7 +16,7 @@
* chain fails this file instead of silently re-opening the divergence.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -24,6 +24,10 @@ import { join } from "node:path";
import { resolveInstallVault } from "../../src/cli/install/install.ts";
import { resolveVault } from "../../src/core/config.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let configVault: string;
let envVault: string;
diff --git a/tests/cli/interrupt-observability.test.ts b/tests/cli/interrupt-observability.test.ts
index fb89cff8..4e83250f 100644
--- a/tests/cli/interrupt-observability.test.ts
+++ b/tests/cli/interrupt-observability.test.ts
@@ -25,7 +25,7 @@
* which may be aimed at the test runner itself.
*/
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
@@ -35,6 +35,10 @@ import { interruptIsObservable, onInterrupt } from "../../src/cli/interrupt.ts";
import { OPERATION, type Operation } from "../../src/core/brain/safeguard.ts";
import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const SRC = resolve(import.meta.dir, "..", "..", "src");
diff --git a/tests/cli/json-next-command.test.ts b/tests/cli/json-next-command.test.ts
index 3914f8be..6f39f429 100644
--- a/tests/cli/json-next-command.test.ts
+++ b/tests/cli/json-next-command.test.ts
@@ -19,7 +19,7 @@
* one looks like success.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -29,6 +29,10 @@ import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { writeCaptureNote } from "../../src/core/brain/capture/capture-note.ts";
import { writeSignal } from "../../src/core/brain/signal.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/links-verb.test.ts b/tests/cli/links-verb.test.ts
index 1738da72..fafc52bf 100644
--- a/tests/cli/links-verb.test.ts
+++ b/tests/cli/links-verb.test.ts
@@ -3,12 +3,16 @@
* CLI surface over the wikilink format kernel.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/maintenance-cron.test.ts b/tests/cli/maintenance-cron.test.ts
index 7899bfb0..0fadb00b 100644
--- a/tests/cli/maintenance-cron.test.ts
+++ b/tests/cli/maintenance-cron.test.ts
@@ -13,7 +13,7 @@
* after and requires them to be the same.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { chmodSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -27,6 +27,10 @@ import {
renderMaintenanceCronTemplate,
} from "../../src/cli/maintenance-cron.ts";
import { IS_WINDOWS } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** The heredoc body: the script exactly as the operator's host will run it. */
function scriptBody(out: string): string {
diff --git a/tests/cli/manifest-completeness.test.ts b/tests/cli/manifest-completeness.test.ts
index 38a51ab5..7d20ca71 100644
--- a/tests/cli/manifest-completeness.test.ts
+++ b/tests/cli/manifest-completeness.test.ts
@@ -28,7 +28,7 @@
* only way to reach the codegraph resync recipe at all.
*/
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { readFileSync } from "node:fs";
import { join } from "node:path";
@@ -40,6 +40,10 @@ import {
} from "../../src/cli/command-manifest.ts";
import { renderCompletions } from "../../src/cli/completions.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const CLI_ROOT = join(import.meta.dir, "..", "..", "src", "cli");
diff --git a/tests/cli/mcp-fault-guard-spawn.test.ts b/tests/cli/mcp-fault-guard-spawn.test.ts
index 82c45baf..4bd9dc4a 100644
--- a/tests/cli/mcp-fault-guard-spawn.test.ts
+++ b/tests/cli/mcp-fault-guard-spawn.test.ts
@@ -12,13 +12,17 @@
* directory, so no product code they run reaches the operator's config.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { EXIT_INTERNAL_FAULT, FAULT_KIND } from "../../src/cli/mcp-fault-guard.ts";
import { IS_WINDOWS, homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const REPO_ROOT = join(import.meta.dir, "../..");
const FIXTURES = join(import.meta.dir, "../fixtures/mcp-fault-guard");
diff --git a/tests/cli/mcp-harness-flag.test.ts b/tests/cli/mcp-harness-flag.test.ts
index 836f9549..bd75ea09 100644
--- a/tests/cli/mcp-harness-flag.test.ts
+++ b/tests/cli/mcp-harness-flag.test.ts
@@ -1,7 +1,7 @@
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
-import { afterAll, beforeAll, describe, expect, test } from "bun:test";
+import { afterAll, beforeAll, describe, expect, setDefaultTimeout, test } from "bun:test";
import { HARNESS_IDS } from "../../src/core/brain/scoped-rules.ts";
import { writeVaultPointer } from "../../src/core/brain/portability/pointer.ts";
import { MCPServer } from "../../src/mcp/server.ts";
@@ -9,6 +9,10 @@ import { homeEnv } from "../helpers/platform.ts";
import { waitForSelfHealChildren } from "../helpers/self-heal-children.ts";
import { tempDirs } from "../helpers/temp-dir.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** Whole tokens: `copilot-cli` contains `pi`, so containment over ids lies. */
function tokensOf(text: string): ReadonlySet<string> {
diff --git a/tests/cli/mcp-scope-arg.test.ts b/tests/cli/mcp-scope-arg.test.ts
index 22b4d234..a07fb1f7 100644
--- a/tests/cli/mcp-scope-arg.test.ts
+++ b/tests/cli/mcp-scope-arg.test.ts
@@ -1,10 +1,14 @@
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
-import { afterAll, beforeAll, describe, expect, test } from "bun:test";
+import { afterAll, beforeAll, describe, expect, setDefaultTimeout, test } from "bun:test";
import { runCli } from "../helpers/run-cli.ts";
import { INSTALL_TARGET_IDS, RUNTIME_FACTS } from "../../src/core/runtime/host-facts.ts";
import { fakeCredential } from "../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const ENV_SUPPLIED_KEY = fakeCredential("env-", "supplied-key");
diff --git a/tests/cli/mcp-token.test.ts b/tests/cli/mcp-token.test.ts
index c94c2571..474d3ad0 100644
--- a/tests/cli/mcp-token.test.ts
+++ b/tests/cli/mcp-token.test.ts
@@ -9,7 +9,7 @@
* literal here is assembled by `fakeCredential`.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -17,6 +17,10 @@ import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { fakeCredential } from "../helpers/fake-credentials.ts";
import { listAgentTokens, resolveAgentForToken } from "../../src/core/brain/secrets/token-store.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
diff --git a/tests/cli/mcp-writer-probe.test.ts b/tests/cli/mcp-writer-probe.test.ts
index 3cbd1797..bd877f01 100644
--- a/tests/cli/mcp-writer-probe.test.ts
+++ b/tests/cli/mcp-writer-probe.test.ts
@@ -1,8 +1,12 @@
-import { describe, expect, test, beforeAll, afterAll } from "bun:test";
+import { afterAll, beforeAll, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
describe("o2b mcp --writer-only alias", () => {
test("--writer-only without --scope sets scope=writer", async () => {
diff --git a/tests/cli/no-vault-memory.test.ts b/tests/cli/no-vault-memory.test.ts
index 888158c1..26b27ed0 100644
--- a/tests/cli/no-vault-memory.test.ts
+++ b/tests/cli/no-vault-memory.test.ts
@@ -5,7 +5,7 @@
* `o2b search` finds the records. A second machine sharing the store sees
* them once its own index catches up.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, readdirSync } from "node:fs";
import { join } from "node:path";
@@ -16,6 +16,10 @@ import {
import { forgetMachineStateCache } from "../../src/core/state/machine-state.ts";
import { runCli } from "../helpers/run-cli.ts";
import { makeStoreEnv, type StoreEnv } from "../core/store/fixtures/store-env.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let env: StoreEnv | null = null;
afterEach(() => {
diff --git a/tests/cli/no-vault.test.ts b/tests/cli/no-vault.test.ts
index 91d96baf..a6b9578d 100644
--- a/tests/cli/no-vault.test.ts
+++ b/tests/cli/no-vault.test.ts
@@ -5,7 +5,7 @@
* store, and a verb that needs a vault refuses. The verb-named refusals of
* the brain verbs are owned by `no-vault-memory.test.ts`.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -13,6 +13,10 @@ import { join } from "node:path";
import { brainVerbContext } from "../../src/cli/brain/helpers.ts";
import { CliError } from "../../src/cli/argparse.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let parent: string;
let configPath: string;
diff --git a/tests/cli/o2b-mcp-launcher.test.ts b/tests/cli/o2b-mcp-launcher.test.ts
index 21c50217..ec17eb7e 100644
--- a/tests/cli/o2b-mcp-launcher.test.ts
+++ b/tests/cli/o2b-mcp-launcher.test.ts
@@ -1,9 +1,13 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import pkg from "../../package.json" with { type: "json" };
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
diff --git a/tests/cli/okf-cli.test.ts b/tests/cli/okf-cli.test.ts
index ac26d80b..7194cc8c 100644
--- a/tests/cli/okf-cli.test.ts
+++ b/tests/cli/okf-cli.test.ts
@@ -5,7 +5,7 @@
* own unit coverage in tests/core/brain/portability/okf.test.ts.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { chmodSync, existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -18,6 +18,10 @@ import { switchDevice } from "../core/brain/store-only/fixtures.ts";
import { CHMOD_CANNOT_DENY } from "../helpers/platform.ts";
import { logShardsOf } from "../core/store/fixtures/log-shards.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/partner-codegraph-resync.test.ts b/tests/cli/partner-codegraph-resync.test.ts
index d87e3c58..ea351348 100644
--- a/tests/cli/partner-codegraph-resync.test.ts
+++ b/tests/cli/partner-codegraph-resync.test.ts
@@ -14,7 +14,7 @@
* exited zero would be a gate that passes what it could not read.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -23,6 +23,10 @@ import { CronTemplateError } from "../../src/cli/cron-recipe.ts";
import { renderCodegraphResyncTemplate } from "../../src/cli/partner-codegraph-cron.ts";
import { IS_WINDOWS } from "../helpers/platform.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
diff --git a/tests/cli/partner-codegraph.test.ts b/tests/cli/partner-codegraph.test.ts
index 06825de2..9c2cc209 100644
--- a/tests/cli/partner-codegraph.test.ts
+++ b/tests/cli/partner-codegraph.test.ts
@@ -8,12 +8,16 @@
* workspace parse and the report envelope, not the CLI-availability field.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
diff --git a/tests/cli/progress-emitter-census.test.ts b/tests/cli/progress-emitter-census.test.ts
index 9b8f5644..e6ae82b3 100644
--- a/tests/cli/progress-emitter-census.test.ts
+++ b/tests/cli/progress-emitter-census.test.ts
@@ -87,7 +87,7 @@
* enclosing-function scan that follows.
*/
-import { beforeAll, afterAll, describe, expect, test } from "bun:test";
+import { afterAll, beforeAll, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, relative, resolve } from "node:path";
@@ -101,6 +101,10 @@ import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { progressRecords } from "../helpers/progress-records.ts";
import { runCli, type RunResult } from "../helpers/run-cli.ts";
import { lexCode } from "../helpers/source-lexer.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const SRC = resolve(import.meta.dir, "..", "..", "src");
diff --git a/tests/cli/project-verb.test.ts b/tests/cli/project-verb.test.ts
index 18b13852..165d193a 100644
--- a/tests/cli/project-verb.test.ts
+++ b/tests/cli/project-verb.test.ts
@@ -3,13 +3,17 @@
* Suite, t_1375e69f): CLI surface over project vault pointers.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { VAULT_POINTER_FILE } from "../../src/core/brain/portability/pointer.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/search-check-integrity.test.ts b/tests/cli/search-check-integrity.test.ts
index 61bdcd39..d440b641 100644
--- a/tests/cli/search-check-integrity.test.ts
+++ b/tests/cli/search-check-integrity.test.ts
@@ -24,7 +24,7 @@
* off, so no provider is constructed and no ping is sent.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { Database } from "bun:sqlite";
import { closeSync, mkdirSync, openSync, statSync, writeSync } from "node:fs";
import { dirname, join } from "node:path";
@@ -38,6 +38,10 @@ import {
} from "../../src/core/search/store/state.ts";
import { createTempVault, makeConfig, writeMd } from "../helpers/search-fixtures.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** The registered exit a structural fault names. */
const INDEX_CORRUPT_CODE = "search-index-corrupt";
diff --git a/tests/cli/search-check-provider.test.ts b/tests/cli/search-check-provider.test.ts
index 2163e5fa..e03b6a47 100644
--- a/tests/cli/search-check-provider.test.ts
+++ b/tests/cli/search-check-provider.test.ts
@@ -38,7 +38,7 @@
* the `recommendations` block (`tests/core/search/check-recommendations.test.ts`).
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { join } from "node:path";
import { INSTALL_EXIT } from "../../src/cli/install/install.ts";
@@ -50,6 +50,10 @@ import { startFakeHttp, type FakeHttp } from "../helpers/fake-http.ts";
import { createTempVault, writeMd } from "../helpers/search-fixtures.ts";
import { runCli } from "../helpers/run-cli.ts";
import { FAKE_PROVIDER_KEY, fakeCredential } from "../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** Short enough for a test, long enough that a healthy loopback answer beats it. */
const SHORT_REQUEST_TIMEOUT_MS = 120;
diff --git a/tests/cli/search-check-visibility-honesty.test.ts b/tests/cli/search-check-visibility-honesty.test.ts
index 766ad6b7..968de2d2 100644
--- a/tests/cli/search-check-visibility-honesty.test.ts
+++ b/tests/cli/search-check-visibility-honesty.test.ts
@@ -25,7 +25,7 @@
* statement, not a fault.
*/
-import { expect, test } from "bun:test";
+import { expect, setDefaultTimeout, test } from "bun:test";
import { runCli } from "../helpers/run-cli.ts";
import { createTempVault, makeConfig, writeMd } from "../helpers/search-fixtures.ts";
@@ -34,6 +34,10 @@ import {
callableVisibilitySurfaces,
excludedCallableVisibilitySurfaces,
} from "../../src/core/search/visibility-surface-registry.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
test("a vault that never uses visibility: renders neither the JSON key nor the human line", async () => {
const { vault, dbPath, cleanup } = createTempVault("check-visibility-honesty-absent");
diff --git a/tests/cli/search-chunk-window-estimate.test.ts b/tests/cli/search-chunk-window-estimate.test.ts
index b609ce8a..db9602ea 100644
--- a/tests/cli/search-chunk-window-estimate.test.ts
+++ b/tests/cli/search-chunk-window-estimate.test.ts
@@ -15,7 +15,7 @@
* undecided band existed.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
@@ -24,6 +24,10 @@ import { requireNextStep } from "../../src/core/brain/next-step.ts";
import { declaredInputWindowTokens } from "../../src/core/search/embeddings/presets.ts";
import { runCli } from "../helpers/run-cli.ts";
import { FAKE_PROVIDER_KEY } from "../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/search-chunk-window.test.ts b/tests/cli/search-chunk-window.test.ts
index 8b12d323..de2f69dd 100644
--- a/tests/cli/search-chunk-window.test.ts
+++ b/tests/cli/search-chunk-window.test.ts
@@ -12,7 +12,7 @@
* here rather than in a consumer.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
@@ -25,6 +25,10 @@ import {
import { charLengthOverTokenBudget } from "../../src/core/search/embeddings/signature.ts";
import { runCli } from "../helpers/run-cli.ts";
import { FAKE_PROVIDER_KEY } from "../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/search-cron-template.test.ts b/tests/cli/search-cron-template.test.ts
index 76e7d85a..42025132 100644
--- a/tests/cli/search-cron-template.test.ts
+++ b/tests/cli/search-cron-template.test.ts
@@ -7,7 +7,7 @@
* subtler edge cases (invalid units, large values).
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, readdirSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -19,6 +19,10 @@ import {
SEARCH_REINDEX_RECIPE,
} from "../../src/cli/search-cron-template.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/**
* The rendered template, captured BEFORE the shared cron-recipe kernel was
diff --git a/tests/cli/search-event-anchor-backfill.test.ts b/tests/cli/search-event-anchor-backfill.test.ts
index bfedf1a2..1e303708 100644
--- a/tests/cli/search-event-anchor-backfill.test.ts
+++ b/tests/cli/search-event-anchor-backfill.test.ts
@@ -18,7 +18,7 @@
* is a pure function of a note's own frontmatter and body.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { Database } from "bun:sqlite";
import { chmodSync, mkdirSync, readFileSync, readdirSync, utimesSync } from "node:fs";
import { join } from "node:path";
@@ -29,6 +29,10 @@ import { indexVault } from "../../src/core/search/indexer.ts";
import { createTempVault, makeConfig, writeMd } from "../helpers/search-fixtures.ts";
import { CHMOD_CANNOT_DENY } from "../helpers/platform.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** The registered exit for an index holding unexamined documents. */
const PENDING_CODE = "event-anchors-pending";
diff --git a/tests/cli/search-explain-overlap.test.ts b/tests/cli/search-explain-overlap.test.ts
index 23610516..fc26c281 100644
--- a/tests/cli/search-explain-overlap.test.ts
+++ b/tests/cli/search-explain-overlap.test.ts
@@ -8,7 +8,7 @@
* zero with the lane not attempted.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -16,6 +16,10 @@ import { join } from "node:path";
import { FAKE_PROVIDER_KEY } from "../helpers/fake-credentials.ts";
import { startFakeHttp, type FakeHttp } from "../helpers/fake-http.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const QUERY = "quick brown fox";
const MODEL = "fake-model";
diff --git a/tests/cli/search-explain-trace.test.ts b/tests/cli/search-explain-trace.test.ts
index 976e8e1d..1dd6647b 100644
--- a/tests/cli/search-explain-trace.test.ts
+++ b/tests/cli/search-explain-trace.test.ts
@@ -8,7 +8,7 @@
* nothing else - no second search, no clock drift, no tolerance.
*/
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -27,6 +27,10 @@ import {
} from "../../src/core/brain/trust/retrieval-receipts.ts";
import type { BrainSearchResult, SearchOutcome } from "../../src/core/search/types.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const QUERY = "widget calibration";
diff --git a/tests/cli/search-feedback-cli.test.ts b/tests/cli/search-feedback-cli.test.ts
index 48285a8e..b757646f 100644
--- a/tests/cli/search-feedback-cli.test.ts
+++ b/tests/cli/search-feedback-cli.test.ts
@@ -3,13 +3,17 @@
* (recall-trust-suite, Feature B).
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { feedbackDir, learnedWeightsPath } from "../../src/core/search/feedback.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/search-index-freshen.test.ts b/tests/cli/search-index-freshen.test.ts
index 4a79b5a0..41e9396d 100644
--- a/tests/cli/search-index-freshen.test.ts
+++ b/tests/cli/search-index-freshen.test.ts
@@ -4,7 +4,7 @@
* after a failure, writes a metric row only when it changed something or
* failed, and releases the claim it was handed in every case.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -20,6 +20,10 @@ import {
} from "../../src/core/search/freshen.ts";
import { acquireWriterLockSync } from "../../src/core/search/store/writer-lock.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/search-index-progress.test.ts b/tests/cli/search-index-progress.test.ts
index 1e014f08..3fed33d4 100644
--- a/tests/cli/search-index-progress.test.ts
+++ b/tests/cli/search-index-progress.test.ts
@@ -9,7 +9,7 @@
* that adding one did not move the other by a byte.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -17,6 +17,10 @@ import { join } from "node:path";
import { OPERATION } from "../../src/core/brain/safeguard.ts";
import { progressRecords, STAGE_IDENTIFIER } from "../helpers/progress-records.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/search-index-reuse.test.ts b/tests/cli/search-index-reuse.test.ts
index 7e08dacf..98dc6581 100644
--- a/tests/cli/search-index-reuse.test.ts
+++ b/tests/cli/search-index-reuse.test.ts
@@ -5,13 +5,17 @@
* payload it emitted before the field existed.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { sqliteVecLoadable } from "../helpers/sqlite-vec.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const VEC_LOADABLE = sqliteVecLoadable();
diff --git a/tests/cli/search-match-mode.test.ts b/tests/cli/search-match-mode.test.ts
index 8ac1af44..a85d096a 100644
--- a/tests/cli/search-match-mode.test.ts
+++ b/tests/cli/search-match-mode.test.ts
@@ -4,13 +4,17 @@
* value outside the pair is refused by name rather than read as the default.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { FTS_MATCH_MODES } from "../../src/core/search/fts-match-mode.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/search-no-vault.test.ts b/tests/cli/search-no-vault.test.ts
index 9c2357bc..039f7020 100644
--- a/tests/cli/search-no-vault.test.ts
+++ b/tests/cli/search-no-vault.test.ts
@@ -5,12 +5,16 @@
* decision-model` and the provider registries. `search index` says it
* indexed the brain store.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { makeStoreEnv, type StoreEnv } from "../core/store/fixtures/store-env.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let env: StoreEnv | null = null;
afterEach(() => {
diff --git a/tests/cli/search-property-cli.test.ts b/tests/cli/search-property-cli.test.ts
index 3e2647d2..d5a9b48a 100644
--- a/tests/cli/search-property-cli.test.ts
+++ b/tests/cli/search-property-cli.test.ts
@@ -7,12 +7,16 @@
* require sqlite-vec.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/search-provider-cli.test.ts b/tests/cli/search-provider-cli.test.ts
index df4469e0..1c4d02ae 100644
--- a/tests/cli/search-provider-cli.test.ts
+++ b/tests/cli/search-provider-cli.test.ts
@@ -5,12 +5,16 @@
* exit codes, JSON shape, and the persisted registry file.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/search-rerank-provider-cli.test.ts b/tests/cli/search-rerank-provider-cli.test.ts
index 58e89485..a8ca927a 100644
--- a/tests/cli/search-rerank-provider-cli.test.ts
+++ b/tests/cli/search-rerank-provider-cli.test.ts
@@ -7,12 +7,16 @@
* usage/output strings and persisted-file path.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/search-restamp.test.ts b/tests/cli/search-restamp.test.ts
index aa7c00ed..799eb37f 100644
--- a/tests/cli/search-restamp.test.ts
+++ b/tests/cli/search-restamp.test.ts
@@ -24,7 +24,7 @@
* 6. No path through the verb contacts an embedding provider.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { Database } from "bun:sqlite";
import { join } from "node:path";
@@ -40,6 +40,10 @@ import { startFakeHttp, type FakeHttp } from "../helpers/fake-http.ts";
import { runCli } from "../helpers/run-cli.ts";
import { sqliteVecLoadable } from "../helpers/sqlite-vec.ts";
import { FAKE_PROVIDER_KEY } from "../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const VEC_LOADABLE = sqliteVecLoadable();
diff --git a/tests/cli/search-status-freshen.test.ts b/tests/cli/search-status-freshen.test.ts
index 2cbe0378..9738682f 100644
--- a/tests/cli/search-status-freshen.test.ts
+++ b/tests/cli/search-status-freshen.test.ts
@@ -6,7 +6,7 @@
* documents the next incremental run would pick up, or "(not measured)"
* when the walk could not run.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -19,6 +19,10 @@ import {
type FreshenStatus,
} from "../../src/core/search/freshen.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/search-vector-backfill-path.test.ts b/tests/cli/search-vector-backfill-path.test.ts
index b5b14876..0500b994 100644
--- a/tests/cli/search-vector-backfill-path.test.ts
+++ b/tests/cli/search-vector-backfill-path.test.ts
@@ -17,7 +17,7 @@
* (search-vector-backfill-price.test.ts).
*/
-import { afterEach, beforeEach, expect, spyOn, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, spyOn, test } from "bun:test";
import { join } from "node:path";
import { indexVault } from "../../src/core/search/indexer.ts";
@@ -35,6 +35,10 @@ import { startFakeHttp, type FakeHttp } from "../helpers/fake-http.ts";
import { runCli } from "../helpers/run-cli.ts";
import { createTempVault, makeConfig, writeMd } from "../helpers/search-fixtures.ts";
import { sqliteVecLoadable } from "../helpers/sqlite-vec.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const VEC_LOADABLE = sqliteVecLoadable();
const BELIEFS = "Brain/preferences/";
diff --git a/tests/cli/search-vector-backfill-price.test.ts b/tests/cli/search-vector-backfill-price.test.ts
index 980614f9..f4c0185e 100644
--- a/tests/cli/search-vector-backfill-price.test.ts
+++ b/tests/cli/search-vector-backfill-price.test.ts
@@ -12,7 +12,7 @@
* mechanics (search-vector-backfill.test.ts) and the plan arithmetic
* (embedding-spend-preview.test.ts).
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { join } from "node:path";
import { indexVault } from "../../src/core/search/indexer.ts";
@@ -22,6 +22,10 @@ import { startFakeHttp } from "../helpers/fake-http.ts";
import { createTempVault, makeConfig, writeMd } from "../helpers/search-fixtures.ts";
import { sqliteVecLoadable } from "../helpers/sqlite-vec.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const VEC_LOADABLE = sqliteVecLoadable();
const UNPRICED_MODEL = "zembed-1";
diff --git a/tests/cli/search-vector-backfill.test.ts b/tests/cli/search-vector-backfill.test.ts
index 2831216f..f186dbc2 100644
--- a/tests/cli/search-vector-backfill.test.ts
+++ b/tests/cli/search-vector-backfill.test.ts
@@ -14,7 +14,7 @@
* fixtures ship; nothing here reaches the network.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { chmodSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -32,6 +32,10 @@ import { sqliteVecLoadable } from "../helpers/sqlite-vec.ts";
import { CHMOD_CANNOT_DENY } from "../helpers/platform.ts";
import { runCli } from "../helpers/run-cli.ts";
import { FAKE_PROVIDER_KEY } from "../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/**
* Whether `sqlite-vec` loaded in THIS process, resolved once at module
diff --git a/tests/cli/search.test.ts b/tests/cli/search.test.ts
index 4caccd40..fa7c5db6 100644
--- a/tests/cli/search.test.ts
+++ b/tests/cli/search.test.ts
@@ -6,13 +6,17 @@
* canonical text patterns, and the JSON shape produced by `--json`.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { LATEST_SCHEMA_VERSION } from "../../src/core/search/schema.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/secret-unlock-nudge.test.ts b/tests/cli/secret-unlock-nudge.test.ts
index b0611194..5b22ca7b 100644
--- a/tests/cli/secret-unlock-nudge.test.ts
+++ b/tests/cli/secret-unlock-nudge.test.ts
@@ -9,13 +9,17 @@
* the operator meets the nudge at the exact moment the wrap begins.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { fakeCredential } from "../helpers/fake-credentials.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/session-discovery.test.ts b/tests/cli/session-discovery.test.ts
index 5adf99dd..90a6ca2e 100644
--- a/tests/cli/session-discovery.test.ts
+++ b/tests/cli/session-discovery.test.ts
@@ -18,7 +18,7 @@
* loosening.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
chmodSync,
existsSync,
@@ -42,6 +42,10 @@ import { sessionMiningSurveysPath } from "../../src/core/brain/session-mining-su
import { CHMOD_CANNOT_DENY } from "../helpers/platform.ts";
import { runCli } from "../helpers/run-cli.ts";
import { fakeCredential } from "../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/sgrep-verb.test.ts b/tests/cli/sgrep-verb.test.ts
index 9631923c..6b537751 100644
--- a/tests/cli/sgrep-verb.test.ts
+++ b/tests/cli/sgrep-verb.test.ts
@@ -3,13 +3,17 @@
* t_323a9a83): shell-native surface CLI tests.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { O2BFS_MARKER_FILE, PROFILE_DOC_REL } from "../../src/core/brain/profile-doc.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/skill-proposals-recover.test.ts b/tests/cli/skill-proposals-recover.test.ts
index c8f1f766..a8415a46 100644
--- a/tests/cli/skill-proposals-recover.test.ts
+++ b/tests/cli/skill-proposals-recover.test.ts
@@ -9,7 +9,7 @@
* exact file on stderr rather than leaving an errno to trace.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
@@ -24,6 +24,10 @@ import {
import { writeSkillAcceptJournal } from "../../src/core/brain/skill-accept-journal.ts";
import { _resetHeldLocksForTests } from "../../src/core/brain/sync-lockfile.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
diff --git a/tests/cli/source-verb.test.ts b/tests/cli/source-verb.test.ts
index e6f03064..5c51f4f8 100644
--- a/tests/cli/source-verb.test.ts
+++ b/tests/cli/source-verb.test.ts
@@ -3,12 +3,16 @@
* t_1375e69f): CLI surface over read-only recall sources.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/state-migrate.test.ts b/tests/cli/state-migrate.test.ts
index 3eaefb71..bf804cd1 100644
--- a/tests/cli/state-migrate.test.ts
+++ b/tests/cli/state-migrate.test.ts
@@ -12,7 +12,7 @@
* supervisor that cannot tell them apart retries the wrong one.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -28,6 +28,10 @@ import { dirname, join } from "node:path";
import { MIGRATION_MANIFEST_FILE, type MigrationPlan } from "../../src/core/state/migrate.ts";
import { STATE_SURFACE_ID, STATE_SURFACES } from "../../src/core/state/surfaces.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const temps: string[] = [];
diff --git a/tests/cli/state-status.test.ts b/tests/cli/state-status.test.ts
index cc22781b..7ac6d723 100644
--- a/tests/cli/state-status.test.ts
+++ b/tests/cli/state-status.test.ts
@@ -7,7 +7,7 @@
* human text, and neither stream is assembled in this layer.
*/
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, writeFileSync } from "node:fs";
import { dirname, join } from "node:path";
@@ -18,6 +18,10 @@ import {
} from "../../src/core/state/surfaces.ts";
import { runCli } from "../helpers/run-cli.ts";
import { tempDirs } from "../helpers/temp-dir.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const mkTemp = tempDirs();
diff --git a/tests/cli/status-store.test.ts b/tests/cli/status-store.test.ts
index efef7839..dd820aa7 100644
--- a/tests/cli/status-store.test.ts
+++ b/tests/cli/status-store.test.ts
@@ -3,7 +3,7 @@
* (design D12, task 2.11): `--json` gains a `store` object, and the human
* output gains one line naming the store root and whether it exists.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -11,6 +11,10 @@ import { join } from "node:path";
import { STORE_ROOT_ENV } from "../../src/core/store/constants.ts";
import { initStore } from "../../src/core/store/store-init.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let parent: string;
let vault: string;
diff --git a/tests/cli/status.test.ts b/tests/cli/status.test.ts
index 3798be81..8b28301c 100644
--- a/tests/cli/status.test.ts
+++ b/tests/cli/status.test.ts
@@ -7,12 +7,16 @@
* `--json` keys.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let cfgDir: string;
let cfgPath: string;
diff --git a/tests/cli/stdin.test.ts b/tests/cli/stdin.test.ts
index cddc6737..6db8bd6c 100644
--- a/tests/cli/stdin.test.ts
+++ b/tests/cli/stdin.test.ts
@@ -7,9 +7,13 @@
* with a real pipe reproduces that, so this spawns one, on every platform.
*/
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawnSync } from "node:child_process";
import { join, resolve } from "node:path";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const STDIN_MODULE = resolve(join(import.meta.dir, "..", "..", "src", "cli", "stdin.ts"));
diff --git a/tests/cli/stdout-epipe-guard.test.ts b/tests/cli/stdout-epipe-guard.test.ts
index 59409fd6..1b4dc8ea 100644
--- a/tests/cli/stdout-epipe-guard.test.ts
+++ b/tests/cli/stdout-epipe-guard.test.ts
@@ -8,10 +8,14 @@
* so guarding that entry covers both CLIs.
*/
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { join } from "node:path";
import { handleStdoutError, isEpipeError } from "../../src/cli/stdout-guard.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const ROOT = join(import.meta.dir, "..", "..");
diff --git a/tests/cli/store-device.test.ts b/tests/cli/store-device.test.ts
index d4588a76..08341145 100644
--- a/tests/cli/store-device.test.ts
+++ b/tests/cli/store-device.test.ts
@@ -4,7 +4,7 @@
* `device-retire` record that takes a gone machine off the digest roster
* and out of the removal gate. This machine's own id is refused.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -16,6 +16,10 @@ import { initStore } from "../../src/core/store/store-init.ts";
import { openStore } from "../../src/core/store/store-open.ts";
import { partitionDir } from "../../src/core/store/store-paths.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let parent: string;
let root: string;
diff --git a/tests/cli/store-init-claim.test.ts b/tests/cli/store-init-claim.test.ts
index e85a4278..9355e18e 100644
--- a/tests/cli/store-init-claim.test.ts
+++ b/tests/cli/store-init-claim.test.ts
@@ -4,13 +4,17 @@
* shared partition takes it, and the JSON answer says whether this
* device's switch was recorded.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { STORE_ROOT_ENV } from "../../src/core/store/constants.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let parent: string;
beforeEach(() => {
diff --git a/tests/cli/store-only-cli-output.test.ts b/tests/cli/store-only-cli-output.test.ts
index 0bd18c04..177f232d 100644
--- a/tests/cli/store-only-cli-output.test.ts
+++ b/tests/cli/store-only-cli-output.test.ts
@@ -4,11 +4,15 @@
* with no vault or refuse by name. An unswitched machine keeps its
* output.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { runCli } from "../helpers/run-cli.ts";
import { brainTreeDigest, switchDevice } from "../core/brain/store-only/fixtures.ts";
import { makeStoreEnv, type StoreEnv } from "../core/store/fixtures/store-env.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let env: StoreEnv | null = null;
afterEach(() => {
diff --git a/tests/cli/store-only-feedback.test.ts b/tests/cli/store-only-feedback.test.ts
index 70eea346..c4a05b41 100644
--- a/tests/cli/store-only-feedback.test.ts
+++ b/tests/cli/store-only-feedback.test.ts
@@ -6,7 +6,7 @@
* the first process remembered; a `Brain/` that appears in the vault
* afterwards does not bring the legacy writer back.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -14,6 +14,10 @@ import { join } from "node:path";
import { readPartition } from "../../src/core/store/state-digest.ts";
import { initStore } from "../../src/core/store/store-init.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let parent: string;
let vault: string;
diff --git a/tests/cli/store-path.test.ts b/tests/cli/store-path.test.ts
index 63519564..9cec4ddb 100644
--- a/tests/cli/store-path.test.ts
+++ b/tests/cli/store-path.test.ts
@@ -5,7 +5,7 @@
* failure (exit 0, naming `o2b store init`, the way `o2b search status`
* treats a missing index); a store root that cannot be used is exit 1.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -14,6 +14,10 @@ import { NEXT_COMMAND_KEY } from "../../src/core/brain/next-step.ts";
import { STORE_ROOT_ENV } from "../../src/core/store/constants.ts";
import { initStore } from "../../src/core/store/store-init.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let parent: string;
let root: string;
diff --git a/tests/cli/terminal-state-census.test.ts b/tests/cli/terminal-state-census.test.ts
index dc67dda8..f9f91d9e 100644
--- a/tests/cli/terminal-state-census.test.ts
+++ b/tests/cli/terminal-state-census.test.ts
@@ -53,11 +53,15 @@
* verb states.
*/
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { readdirSync, readFileSync } from "node:fs";
import { dirname, join, relative, resolve, sep } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const REPO_ROOT = join(import.meta.dir, "..", "..");
const CLI_ROOT = join(REPO_ROOT, "src", "cli");
diff --git a/tests/cli/terminal-states.test.ts b/tests/cli/terminal-states.test.ts
index 9a308a58..dd0697c6 100644
--- a/tests/cli/terminal-states.test.ts
+++ b/tests/cli/terminal-states.test.ts
@@ -14,13 +14,17 @@
* that knows whether stdout is a machine payload.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { DIAGNOSTIC_SIGNALS } from "../../src/core/brain/diagnostics.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const BRAIN_EMPTY_COMMAND = DIAGNOSTIC_SIGNALS.get("brain-empty")!.nextCommand;
const CLUSTERS_ABSENT_COMMAND = DIAGNOSTIC_SIGNALS.get("signal-clusters-absent")!.nextCommand;
diff --git a/tests/cli/vault-portability-cli.test.ts b/tests/cli/vault-portability-cli.test.ts
index beaa2d6b..65225bae 100644
--- a/tests/cli/vault-portability-cli.test.ts
+++ b/tests/cli/vault-portability-cli.test.ts
@@ -5,12 +5,16 @@
* codes; the underlying cores have their own unit coverage.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/vault.test.ts b/tests/cli/vault.test.ts
index 6f3ce612..b8a0b53f 100644
--- a/tests/cli/vault.test.ts
+++ b/tests/cli/vault.test.ts
@@ -5,12 +5,16 @@
* brain CLI tests).
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/cli/version.test.ts b/tests/cli/version.test.ts
index 331c3990..0ec4eeca 100644
--- a/tests/cli/version.test.ts
+++ b/tests/cli/version.test.ts
@@ -13,11 +13,15 @@
* one into a report.
*/
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { OPEN_SECOND_BRAIN_VERSION } from "../../src/core/version.ts";
import { CLI_COMMAND_MANIFEST, allFlagNames } from "../../src/cli/command-manifest.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** The verb under test, and the root flag that is its synonym. */
const VERSION_COMMAND = "version";
diff --git a/tests/cli/view.test.ts b/tests/cli/view.test.ts
index 52a581e5..7802e3a7 100644
--- a/tests/cli/view.test.ts
+++ b/tests/cli/view.test.ts
@@ -4,7 +4,7 @@
* `render` writes the pages only on the writer, and `recover` lists and
* prints replaced versions.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { cpSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -12,6 +12,10 @@ import { join } from "node:path";
import { STORE_ROOT_ENV } from "../../src/core/store/constants.ts";
import { VIEW_TARGET_ENV } from "../../src/core/view/constants.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let parent: string;
beforeEach(() => {
diff --git a/tests/core/brain.init.test.ts b/tests/core/brain.init.test.ts
index b534dc19..0f2180d4 100644
--- a/tests/core/brain.init.test.ts
+++ b/tests/core/brain.init.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -21,6 +21,10 @@ import {
} from "../../src/core/brain/doctor/git-tracked-state-check.ts";
import { DEFAULT_BEGIN_MARKER, DEFAULT_END_MARKER } from "../../src/core/install/managed-block.ts";
import { cmdBrainInit } from "../../src/cli/brain/verbs/init.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
// Shared temp scratch for both vault and machine-config directories.
// Tests that need to assert the "missing machine config" path can
diff --git a/tests/core/brain.note-history.test.ts b/tests/core/brain.note-history.test.ts
index 2651d2e9..efeac07c 100644
--- a/tests/core/brain.note-history.test.ts
+++ b/tests/core/brain.note-history.test.ts
@@ -1,10 +1,14 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { execFileSync } from "node:child_process";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { decomposeNoteHistory } from "../../src/core/brain/note-history.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let repo: string;
diff --git a/tests/core/brain/apply-evidence-key-race.test.ts b/tests/core/brain/apply-evidence-key-race.test.ts
index 5e447834..6d675bb4 100644
--- a/tests/core/brain/apply-evidence-key-race.test.ts
+++ b/tests/core/brain/apply-evidence-key-race.test.ts
@@ -7,7 +7,7 @@
* shared instant, the discipline of `pinned-concurrency.test.ts`.
*/
-import { afterEach, expect, test } from "bun:test";
+import { afterEach, expect, setDefaultTimeout, test } from "bun:test";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
@@ -15,6 +15,10 @@ import { writePreference } from "../../../src/core/brain/preference.ts";
import { readPreferences } from "../../../src/core/store/read/preferences.ts";
import { makeStoreEnv, type StoreEnv } from "../store/fixtures/store-env.ts";
import { switchDevice } from "./store-only/fixtures.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const WRITERS = 4;
const KEYS = 12;
diff --git a/tests/core/brain/architect-concurrent-runs.test.ts b/tests/core/brain/architect-concurrent-runs.test.ts
index 1f29877f..f2db3683 100644
--- a/tests/core/brain/architect-concurrent-runs.test.ts
+++ b/tests/core/brain/architect-concurrent-runs.test.ts
@@ -29,13 +29,17 @@
* would serialize them by accident and pass against the defect.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { generateArchDocs } from "../../../src/core/brain/architect/generate.ts";
import { repoKey } from "../../../src/core/brain/git/identity.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** Enough notes that one run's write loop outlasts another run's plan. */
const MODULES = 40;
diff --git a/tests/core/brain/architect-manifests.test.ts b/tests/core/brain/architect-manifests.test.ts
index 7ff440c8..f107f413 100644
--- a/tests/core/brain/architect-manifests.test.ts
+++ b/tests/core/brain/architect-manifests.test.ts
@@ -3,7 +3,7 @@
* a closed status for every outcome, never a throw on project content.
*/
-import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, spyOn, test } from "bun:test";
import * as fs from "node:fs";
import { chmodSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -17,6 +17,10 @@ import {
} from "../../../src/core/brain/architect/manifests.ts";
import { MANIFEST_ECOSYSTEM } from "../../../src/core/project-manifests.ts";
import { CHMOD_CANNOT_DENY, IS_WINDOWS } from "../../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let root: string;
diff --git a/tests/core/brain/architect.test.ts b/tests/core/brain/architect.test.ts
index 8a806030..ed21dbb8 100644
--- a/tests/core/brain/architect.test.ts
+++ b/tests/core/brain/architect.test.ts
@@ -3,7 +3,7 @@
* (Project History Suite, t_929da8a2).
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
chmodSync,
existsSync,
@@ -22,6 +22,10 @@ import { ARCHITECT_STAGE, scanProject } from "../../../src/core/brain/architect/
import { PROGRESS_KIND } from "../../../src/core/brain/progress.ts";
import { RegionError } from "../../../src/core/brain/regions.ts";
import { CHMOD_CANNOT_DENY } from "../../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let project: string;
diff --git a/tests/core/brain/bundle-wildcard-warning.test.ts b/tests/core/brain/bundle-wildcard-warning.test.ts
index 927679aa..445cd82b 100644
--- a/tests/core/brain/bundle-wildcard-warning.test.ts
+++ b/tests/core/brain/bundle-wildcard-warning.test.ts
@@ -11,13 +11,17 @@
* non-wildcard bundle imports byte-identically and says nothing.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { fakeCredential } from "../../helpers/fake-credentials.ts";
import { runCli } from "../../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/core/brain/doctor-freshen.test.ts b/tests/core/brain/doctor-freshen.test.ts
index 8faf7574..d30d5fe7 100644
--- a/tests/core/brain/doctor-freshen.test.ts
+++ b/tests/core/brain/doctor-freshen.test.ts
@@ -3,7 +3,7 @@
* failing: three in a row is a broken index, not a transient hiccup, and
* until it is fixed every search answers from an ageing index.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
@@ -15,6 +15,10 @@ import { writeFreshenState } from "../../../src/core/search/freshen.ts";
import { resolveSearchConfig } from "../../../src/core/search/index.ts";
import { MCPServer } from "../../../src/mcp/server.ts";
import { runCli } from "../../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/core/brain/doctor/git-tracked-state-check.test.ts b/tests/core/brain/doctor/git-tracked-state-check.test.ts
index 796fce87..a27081da 100644
--- a/tests/core/brain/doctor/git-tracked-state-check.test.ts
+++ b/tests/core/brain/doctor/git-tracked-state-check.test.ts
@@ -10,7 +10,7 @@
* answer, and it never edits anything.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -24,6 +24,10 @@ import {
} from "../../../../src/core/brain/doctor/git-tracked-state-check.ts";
import { ensureVaultGitignoreEntries } from "../../../../src/core/brain/gitignore-guard.ts";
import type { DoctorIssue } from "../../../../src/core/brain/types.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/core/brain/force-confirmed-cold-start.test.ts b/tests/core/brain/force-confirmed-cold-start.test.ts
index aed3625a..fcd367c2 100644
--- a/tests/core/brain/force-confirmed-cold-start.test.ts
+++ b/tests/core/brain/force-confirmed-cold-start.test.ts
@@ -29,7 +29,7 @@
* assert a rule was exercised against work that never happened.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -44,6 +44,10 @@ import { parsePreference, writePreference } from "../../../src/core/brain/prefer
import { resetVaultIdentityPins } from "../../../src/core/brain/vault-identity.ts";
import { BRAIN_LOG_EVENT_KIND } from "../../../src/core/brain/types.ts";
import { runCli } from "../../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const LOW_EVIDENCE_CODE = "low-evidence-confirmed";
diff --git a/tests/core/brain/git/ingest.test.ts b/tests/core/brain/git/ingest.test.ts
index 7d1c13db..75324c9c 100644
--- a/tests/core/brain/git/ingest.test.ts
+++ b/tests/core/brain/git/ingest.test.ts
@@ -4,7 +4,7 @@
* (Project History Suite, t_c812752c).
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { execFileSync } from "node:child_process";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -19,6 +19,10 @@ import {
readGitState,
writeGitState,
} from "../../../../src/core/brain/git/store.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let repo: string;
diff --git a/tests/core/brain/git/reader.test.ts b/tests/core/brain/git/reader.test.ts
index 522f9a84..ae4484ce 100644
--- a/tests/core/brain/git/reader.test.ts
+++ b/tests/core/brain/git/reader.test.ts
@@ -3,7 +3,7 @@
* (Project History Suite, t_c812752c).
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { execFileSync } from "node:child_process";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -17,6 +17,10 @@ import {
revListRange,
shaExists,
} from "../../../../src/core/brain/git/reader.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let repo: string;
diff --git a/tests/core/brain/ingest/concurrent-shared-writes.test.ts b/tests/core/brain/ingest/concurrent-shared-writes.test.ts
index 5947c0d9..88705e51 100644
--- a/tests/core/brain/ingest/concurrent-shared-writes.test.ts
+++ b/tests/core/brain/ingest/concurrent-shared-writes.test.ts
@@ -17,7 +17,7 @@
* the same discipline as `tests/core/brain/lineage-ledger-integrity.test.ts`.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -37,6 +37,10 @@ import {
acquireLockSync,
acquireLockSyncWithRetry,
} from "../../../../src/core/brain/sync-lockfile.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const WRITERS = 4;
const PER_WRITER = 25;
diff --git a/tests/core/brain/ingest/extract-html.test.ts b/tests/core/brain/ingest/extract-html.test.ts
index 81112fa4..2a532175 100644
--- a/tests/core/brain/ingest/extract-html.test.ts
+++ b/tests/core/brain/ingest/extract-html.test.ts
@@ -5,7 +5,7 @@
* whitespace, line breaks), the refusals and the bound on running time.
*/
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawnSync } from "node:child_process";
import { SOURCE_HASH_MAX_BYTES } from "../../../../src/core/brain/intake/source-trust.ts";
@@ -26,6 +26,10 @@ import {
import { extractTagValues, stripCode } from "../../../../src/core/tags.ts";
import { extractWikilinks } from "../../../../src/core/vault.ts";
import { fakeCredential } from "../../../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const encoder = new TextEncoder();
diff --git a/tests/core/brain/ingest/incremental-extract.test.ts b/tests/core/brain/ingest/incremental-extract.test.ts
index f2739c09..feb2f39c 100644
--- a/tests/core/brain/ingest/incremental-extract.test.ts
+++ b/tests/core/brain/ingest/incremental-extract.test.ts
@@ -28,7 +28,11 @@ import { mkdirSync, mkdtempSync, rmSync, appendFileSync, writeFileSync, statSync
import { tmpdir } from "node:os";
import { join } from "node:path";
-import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, mock, setDefaultTimeout, test } from "bun:test";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
// Positioned-read observer for the delta pass. The ONLY positioned readSync
// reachable from ingestSource is the append-proof snapshot's byte walk; the
diff --git a/tests/core/brain/ingest/ingest-derived-section.test.ts b/tests/core/brain/ingest/ingest-derived-section.test.ts
index efbd2935..c692a132 100644
--- a/tests/core/brain/ingest/ingest-derived-section.test.ts
+++ b/tests/core/brain/ingest/ingest-derived-section.test.ts
@@ -7,7 +7,7 @@
* `visibility` on a summary page survives a re-ingest.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawnSync } from "node:child_process";
import {
mkdirSync,
@@ -30,6 +30,10 @@ import { createHash } from "node:crypto";
import { IS_WINDOWS } from "../../../helpers/platform.ts";
import { redactRawOutput } from "../../../../src/core/redactor.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const NOW = new Date("2026-06-13T12:00:00Z");
diff --git a/tests/core/brain/ingest/ingest.test.ts b/tests/core/brain/ingest/ingest.test.ts
index 238ad985..cd36b072 100644
--- a/tests/core/brain/ingest/ingest.test.ts
+++ b/tests/core/brain/ingest/ingest.test.ts
@@ -6,7 +6,7 @@
* the agent supplies the extraction and the summary prose.
*/
-import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, spyOn, test } from "bun:test";
import * as fs from "node:fs";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { join, relative } from "node:path";
@@ -40,6 +40,10 @@ import { canonicalNotePath } from "../../../../src/core/path-safety.ts";
import { queryDecisionLedger } from "../../../../src/core/brain/permissions/ledger.ts";
import { deleteBySource } from "../../../../src/core/brain/source-cleanup.ts";
import { readManifest } from "../../../../src/core/brain/ingest/content-manifest.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
function readManifestEntries(): string[] {
return Object.keys(readManifest(vault).entries);
diff --git a/tests/core/brain/lineage-continuation.test.ts b/tests/core/brain/lineage-continuation.test.ts
index 6573e2d1..4e10f3cf 100644
--- a/tests/core/brain/lineage-continuation.test.ts
+++ b/tests/core/brain/lineage-continuation.test.ts
@@ -13,7 +13,7 @@
* never reaches a recorded field.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { execFileSync } from "node:child_process";
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { join } from "node:path";
@@ -44,6 +44,10 @@ import {
import { captureSessionLifecycleEvent } from "../../../src/core/brain/session-lifecycle.ts";
import { bootstrapBrain } from "../../../src/core/brain/init.ts";
import { tempDirs } from "../../helpers/temp-dir.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
// Every test's throwaway workspace is minted through the tracked helper
// so a directory is owned twice over: the afterEach removes the current
diff --git a/tests/core/brain/lineage-ledger-integrity.test.ts b/tests/core/brain/lineage-ledger-integrity.test.ts
index c015f7c9..7213530f 100644
--- a/tests/core/brain/lineage-ledger-integrity.test.ts
+++ b/tests/core/brain/lineage-ledger-integrity.test.ts
@@ -19,7 +19,7 @@
* cache and the lifecycle hook both depend on that.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
appendFileSync,
chmodSync,
@@ -46,6 +46,10 @@ import {
import { verifyLineageLedger } from "../../../src/core/brain/lineage/verify.ts";
import { acquireLockSync } from "../../../src/core/brain/sync-lockfile.ts";
import { CHMOD_CANNOT_DENY } from "../../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
diff --git a/tests/core/brain/lint-read-path.test.ts b/tests/core/brain/lint-read-path.test.ts
index b7c6dfbd..4878b7de 100644
--- a/tests/core/brain/lint-read-path.test.ts
+++ b/tests/core/brain/lint-read-path.test.ts
@@ -12,7 +12,7 @@
* point, before any other work, and only when the call will write.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -29,6 +29,10 @@ import {
} from "../../../src/core/brain/vault-identity.ts";
import { atomicWriteFileSync } from "../../../src/core/fs-atomic.ts";
import { runCli } from "../../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/core/brain/log-append.test.ts b/tests/core/brain/log-append.test.ts
index 0e3db9a6..710c2c4d 100644
--- a/tests/core/brain/log-append.test.ts
+++ b/tests/core/brain/log-append.test.ts
@@ -9,7 +9,7 @@
* markdown view's bytes, and correctness under concurrent processes.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
appendFileSync,
mkdirSync,
@@ -26,6 +26,10 @@ import { verifyLogChain } from "../../../src/core/brain/log-chain.ts";
import { readLogDay } from "../../../src/core/brain/log-jsonl.ts";
import { appendLogEvent, LOG_CHAIN_FIELDS } from "../../../src/core/brain/log.ts";
import { logJsonlPath, logPath } from "../../../src/core/brain/paths.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const DATE = "2026-06-01";
const SPAWN_TIMEOUT_MS = 60_000;
@@ -197,12 +201,28 @@ describe("log append", () => {
`import { appendLogEvent } from ${JSON.stringify(logModule)};`,
"const [vault, tag, count, startAt] = process.argv.slice(2);",
"while (Date.now() < Number(startAt)) Bun.sleepSync(1);",
+ // Four writers each firing 25 appends back to back is far more
+ // contention than the log lock's two-second wait is sized for
+ // (several agents, not a tight loop), and on a slow Windows disk a
+ // writer lost every round past it with ELOCKED. The refusal tells
+ // the caller to retry the write, so the writer does, within a
+ // bound: what this test proves is the chain under concurrency.
+ "const RETRY_UNTIL_MS = 30_000;",
"for (let i = 0; i < Number(count); i++) {",
- " appendLogEvent(",
- " vault,",
- ` { timestamp: "${DATE}T11:00:00Z", eventType: "note", body: { text: \`\${tag}-\${i}\` } },`,
- ' { deviceId: "" },',
- " );",
+ " const giveUpAt = Date.now() + RETRY_UNTIL_MS;",
+ " for (;;) {",
+ " try {",
+ " appendLogEvent(",
+ " vault,",
+ ` { timestamp: "${DATE}T11:00:00Z", eventType: "note", body: { text: \`\${tag}-\${i}\` } },`,
+ ' { deviceId: "" },',
+ " );",
+ " break;",
+ " } catch (err) {",
+ ' if (err?.code !== "ELOCKED" || Date.now() > giveUpAt) throw err;',
+ " Bun.sleepSync(10 + Math.floor(Math.random() * 20));",
+ " }",
+ " }",
"}",
].join("\n"),
"utf8",
diff --git a/tests/core/brain/maintenance-capacity-gate.test.ts b/tests/core/brain/maintenance-capacity-gate.test.ts
index b8505dcf..4c55a421 100644
--- a/tests/core/brain/maintenance-capacity-gate.test.ts
+++ b/tests/core/brain/maintenance-capacity-gate.test.ts
@@ -18,7 +18,7 @@
* datum the storage report surfaces already collect.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { appendFileSync, existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -50,6 +50,10 @@ import { TRANSPORT_REACH } from "../../../src/core/graph/transport-reach.ts";
import { JSONRPC_VERSION, MCPServer, PROTOCOL_VERSION } from "../../../src/mcp/index.ts";
import { homeEnv } from "../../helpers/platform.ts";
import { runCli } from "../../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const NOW = new Date("2026-06-05T03:30:00Z");
/** The metrics surface Lane 1's `sampleStorageUsage` appends one record per call under. */
diff --git a/tests/core/brain/maintenance/custom-tasks.test.ts b/tests/core/brain/maintenance/custom-tasks.test.ts
index 1f1945d2..df3db8bf 100644
--- a/tests/core/brain/maintenance/custom-tasks.test.ts
+++ b/tests/core/brain/maintenance/custom-tasks.test.ts
@@ -8,7 +8,7 @@
* failure, and the whole process group killed on timeout or abort.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -47,6 +47,10 @@ import {
} from "../../../../src/core/brain/safeguard.ts";
import { MAINTENANCE_LEASE_TTL_MS } from "../../../../src/core/brain/maintenance/lane.ts";
import { IS_WINDOWS } from "../../../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let dir: string;
let configPath: string;
diff --git a/tests/core/brain/manual-template-revision.test.ts b/tests/core/brain/manual-template-revision.test.ts
index 0a093b0b..91387343 100644
--- a/tests/core/brain/manual-template-revision.test.ts
+++ b/tests/core/brain/manual-template-revision.test.ts
@@ -15,7 +15,7 @@
* release constant it renders without bumping the revision fails here.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { createHash } from "node:crypto";
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -38,6 +38,10 @@ import {
SELF_HEAL_UPGRADE_OUTCOME,
} from "../../../src/core/maintenance/self-heal-upgrade.ts";
import { runCli } from "../../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const MANUAL = "Brain/_BRAIN.md";
diff --git a/tests/core/brain/metrics.test.ts b/tests/core/brain/metrics.test.ts
index 70289d11..cbc1bd6b 100644
--- a/tests/core/brain/metrics.test.ts
+++ b/tests/core/brain/metrics.test.ts
@@ -7,7 +7,7 @@
* version, renames/removals bump it.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdtempSync,
@@ -28,6 +28,10 @@ import {
metricsDir,
} from "../../../src/core/brain/metrics.ts";
import { useUnshardedLegacyLog } from "../../helpers/device-id.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
// The legacy day log and ledgers are read under their un-sharded names.
useUnshardedLegacyLog();
diff --git a/tests/core/brain/pinned-concurrency.test.ts b/tests/core/brain/pinned-concurrency.test.ts
index e9974076..ea254919 100644
--- a/tests/core/brain/pinned-concurrency.test.ts
+++ b/tests/core/brain/pinned-concurrency.test.ts
@@ -9,7 +9,7 @@
* `tests/core/brain/ingest/concurrent-shared-writes.test.ts`.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -17,6 +17,10 @@ import { join } from "node:path";
import { bootstrapBrain } from "../../../src/core/brain/init.ts";
import { brainPinnedPath } from "../../../src/core/brain/paths.ts";
import { readPinnedContext } from "../../../src/core/brain/pinned.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const WRITERS = 4;
const PER_WRITER = 15;
diff --git a/tests/core/brain/pledges.test.ts b/tests/core/brain/pledges.test.ts
index 8f03fbbd..427612c5 100644
--- a/tests/core/brain/pledges.test.ts
+++ b/tests/core/brain/pledges.test.ts
@@ -6,7 +6,7 @@
* wave plan pins for A1.
*/
-import { test, expect, beforeEach, afterEach, spyOn } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, spyOn, test } from "bun:test";
import * as fs from "node:fs";
import {
existsSync,
@@ -33,6 +33,10 @@ import {
import { formatFrontmatter, parseFrontmatter } from "../../../src/core/vault.ts";
import { REMOTE_DENY_VISIBILITY_TOKEN } from "../../../src/core/graph/visibility.ts";
import { acquireLockSync, LOCK_WAIT_BUDGET_ENV } from "../../../src/core/brain/sync-lockfile.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const NOW = new Date("2026-06-19T12:00:00Z");
diff --git a/tests/core/brain/portability/profiles.test.ts b/tests/core/brain/portability/profiles.test.ts
index ebb8ad42..638deb6f 100644
--- a/tests/core/brain/portability/profiles.test.ts
+++ b/tests/core/brain/portability/profiles.test.ts
@@ -8,7 +8,7 @@
* unchanged (back-compat).
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
@@ -23,6 +23,10 @@ import {
} from "../../../../src/core/brain/portability/profiles.ts";
import { resolveVault } from "../../../../src/core/config.ts";
import { atomicWriteFileSync } from "../../../../src/core/fs-atomic.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let home: string;
let configPath: string;
diff --git a/tests/core/brain/schema-store-only.test.ts b/tests/core/brain/schema-store-only.test.ts
index fa2009c9..80d55235 100644
--- a/tests/core/brain/schema-store-only.test.ts
+++ b/tests/core/brain/schema-store-only.test.ts
@@ -5,7 +5,7 @@
* readers see the stored pack, and nothing under `Brain/` changes. An
* unswitched machine keeps writing `_brain.yaml`.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { readFileSync } from "node:fs";
import { brainConfigPath } from "../../../src/core/brain/paths.ts";
@@ -25,6 +25,10 @@ import {
partitionRecords,
switchDevice,
} from "./store-only/fixtures.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let env: StoreEnv | null = null;
afterEach(() => {
diff --git a/tests/core/brain/secrets/owner-acl.test.ts b/tests/core/brain/secrets/owner-acl.test.ts
index 5a2bac56..5dc6bc53 100644
--- a/tests/core/brain/secrets/owner-acl.test.ts
+++ b/tests/core/brain/secrets/owner-acl.test.ts
@@ -6,7 +6,7 @@
* back with `icacls` itself.
*/
-import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, spyOn, test } from "bun:test";
import { spawnSync } from "node:child_process";
import {
chmodSync,
@@ -38,6 +38,10 @@ import {
} from "../../../../src/core/brain/secrets/store.ts";
import { fakeCredential } from "../../../helpers/fake-credentials.ts";
import { IS_WINDOWS } from "../../../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const SID = "S-1-5-21-1111111111-2222222222-3333333333-1001";
diff --git a/tests/core/brain/secrets/sync-exposure.test.ts b/tests/core/brain/secrets/sync-exposure.test.ts
index 7f0dacc2..35e8f421 100644
--- a/tests/core/brain/secrets/sync-exposure.test.ts
+++ b/tests/core/brain/secrets/sync-exposure.test.ts
@@ -7,7 +7,7 @@
* to add; it never edits `.stignore` itself.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -35,6 +35,10 @@ import { generateAttestationKeypair } from "../../../../src/core/brain/attestati
import { secretsDir } from "../../../../src/core/brain/secrets/store.ts";
import { fakeCredential } from "../../../helpers/fake-credentials.ts";
import { runCli } from "../../../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/core/brain/snapshot-atomic-publish.test.ts b/tests/core/brain/snapshot-atomic-publish.test.ts
index 4ca57d01..2c86c714 100644
--- a/tests/core/brain/snapshot-atomic-publish.test.ts
+++ b/tests/core/brain/snapshot-atomic-publish.test.ts
@@ -13,7 +13,7 @@
* on POSIX hosts only.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
chmodSync,
existsSync,
@@ -32,9 +32,20 @@ import { join } from "node:path";
import { bootstrapBrain } from "../../../src/core/brain/init.ts";
import { manifestSidecarPath } from "../../../src/core/brain/manifest.ts";
import { snapshotPath, snapshotsDir } from "../../../src/core/brain/paths.ts";
-import { createSnapshot, listSnapshots, pruneSnapshots } from "../../../src/core/brain/snapshot.ts";
+import {
+ createSnapshot,
+ listSnapshots,
+ pruneSnapshots,
+ resolveSnapshotToolTimeoutMs,
+ SNAPSHOT_TOOL_TIMEOUT_ENV,
+ SNAPSHOT_TOOL_TIMEOUT_MS,
+} from "../../../src/core/brain/snapshot.ts";
import { BRAIN_SNAPSHOT_REASON } from "../../../src/core/brain/types.ts";
import { atomicWriteFileSync } from "../../../src/core/fs-atomic.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const RUN_ID = "upgrade-atomic-publish";
@@ -42,6 +53,7 @@ let root: string;
let vault: string;
let bin: string;
let originalPath: string | undefined;
+let originalToolTimeout: string | undefined;
beforeEach(() => {
root = mkdtempSync(join(tmpdir(), "o2b-snap-atomic-"));
@@ -56,10 +68,13 @@ beforeEach(() => {
if (tar === null) throw new Error("test prerequisite missing from this machine: tar");
symlinkSync(tar, join(bin, "tar"));
originalPath = process.env["PATH"];
+ originalToolTimeout = process.env[SNAPSHOT_TOOL_TIMEOUT_ENV];
});
afterEach(() => {
process.env["PATH"] = originalPath;
+ if (originalToolTimeout === undefined) delete process.env[SNAPSHOT_TOOL_TIMEOUT_ENV];
+ else process.env[SNAPSHOT_TOOL_TIMEOUT_ENV] = originalToolTimeout;
rmSync(root, { recursive: true, force: true });
});
@@ -179,3 +194,46 @@ describe.skipIf(process.platform === "win32")("publishing a zstd snapshot", () =
expect(existsSync(fresh)).toBe(true);
});
});
+
+describe.skipIf(process.platform === "win32")("a compressor that never exits", () => {
+ test("is stopped at the tool timeout and the snapshot fails naming it", () => {
+ // `exec` so the killed process is the sleeper itself: a shell killed
+ // around a running child would leave that child holding stderr open.
+ const sleep = Bun.which("sleep");
+ if (sleep === null) throw new Error("test prerequisite missing from this machine: sleep");
+ fakeZstd(`printf 'torn' > "$out"\nexec '${sleep}' 30`);
+ process.env["PATH"] = bin;
+ process.env[SNAPSHOT_TOOL_TIMEOUT_ENV] = "300";
+
+ const started = Date.now();
+ expect(() => createSnapshot(vault, RUN_ID, { reason: BRAIN_SNAPSHOT_REASON.upgrade })).toThrow(
+ /zstd did not finish within 300 ms and was stopped/,
+ );
+
+ expect(Date.now() - started).toBeLessThan(10_000);
+ expect(snapshotEntries()).toEqual([]);
+ });
+});
+
+describe("the snapshot tool timeout", () => {
+ test("defaults to fifteen minutes when unset or empty", () => {
+ expect(resolveSnapshotToolTimeoutMs({})).toBe(SNAPSHOT_TOOL_TIMEOUT_MS);
+ expect(resolveSnapshotToolTimeoutMs({ [SNAPSHOT_TOOL_TIMEOUT_ENV]: " " })).toBe(15 * 60 * 1000);
+ });
+
+ test("is the variable the test preload bounds the suite with", () => {
+ expect(SNAPSHOT_TOOL_TIMEOUT_ENV).toBe("OPEN_SECOND_BRAIN_SNAPSHOT_TIMEOUT_MS");
+ });
+
+ test("takes a whole number of milliseconds above zero", () => {
+ expect(resolveSnapshotToolTimeoutMs({ [SNAPSHOT_TOOL_TIMEOUT_ENV]: "60000" })).toBe(60_000);
+ });
+
+ test("refuses anything else instead of falling back", () => {
+ for (const bad of ["0", "-5", "1.5", "10s", "abc"]) {
+ expect(() => resolveSnapshotToolTimeoutMs({ [SNAPSHOT_TOOL_TIMEOUT_ENV]: bad })).toThrow(
+ SNAPSHOT_TOOL_TIMEOUT_ENV,
+ );
+ }
+ });
+});
diff --git a/tests/core/brain/snapshot-extract-containment.test.ts b/tests/core/brain/snapshot-extract-containment.test.ts
index 354c0673..34665486 100644
--- a/tests/core/brain/snapshot-extract-containment.test.ts
+++ b/tests/core/brain/snapshot-extract-containment.test.ts
@@ -14,7 +14,7 @@
* cannot be built.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawnSync } from "node:child_process";
import {
existsSync,
@@ -39,6 +39,10 @@ import {
restoreSnapshot,
} from "../../../src/core/brain/snapshot.ts";
import { IS_WINDOWS } from "../../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
let configHome: string;
diff --git a/tests/core/brain/snapshot-members.test.ts b/tests/core/brain/snapshot-members.test.ts
index fedccc50..66c807ad 100644
--- a/tests/core/brain/snapshot-members.test.ts
+++ b/tests/core/brain/snapshot-members.test.ts
@@ -15,7 +15,7 @@
* and GNU tar refused the whole archive.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawnSync } from "node:child_process";
import {
chmodSync,
@@ -43,6 +43,10 @@ import { BRAIN_SNAPSHOT_REASON } from "../../../src/core/brain/types.ts";
import { atomicWriteFileSync } from "../../../src/core/fs-atomic.ts";
import { CHMOD_CANNOT_DENY, IS_WINDOWS } from "../../helpers/platform.ts";
import { extractSnapshotArchive, listSnapshotArchive } from "../../helpers/snapshot-archive.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const DREAM = BRAIN_SNAPSHOT_REASON.dream;
diff --git a/tests/core/brain/snapshot-streaming.test.ts b/tests/core/brain/snapshot-streaming.test.ts
index 8d5b5224..236fb091 100644
--- a/tests/core/brain/snapshot-streaming.test.ts
+++ b/tests/core/brain/snapshot-streaming.test.ts
@@ -13,7 +13,7 @@
* costs no disk in the fixture tree.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
chmodSync,
closeSync,
@@ -38,6 +38,10 @@ import { bootstrapBrain } from "../../../src/core/brain/init.ts";
import { createSnapshot, extractSnapshotToTemp } from "../../../src/core/brain/snapshot.ts";
import { BRAIN_SNAPSHOT_REASON } from "../../../src/core/brain/types.ts";
import { atomicWriteFileSync } from "../../../src/core/fs-atomic.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** Above the 256 MB buffer the archive path used to be capped at. */
const PRODUCED_BYTES = 300 * 1024 * 1024;
diff --git a/tests/core/brain/store-only/log-store-only.test.ts b/tests/core/brain/store-only/log-store-only.test.ts
index b7a84cc3..6eed9941 100644
--- a/tests/core/brain/store-only/log-store-only.test.ts
+++ b/tests/core/brain/store-only/log-store-only.test.ts
@@ -6,7 +6,7 @@
* legacy day files plus the dual write; the log reader facade returns the
* event either way.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { join } from "node:path";
@@ -33,6 +33,10 @@ import { runCli } from "../../../helpers/run-cli.ts";
import { makeStoreEnv, type StoreEnv } from "../../store/fixtures/store-env.ts";
import { brainTreeDigest, ledgerRows, partitionRecords, switchDevice } from "./fixtures.ts";
import { digestVaultTree } from "../../../helpers/vault-digest.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const DATE = "2026-06-01";
const TS = `${DATE}T10:00:00Z`;
diff --git a/tests/core/brain/sync-lockfile-fairness.test.ts b/tests/core/brain/sync-lockfile-fairness.test.ts
index fd15988d..d71e1f75 100644
--- a/tests/core/brain/sync-lockfile-fairness.test.ts
+++ b/tests/core/brain/sync-lockfile-fairness.test.ts
@@ -10,7 +10,7 @@
* holder that releases a marked lock steps back before it re-acquires.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdtempSync,
@@ -31,6 +31,10 @@ import {
LOCK_WAIT_BUDGET_MS,
resolveLockWaitBudgetMs,
} from "../../../src/core/brain/sync-lockfile.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let root: string;
let savedEnv: string | undefined;
diff --git a/tests/core/brain/sync-lockfile.test.ts b/tests/core/brain/sync-lockfile.test.ts
index 7927f863..c8a7b524 100644
--- a/tests/core/brain/sync-lockfile.test.ts
+++ b/tests/core/brain/sync-lockfile.test.ts
@@ -5,7 +5,7 @@
* txn layer maps that to a `BrainCollisionError({ kind: 'SourceLock' })`.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
lstatSync,
@@ -37,6 +37,10 @@ import {
scanStaleLocks,
TAKEOVER_CLAIM_STALE_MS,
} from "../../../src/core/brain/sync-lockfile.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmpRoot: string;
diff --git a/tests/core/brain/upgrade-switched.test.ts b/tests/core/brain/upgrade-switched.test.ts
index ade66a03..deb54253 100644
--- a/tests/core/brain/upgrade-switched.test.ts
+++ b/tests/core/brain/upgrade-switched.test.ts
@@ -3,7 +3,7 @@
* (design D14 item 1, task 2.10): `brain upgrade` refuses there, and the
* session-start maintenance skips the managed-file upgrade.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import {
@@ -21,6 +21,10 @@ import { digestVaultTree } from "../../helpers/vault-digest.ts";
import { makeStoreEnv, type StoreEnv } from "../store/fixtures/store-env.ts";
import { switchDevice as switchDeviceAt } from "./store-only/fixtures.ts";
import { join } from "node:path";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let env: StoreEnv | null = null;
afterEach(() => {
diff --git a/tests/core/config-read-failure.test.ts b/tests/core/config-read-failure.test.ts
index d7e51c6f..c82aa92b 100644
--- a/tests/core/config-read-failure.test.ts
+++ b/tests/core/config-read-failure.test.ts
@@ -21,7 +21,7 @@
* tolerant parser into a strict one.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
@@ -39,6 +39,10 @@ import {
import { receiptShardPath } from "../../src/core/brain/decisions/receipts.ts";
import { claimShardPath } from "../../src/core/brain/truth/store.ts";
import { CHMOD_CANNOT_DENY, homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOKS_DIR = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "hooks");
diff --git a/tests/core/content-class-egress.test.ts b/tests/core/content-class-egress.test.ts
index 75773ae1..944f6785 100644
--- a/tests/core/content-class-egress.test.ts
+++ b/tests/core/content-class-egress.test.ts
@@ -15,7 +15,7 @@
* - the same bytes the deterministic prompt-derived writers put on disk.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -40,6 +40,10 @@ import {
treeCarriesPromptDerived,
} from "../../src/core/brain/provenance/content-class.ts";
import { spoolTranscriptCorpus, type SpoolOutcome } from "../../src/cli/brain/verbs/export.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/core/doctor.test.ts b/tests/core/doctor.test.ts
index 053568a9..c5e14f58 100644
--- a/tests/core/doctor.test.ts
+++ b/tests/core/doctor.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawnSync } from "node:child_process";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -17,6 +17,10 @@ import {
} from "../../src/core/doctor.ts";
import { checkHermesResolverParity } from "../../src/core/doctor-hermes-parity.ts";
import { createPluginRepo, createSandboxVault } from "../helpers/fixtures.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/**
* Whether a real Python 3 answers on this machine, under any name the check
diff --git a/tests/core/install/tool-ceiling.test.ts b/tests/core/install/tool-ceiling.test.ts
index 8ba52aa0..6b6cf42a 100644
--- a/tests/core/install/tool-ceiling.test.ts
+++ b/tests/core/install/tool-ceiling.test.ts
@@ -32,7 +32,7 @@
* writes and reads the surface back off the probe.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -64,6 +64,10 @@ import { CONFIG_ORIGIN } from "../../../src/core/validate.ts";
import { evaluateToolCapabilities } from "../../../src/mcp/capabilities.ts";
import { resolveToolSurface } from "../../../src/mcp/profiles.ts";
import { buildToolTable } from "../../../src/mcp/tools.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
let home: string;
diff --git a/tests/core/lanes/create-once-race.test.ts b/tests/core/lanes/create-once-race.test.ts
index 6a9a09f1..9aab0faf 100644
--- a/tests/core/lanes/create-once-race.test.ts
+++ b/tests/core/lanes/create-once-race.test.ts
@@ -4,12 +4,16 @@
* the "exists" answer (`EEXIST`) an unswitched machine's exclusive create
* gives, in every mode.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { readLanePage } from "../../../src/core/store/lane-pages.ts";
import { LANE_MODES, makeLaneEnv, type LaneEnv } from "./fixtures/lane-env.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let lane: LaneEnv | null = null;
afterEach(() => {
diff --git a/tests/core/maintenance/self-heal-upgrade-synced-vault.test.ts b/tests/core/maintenance/self-heal-upgrade-synced-vault.test.ts
index 46302f75..0eaf548a 100644
--- a/tests/core/maintenance/self-heal-upgrade-synced-vault.test.ts
+++ b/tests/core/maintenance/self-heal-upgrade-synced-vault.test.ts
@@ -22,7 +22,16 @@
* revision one higher, run in its own process.
*/
-import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from "bun:test";
+import {
+ afterAll,
+ afterEach,
+ beforeAll,
+ beforeEach,
+ describe,
+ expect,
+ setDefaultTimeout,
+ test,
+} from "bun:test";
import {
cpSync,
existsSync,
@@ -49,6 +58,10 @@ import {
runSelfHealUpgrade,
SELF_HEAL_UPGRADE_OUTCOME,
} from "../../../src/core/maintenance/self-heal-upgrade.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let root: string;
let mac: string;
diff --git a/tests/core/maintenance/self-heal-upgrade.test.ts b/tests/core/maintenance/self-heal-upgrade.test.ts
index eabbc1e0..e907eac3 100644
--- a/tests/core/maintenance/self-heal-upgrade.test.ts
+++ b/tests/core/maintenance/self-heal-upgrade.test.ts
@@ -8,7 +8,7 @@
* (and with it the whole upgrade) cannot proceed.
*/
-import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, spyOn, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
@@ -39,6 +39,10 @@ import {
} from "../../../src/core/maintenance/self-heal-upgrade-state.ts";
import { runCli } from "../../helpers/run-cli.ts";
import { waitForSelfHealChildren } from "../../helpers/self-heal-children.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOUR = 60 * 60_000;
const T0 = new Date("2026-09-28T10:00:00.000Z");
@@ -65,15 +69,27 @@ afterEach(async () => {
rmSync(root, { recursive: true, force: true });
});
-/** A detached worker releases the lock it was handed when it ends. */
+/**
+ * Wait for the detached worker to end: its outcome row is recorded and the
+ * lock it was handed is released.
+ *
+ * The row is what decides. Waiting on the lock file alone returned on a
+ * Windows runner about a second after the spawn, before a cold worker
+ * could have planned anything, and the test then read the upgrade as still
+ * pending. The worker writes its row before it exits and releases the lock
+ * on exit, so a run that has both is a run that ended.
+ */
async function waitForWorker(budgetMs = 60_000): Promise<void> {
const deadline = Date.now() + budgetMs;
- while (existsSync(selfHealUpgradeLockPath(vault)) && Date.now() < deadline) {
+ const ended = (): boolean =>
+ upgradeRows().length > 0 && !existsSync(selfHealUpgradeLockPath(vault));
+ while (!ended() && Date.now() < deadline) {
// Nothing in-process holds the detached worker; looking again is the
// only way to learn it ended.
// eslint-disable-next-line no-await-in-loop
await Bun.sleep(50);
}
+ if (upgradeRows().length === 0) throw new Error("worker recorded no outcome");
if (existsSync(selfHealUpgradeLockPath(vault))) throw new Error("worker never released its lock");
}
@@ -233,8 +249,12 @@ describe("ensureVaultCurrent in the background", () => {
expect(r.brainUpgradeSpawn).toBe(SELF_HEAL_UPGRADE_SPAWN.spawned);
expect(r.brainUpgraded).toEqual([]);
await waitForWorker();
+ // The outcome first: a worker that did not apply says why in its row,
+ // which a bare "pending: 1" would hide.
+ expect(upgradeRows().map((row) => [row["outcome"], row["error"] ?? null])).toEqual([
+ [SELF_HEAL_UPGRADE_OUTCOME.applied, null],
+ ]);
expect(planUpgrade(vault).pending).toBe(0);
- expect(upgradeRows().map((row) => row["outcome"])).toEqual([SELF_HEAL_UPGRADE_OUTCOME.applied]);
}, 60_000);
test("starts nothing while a recorded failure is cooling down", async () => {
diff --git a/tests/core/search/brain-store-rebuild.test.ts b/tests/core/search/brain-store-rebuild.test.ts
index ca64628d..302343bb 100644
--- a/tests/core/search/brain-store-rebuild.test.ts
+++ b/tests/core/search/brain-store-rebuild.test.ts
@@ -5,7 +5,7 @@
* read. The rebuild is the self-heal one an index chunked by older rules
* gets, and the new index carries the store from its first read.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { Database } from "bun:sqlite";
import { existsSync, statSync, writeFileSync } from "node:fs";
import { join } from "node:path";
@@ -25,6 +25,10 @@ import {
REMOTE_DEVICE,
type StoreIndexFixture,
} from "./fixtures/brain-store-index.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const NOTES = 400;
const WORKER = join(import.meta.dir, "fixtures", "store-rebuild-worker.ts");
diff --git a/tests/core/search/embedder-record-audit.test.ts b/tests/core/search/embedder-record-audit.test.ts
index b505a89d..b9fcf14d 100644
--- a/tests/core/search/embedder-record-audit.test.ts
+++ b/tests/core/search/embedder-record-audit.test.ts
@@ -27,7 +27,7 @@
* audit in every state.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, writeFileSync } from "node:fs";
import { dirname } from "node:path";
@@ -45,6 +45,10 @@ import { runCli } from "../../helpers/run-cli.ts";
import { createTempVault, makeConfig, writeMd } from "../../helpers/search-fixtures.ts";
import { sqliteVecLoadable } from "../../helpers/sqlite-vec.ts";
import { FAKE_PROVIDER_KEY } from "../../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
let dbPath: string;
diff --git a/tests/core/search/embedding-abi.test.ts b/tests/core/search/embedding-abi.test.ts
index d7434bfe..7ee7a91f 100644
--- a/tests/core/search/embedding-abi.test.ts
+++ b/tests/core/search/embedding-abi.test.ts
@@ -13,7 +13,7 @@
* loaded, following the repository-wide `sqliteVecLoadable()` pattern.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, writeFileSync } from "node:fs";
import { join } from "node:path";
@@ -30,6 +30,10 @@ import { runCli } from "../../helpers/run-cli.ts";
import { createTempVault, makeConfig, writeMd } from "../../helpers/search-fixtures.ts";
import { sqliteVecLoadable } from "../../helpers/sqlite-vec.ts";
import { FAKE_PROVIDER_KEY } from "../../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
let dbPath: string;
diff --git a/tests/core/search/freshen.test.ts b/tests/core/search/freshen.test.ts
index 62775f0b..d44532f0 100644
--- a/tests/core/search/freshen.test.ts
+++ b/tests/core/search/freshen.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
chmodSync,
existsSync,
@@ -35,6 +35,10 @@ import { acquireWriterLockSync } from "../../../src/core/search/store/writer-loc
import type { ResolvedSearchConfig } from "../../../src/core/search/types.ts";
import type { FreshenPending } from "../../../src/core/search/freshen.ts";
import { CHMOD_CANNOT_DENY } from "../../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const NOW = Date.parse("2026-10-07T12:00:00.000Z");
const ago = (s: number): string => new Date(NOW - s * 1000).toISOString();
diff --git a/tests/core/search/pending-vectors.test.ts b/tests/core/search/pending-vectors.test.ts
index a5270b04..75a1fc3b 100644
--- a/tests/core/search/pending-vectors.test.ts
+++ b/tests/core/search/pending-vectors.test.ts
@@ -26,7 +26,7 @@
* 8. Both `o2b search check` shapes render the field in every state.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { Database } from "bun:sqlite";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { dirname, join } from "node:path";
@@ -46,6 +46,10 @@ import { runCli } from "../../helpers/run-cli.ts";
import { createTempVault, makeConfig, writeMd } from "../../helpers/search-fixtures.ts";
import { sqliteVecLoadable } from "../../helpers/sqlite-vec.ts";
import { FAKE_PROVIDER_KEY } from "../../helpers/fake-credentials.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const VEC_LOADABLE = sqliteVecLoadable();
diff --git a/tests/core/search/pool-total.test.ts b/tests/core/search/pool-total.test.ts
index 7a4272c5..d1ecef15 100644
--- a/tests/core/search/pool-total.test.ts
+++ b/tests/core/search/pool-total.test.ts
@@ -10,6 +10,7 @@
*/
import { afterEach, beforeEach, expect, test } from "bun:test";
+import { utimesSync } from "node:fs";
import { indexVault } from "../../../src/core/search/indexer.ts";
import { search } from "../../../src/core/search/search.ts";
@@ -103,23 +104,35 @@ function withRecall(
const CROWDED_HOT_NOTES = 6;
const CROWDED_QUERY = "widget calibration";
+/**
+ * One modification time for every crowded note. The hot notes tie on score,
+ * and the ranker's tie-break ladder reaches `mtime` (newest first) before
+ * the chunk id. Written back to back, the six files got one coarse clock
+ * tick on Linux and so fell through to the chunk id, but straddled ticks on
+ * a Windows runner, which then answered with the newest notes first. A
+ * fixed time makes the fixture as clock-free as its config claims.
+ */
+const CROWDED_MTIME = new Date("2026-01-01T00:00:00Z");
+
function writeCrowdedVault(vaultDir: string): void {
for (let i = 0; i < CROWDED_HOT_NOTES; i += 1) {
- writeMd(
+ const path = writeMd(
vaultDir,
`a-${i}.md`,
`---\ntitle: Crowded ${i}\nsession_ref: sess-a\n---\n\n# Crowded ${i}\n\n` +
`The widget calibration routine number ${i}. Widget calibration is repeated here. ` +
`Widget calibration matters to this note.\n`,
);
+ utimesSync(path, CROWDED_MTIME, CROWDED_MTIME);
}
for (const session of ["b", "c", "d"]) {
- writeMd(
+ const path = writeMd(
vaultDir,
`${session}.md`,
`---\ntitle: Other ${session}\nsession_ref: sess-${session}\n---\n\n# Other ${session}\n\n` +
`The widget calibration routine of session ${session}.\n`,
);
+ utimesSync(path, CROWDED_MTIME, CROWDED_MTIME);
}
}
diff --git a/tests/core/state/migrate.test.ts b/tests/core/state/migrate.test.ts
index 00650f55..2c954504 100644
--- a/tests/core/state/migrate.test.ts
+++ b/tests/core/state/migrate.test.ts
@@ -25,7 +25,7 @@
* code.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
chmodSync,
existsSync,
@@ -57,6 +57,10 @@ import {
} from "../../../src/core/state/migrate.ts";
import { STATE_SURFACE_ID, STATE_SURFACES } from "../../../src/core/state/surfaces.ts";
import { CHMOD_CANNOT_DENY, IS_WINDOWS } from "../../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const temps: string[] = [];
diff --git a/tests/core/store-migration/migrate-writers.test.ts b/tests/core/store-migration/migrate-writers.test.ts
index 98a12eef..a9f10be4 100644
--- a/tests/core/store-migration/migrate-writers.test.ts
+++ b/tests/core/store-migration/migrate-writers.test.ts
@@ -4,12 +4,16 @@
* delta pass drain what was in flight, and every write that succeeded is
* in the store. Three cold child processes, so the test is kept to one.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, readFileSync } from "node:fs";
import { join, relative, sep } from "node:path";
import { runMigration } from "../../../src/core/store-migration/migrate.ts";
import { makeMigrationBench, type MigrationBench } from "./fixtures/migration-env.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let bench: MigrationBench;
beforeEach(() => {
diff --git a/tests/core/store-migration/migrate.test.ts b/tests/core/store-migration/migrate.test.ts
index f25fbc92..1010636a 100644
--- a/tests/core/store-migration/migrate.test.ts
+++ b/tests/core/store-migration/migrate.test.ts
@@ -4,7 +4,7 @@
* with identical content, a file that grows during conversion, a
* verification gap and a backup failure.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
appendFileSync,
existsSync,
@@ -65,6 +65,10 @@ import {
import { forgetMachineStateCache } from "../../../src/core/state/machine-state.ts";
import { CHMOD_CANNOT_DENY } from "../../helpers/platform.ts";
import { digestVaultTree } from "../../helpers/vault-digest.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let bench: MigrationBench;
beforeEach(() => {
diff --git a/tests/core/store-migration/quiesce.test.ts b/tests/core/store-migration/quiesce.test.ts
index 83ff362d..4a145a79 100644
--- a/tests/core/store-migration/quiesce.test.ts
+++ b/tests/core/store-migration/quiesce.test.ts
@@ -6,7 +6,7 @@
* releases only its own gate, and the operator's forced release refuses
* only a holder that is provably alive.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawnSync } from "node:child_process";
import { mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -21,6 +21,10 @@ import {
} from "../../../src/core/store-migration/quiesce.ts";
import { processStartIdentity } from "../../../src/core/store-migration/process-identity.ts";
import { IS_WINDOWS } from "../../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let parent: string;
let vault: string;
diff --git a/tests/core/store-migration/removal.test.ts b/tests/core/store-migration/removal.test.ts
index a57707d9..1f011930 100644
--- a/tests/core/store-migration/removal.test.ts
+++ b/tests/core/store-migration/removal.test.ts
@@ -5,7 +5,7 @@
* closed, the dated device-local archive, the doctor naming devices still
* on the legacy layout, and a legacy directory that comes back.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawn } from "node:child_process";
import {
existsSync,
@@ -52,6 +52,10 @@ import {
import { RollbackRefusedError } from "../../../src/core/store-migration/rollback.ts";
import { makeFleet, type Fleet, type Machine } from "./fixtures/fleet.ts";
import { moveNeverHeld } from "../../helpers/held-partitions.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const FAST = { settleMs: 0 } as const;
diff --git a/tests/core/store-migration/rollback.test.ts b/tests/core/store-migration/rollback.test.ts
index 0691a555..cd7d7101 100644
--- a/tests/core/store-migration/rollback.test.ts
+++ b/tests/core/store-migration/rollback.test.ts
@@ -5,7 +5,7 @@
* order; kinds with no legacy form stay in the store and are reported; a
* resumed rollback duplicates nothing; the device is no longer switched.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
appendFileSync,
chmodSync,
@@ -38,6 +38,10 @@ import { readVaultIdentity } from "../../../src/core/brain/vault-identity.ts";
import { readVaultBindings } from "../../../src/core/vault-adapter/vault-binding.ts";
import { CHMOD_CANNOT_DENY } from "../../helpers/platform.ts";
import { makeFleet, type Fleet, type Machine } from "./fixtures/fleet.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const FAST = { settleMs: 0 } as const;
const KILL_CHILD = join(import.meta.dir, "fixtures", "kill-child.ts");
diff --git a/tests/core/store/appender.test.ts b/tests/core/store/appender.test.ts
index e38adf9f..c98f9850 100644
--- a/tests/core/store/appender.test.ts
+++ b/tests/core/store/appender.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
appendFileSync,
existsSync,
@@ -25,6 +25,10 @@ import {
import { openStore } from "../../../src/core/store/store-open.ts";
import { ensureStore, makeTempStore, type TempStore } from "./fixtures/temp-store.ts";
import { neverHeld } from "../../helpers/held-partitions.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const NOV_2026 = Date.UTC(2026, 10, 6, 12, 0, 0);
diff --git a/tests/core/store/dual-write.test.ts b/tests/core/store/dual-write.test.ts
index 596d26e0..c213338f 100644
--- a/tests/core/store/dual-write.test.ts
+++ b/tests/core/store/dual-write.test.ts
@@ -6,7 +6,7 @@
* Every test runs against its own temp HOME, state base, vault and store
* root under one named parent, removed in teardown.
*/
-import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, spyOn, test } from "bun:test";
import {
chmodSync,
existsSync,
@@ -70,6 +70,10 @@ import { readPartition } from "../../../src/core/store/state-digest.ts";
import { deviceStateDirFor, dualWriteStatusPath } from "../../../src/core/store/store-paths.ts";
import { CHMOD_CANNOT_DENY } from "../../helpers/platform.ts";
import { forgetHeldPartitions, moveNeverHeld, neverHeld } from "../../helpers/held-partitions.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const ENV_KEYS = [
STORE_DUAL_WRITE_ENV,
diff --git a/tests/core/store/held-ledger.test.ts b/tests/core/store/held-ledger.test.ts
index 84c3cdbb..f48d3e23 100644
--- a/tests/core/store/held-ledger.test.ts
+++ b/tests/core/store/held-ledger.test.ts
@@ -1,10 +1,14 @@
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { lostHeldPartitions, recordHeldPartitions } from "../../../src/core/store/held-ledger.ts";
import type { PlatformDirsEnv } from "../../../src/core/platform-dirs.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const LEDGER = join(import.meta.dir, "../../../src/core/store/held-ledger.ts");
const dirs: string[] = [];
diff --git a/tests/core/store/safe-fs.test.ts b/tests/core/store/safe-fs.test.ts
index b3bb867f..dac39dac 100644
--- a/tests/core/store/safe-fs.test.ts
+++ b/tests/core/store/safe-fs.test.ts
@@ -6,7 +6,7 @@
* Symlinks need no privilege on POSIX; on Windows creating one does, so
* the symlink cases run where the fixture can be built.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
linkSync,
@@ -32,6 +32,10 @@ import { sha256Hex } from "../../../src/core/integrity/digest.ts";
import { blobPath, partitionDir, shardPath } from "../../../src/core/store/store-paths.ts";
import { IS_WINDOWS } from "../../helpers/platform.ts";
import { makeTempStore, type TempStore } from "./fixtures/temp-store.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const NOV_2026 = Date.UTC(2026, 10, 6, 12, 0, 0);
const NOTE: AppendInput = {
diff --git a/tests/core/store/shard-quarantine.test.ts b/tests/core/store/shard-quarantine.test.ts
index 294176cb..8de66896 100644
--- a/tests/core/store/shard-quarantine.test.ts
+++ b/tests/core/store/shard-quarantine.test.ts
@@ -7,7 +7,7 @@
* record is still left out until the blob arrives, and the migration's
* refusals still see it.
*/
-import { afterEach, describe, expect, spyOn, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, spyOn, test } from "bun:test";
import * as fs from "node:fs";
import {
chmodSync,
@@ -64,6 +64,10 @@ import { partitionDir } from "../../../src/core/store/store-paths.ts";
import { switchDevice } from "../brain/store-only/fixtures.ts";
import { CHMOD_CANNOT_DENY } from "../../helpers/platform.ts";
import { makeStoreEnv, type StoreEnv } from "./fixtures/store-env.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let env: StoreEnv | null = null;
afterEach(() => {
diff --git a/tests/core/store/store-identity.test.ts b/tests/core/store/store-identity.test.ts
index 43449f7e..fdf835f6 100644
--- a/tests/core/store/store-identity.test.ts
+++ b/tests/core/store/store-identity.test.ts
@@ -4,7 +4,7 @@
* later write to another store at the same root, or as another device,
* is refused with the `store-identity` reason; `o2b init` binds again.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { readFileSync, rmSync, writeFileSync } from "node:fs";
import { join } from "node:path";
@@ -13,6 +13,10 @@ import { readStoreBindings, storeIdentityPath } from "../../../src/core/store/st
import { initStore } from "../../../src/core/store/store-init.ts";
import { StoreWriteError, storeWrite } from "../../../src/core/store/store-write.ts";
import { makeStoreEnv, type StoreEnv } from "./fixtures/store-env.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let env: StoreEnv | null = null;
afterEach(() => {
diff --git a/tests/core/store/store-init.test.ts b/tests/core/store/store-init.test.ts
index 828b8d89..c6860ea8 100644
--- a/tests/core/store/store-init.test.ts
+++ b/tests/core/store/store-init.test.ts
@@ -4,7 +4,7 @@
* half-created store with the id it already has, and refuses an existing
* store, a partial one, and partitions of two stores.
*/
-import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, spyOn, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -20,6 +20,10 @@ import { shippedFormatDoc } from "../../../src/core/store/format-doc.ts";
import { initStore, StoreInitRefusal } from "../../../src/core/store/store-init.ts";
import { inspectStore } from "../../../src/core/store/store-open.ts";
import { runCli } from "../../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let parent: string;
let root: string;
diff --git a/tests/core/write-binding.test.ts b/tests/core/write-binding.test.ts
index e9e8f544..fc8bfb68 100644
--- a/tests/core/write-binding.test.ts
+++ b/tests/core/write-binding.test.ts
@@ -28,7 +28,7 @@
* the environment variable underneath the same call.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
mkdirSync,
mkdtempSync,
@@ -58,6 +58,10 @@ import { BrainConfigError } from "../../src/core/brain/policy.ts";
import { validateBrainConfig } from "../../src/core/brain/policy.ts";
import { parseBrainYaml } from "../../src/core/brain/yaml-parse.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** A caller-named note path that no declared prefix in these tests admits. */
const OUTSIDE_PATH = "Elsewhere/Note.md";
diff --git a/tests/discipline/activity-git.test.ts b/tests/discipline/activity-git.test.ts
index c23be398..db50534b 100644
--- a/tests/discipline/activity-git.test.ts
+++ b/tests/discipline/activity-git.test.ts
@@ -1,10 +1,14 @@
-import { describe, expect, test, beforeAll, afterAll } from "bun:test";
+import { afterAll, beforeAll, describe, expect, setDefaultTimeout, test } from "bun:test";
import { execSync } from "node:child_process";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { gitActivity } from "../../src/core/discipline/activity-git.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let repo: string;
diff --git a/tests/discipline/report.test.ts b/tests/discipline/report.test.ts
index 908d4023..f23c8df6 100644
--- a/tests/discipline/report.test.ts
+++ b/tests/discipline/report.test.ts
@@ -1,10 +1,14 @@
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { execSync } from "node:child_process";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runDisciplineReport } from "../../src/core/discipline/report.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
describe("runDisciplineReport", () => {
test("end-to-end: empty log + active repo → alert text emitted", () => {
diff --git a/tests/e2e/brain-capture-and-fields.test.ts b/tests/e2e/brain-capture-and-fields.test.ts
index 6a65b038..bbd39016 100644
--- a/tests/e2e/brain-capture-and-fields.test.ts
+++ b/tests/e2e/brain-capture-and-fields.test.ts
@@ -12,12 +12,16 @@
* If any step fails, the chain breaks and we see which seam is broken.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/e2e/index-freshen.test.ts b/tests/e2e/index-freshen.test.ts
index b6045776..55779a40 100644
--- a/tests/e2e/index-freshen.test.ts
+++ b/tests/e2e/index-freshen.test.ts
@@ -4,13 +4,17 @@
* a background `o2b search index --freshen`; once that run has recorded
* its outcome, the next search finds the note. No test seam is used.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { FRESHEN_CLAIM_FILE, readFreshenState } from "../../src/core/search/freshen.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
@@ -44,8 +48,15 @@ test(
expect(JSON.parse(first.stdout).results ?? []).toHaveLength(0);
const derived = join(vault, ".open-second-brain");
+ // The run has ended once its outcome is recorded AND its claim is
+ // released. The child records the outcome first, then settles any
+ // pending marker, then releases, so waiting on the outcome alone left
+ // the claim assertion below racing the child's last steps.
+ const ended = (): boolean =>
+ readFreshenState(derived).lastOutcome !== null &&
+ !existsSync(join(derived, FRESHEN_CLAIM_FILE));
const deadline = Date.now() + 30_000;
- while (readFreshenState(derived).lastOutcome === null && Date.now() < deadline) {
+ while (!ended() && Date.now() < deadline) {
await Bun.sleep(200);
}
const state = readFreshenState(derived);
diff --git a/tests/e2e/memory-observability.integration.test.ts b/tests/e2e/memory-observability.integration.test.ts
index f441481c..0a340954 100644
--- a/tests/e2e/memory-observability.integration.test.ts
+++ b/tests/e2e/memory-observability.integration.test.ts
@@ -7,7 +7,7 @@
* repo fixture reports quality / latency / context cost separately.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -18,6 +18,10 @@ import { CONTINUITY_SCHEMA_VERSION } from "../../src/core/brain/continuity/types
import { appendContinuityRecord } from "../../src/core/brain/continuity/store.ts";
import { runCli } from "../helpers/run-cli.ts";
import { RECALL_CHANNEL } from "../../src/core/brain/recall-telemetry.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/e2e/project-history.integration.test.ts b/tests/e2e/project-history.integration.test.ts
index c0ea436f..6e8ed360 100644
--- a/tests/e2e/project-history.integration.test.ts
+++ b/tests/e2e/project-history.integration.test.ts
@@ -5,7 +5,7 @@
* edit survival.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { execFileSync } from "node:child_process";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -15,6 +15,10 @@ import { generateArchDocs } from "../../src/core/brain/architect/generate.ts";
import { mineCommitDecisions } from "../../src/core/brain/git/decisions.ts";
import { ingestGitHistory } from "../../src/core/brain/git/ingest.ts";
import { gitStoreDir, listGitCommits } from "../../src/core/brain/git/store.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let repo: string;
diff --git a/tests/e2e/v0.10.10-pull-channels.test.ts b/tests/e2e/v0.10.10-pull-channels.test.ts
index 0bea47a4..c82f40da 100644
--- a/tests/e2e/v0.10.10-pull-channels.test.ts
+++ b/tests/e2e/v0.10.10-pull-channels.test.ts
@@ -16,13 +16,17 @@
* If any seam between CLI / core / MCP breaks, the chain surfaces it.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { runCli } from "../helpers/run-cli.ts";
import { JSONRPC_VERSION, MCPServer, PROTOCOL_VERSION } from "../../src/mcp/index.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/e2e/workspace-insight.integration.test.ts b/tests/e2e/workspace-insight.integration.test.ts
index 3313817a..6b9babc8 100644
--- a/tests/e2e/workspace-insight.integration.test.ts
+++ b/tests/e2e/workspace-insight.integration.test.ts
@@ -6,13 +6,17 @@
* brief deliver pending triggers once.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { createTriggers } from "../../src/core/brain/triggers/store.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let tmp: string;
let vault: string;
diff --git a/tests/helpers/inflight-recorder.ts b/tests/helpers/inflight-recorder.ts
new file mode 100644
index 00000000..e3648d1f
--- /dev/null
+++ b/tests/helpers/inflight-recorder.ts
@@ -0,0 +1,73 @@
+/**
+ * Records, per test process, which test file and which test of it is
+ * running right now, so a suite that stops making progress can say where.
+ *
+ * A test that blocks its process synchronously (a busy loop, or a runtime
+ * call that never returns, like the `spawnSync` that spun forever under
+ * `--isolate` before Bun 1.4.3) cannot be stopped by bun's per-test
+ * timeout: the timer that would fire runs on the same thread. Under
+ * `--parallel` the worker then never reports the file done and the run
+ * waits on it in silence, with nothing in the log that names the file. The
+ * CI wrapper `.github/scripts/test-watchdog.sh` sets
+ * {@link INFLIGHT_DIR_ENV}, and when the suite outlives its bound it
+ * prints these records before it stops the run.
+ *
+ * One small file per process (`<pid>.txt`), overwritten in place, holding
+ * one line: `loading <file>`, `running <file> test #<n>` or
+ * `idle after <file> test #<n>`, each with the time it was written. Off
+ * unless the variable is set, so a local run writes nothing.
+ */
+import { afterEach, beforeEach } from "bun:test";
+import { mkdirSync, writeFileSync } from "node:fs";
+import { join, relative } from "node:path";
+
+// The originals, taken when the preload loads and before any test runs:
+// tests that spy on `fs.writeFileSync` and assert what was written must not
+// see the recorder's own writes. A named import is a live binding, so it
+// would follow the spy; these constants do not.
+const rawMkdirSync = mkdirSync;
+const rawWriteFileSync = writeFileSync;
+
+/** Directory the records go to; recording is off when it is unset or empty. */
+export const INFLIGHT_DIR_ENV = "O2B_TEST_INFLIGHT_DIR";
+
+export function installInflightRecorder(env: NodeJS.ProcessEnv = process.env): void {
+ const dir = env[INFLIGHT_DIR_ENV];
+ if (dir === undefined || dir === "") return;
+ try {
+ rawMkdirSync(dir, { recursive: true });
+ } catch {
+ // A diagnostic must never fail a test; the writes below fail quietly too.
+ }
+ const record = join(dir, `${process.pid}.txt`);
+ const write = (line: string): void => {
+ try {
+ rawWriteFileSync(record, `${line} (${new Date().toISOString()})\n`);
+ } catch {
+ // A diagnostic must never fail a test.
+ }
+ };
+ const currentFile = (): string => relative(process.cwd(), Bun.main);
+
+ // Under `--parallel` (which implies `--isolate`) the preload runs again
+ // for every file, so this line also covers a file stuck before its
+ // first test: in its imports or in a `beforeAll`.
+ let file = currentFile();
+ let index = 0;
+ write(`loading ${file}`);
+
+ // A serial run evaluates the preload once and these hooks see every
+ // file, so the file name is re-read per test rather than kept.
+ beforeEach(() => {
+ const now = currentFile();
+ if (now !== file) {
+ file = now;
+ index = 0;
+ }
+ index += 1;
+ write(`running ${file} test #${index}`);
+ });
+ afterEach(() => {
+ write(`idle after ${file} test #${index}`);
+ });
+}
diff --git a/tests/hooks/active-inject-ledger.test.ts b/tests/hooks/active-inject-ledger.test.ts
index fda91650..264d704a 100644
--- a/tests/hooks/active-inject-ledger.test.ts
+++ b/tests/hooks/active-inject-ledger.test.ts
@@ -10,7 +10,7 @@
* install gets no new disk write. Every write is fail-soft.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -33,6 +33,10 @@ import {
} from "../../hooks/lib/injection-ledger.ts";
import { homeEnv } from "../helpers/platform.ts";
import { waitForSelfHealChildren } from "../helpers/self-heal-children.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/active-inject-meter.test.ts b/tests/hooks/active-inject-meter.test.ts
index df4a68fd..80d1628f 100644
--- a/tests/hooks/active-inject-meter.test.ts
+++ b/tests/hooks/active-inject-meter.test.ts
@@ -6,7 +6,7 @@
* emitted context and the exit code are what they were without the meter.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -28,6 +28,10 @@ import {
SOURCE_ACTIVE_BODY,
SOURCE_LESSONS_BODY,
} from "../../hooks/lib/active-context.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/active-inject-receipt-session.test.ts b/tests/hooks/active-inject-receipt-session.test.ts
index 6e970c53..b3ad3e6c 100644
--- a/tests/hooks/active-inject-receipt-session.test.ts
+++ b/tests/hooks/active-inject-receipt-session.test.ts
@@ -11,7 +11,7 @@
* exit code are exactly what they were without the key.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -26,6 +26,10 @@ import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { homeEnv } from "../helpers/platform.ts";
import { waitForSelfHealChildren } from "../helpers/self-heal-children.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/active-inject-reground.test.ts b/tests/hooks/active-inject-reground.test.ts
index 83caa8b6..16951e63 100644
--- a/tests/hooks/active-inject-reground.test.ts
+++ b/tests/hooks/active-inject-reground.test.ts
@@ -8,7 +8,7 @@
* single payload exactly as before.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -30,6 +30,10 @@ import {
import { hookStateFilePath } from "../../hooks/lib/session-state.ts";
import { homeEnv } from "../helpers/platform.ts";
import { waitForSelfHealChildren } from "../helpers/self-heal-children.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/active-inject-scoped-rules.test.ts b/tests/hooks/active-inject-scoped-rules.test.ts
index 6e38c7c8..09964c98 100644
--- a/tests/hooks/active-inject-scoped-rules.test.ts
+++ b/tests/hooks/active-inject-scoped-rules.test.ts
@@ -9,7 +9,7 @@
* file injects byte-for-byte what the same vault without it injects.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -38,6 +38,10 @@ import { SOURCE_ACTIVE_BODY } from "../../hooks/lib/active-context.ts";
import { writeVaultPointer } from "../../src/core/brain/portability/pointer.ts";
import { homeEnv } from "../helpers/platform.ts";
import { waitForSelfHealChildren } from "../helpers/self-heal-children.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/active-inject.test.ts b/tests/hooks/active-inject.test.ts
index d23a6a92..6d98c416 100644
--- a/tests/hooks/active-inject.test.ts
+++ b/tests/hooks/active-inject.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
@@ -8,6 +8,10 @@ import { CHMOD_CANNOT_DENY, homeEnv } from "../helpers/platform.ts";
import { waitForSelfHealChildren } from "../helpers/self-heal-children.ts";
import { untrustedBindingFramingHeader } from "../../src/core/brain/untrusted-source.ts";
import { SOURCE_ACTIVE_BODY, SOURCE_LESSONS_BODY } from "../../hooks/lib/active-context.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/answer-quote-check.test.ts b/tests/hooks/answer-quote-check.test.ts
index 680afde5..cd91a277 100644
--- a/tests/hooks/answer-quote-check.test.ts
+++ b/tests/hooks/answer-quote-check.test.ts
@@ -10,7 +10,7 @@
* once-per-turn), and that a checked turn never edits the transcript.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -46,6 +46,10 @@ import {
} from "../../src/core/brain/answer-quotes/check.ts";
import { untrustedFramingHeader } from "../../src/core/brain/untrusted-source.ts";
import { QUOTE_SPAN_PREVIEW_MAX_CHARS } from "../../src/core/brain/distill/quote-verdict.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/backlog-nudge.test.ts b/tests/hooks/backlog-nudge.test.ts
index 5f83f9cf..4a43143e 100644
--- a/tests/hooks/backlog-nudge.test.ts
+++ b/tests/hooks/backlog-nudge.test.ts
@@ -13,7 +13,7 @@
* stays byte-identical. Every path exits 0.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
@@ -27,6 +27,10 @@ import { DERIVED_STORE_DIR } from "../../src/core/brain/path-constants.ts";
import { atomicWriteFileSync } from "../../src/core/fs-atomic.ts";
import { SESSION_RUNTIME_ID } from "../../src/core/runtime/host-facts.ts";
import { homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOKS_DIR = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "hooks");
const NOW = new Date("2026-09-18T10:00:00Z");
diff --git a/tests/hooks/counterparty-brief.test.ts b/tests/hooks/counterparty-brief.test.ts
index 46e8b239..efcada5f 100644
--- a/tests/hooks/counterparty-brief.test.ts
+++ b/tests/hooks/counterparty-brief.test.ts
@@ -15,7 +15,7 @@
* refusal (`no_trigger`, `no_match`, `ambiguous`), never a blanket one.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
chmodSync,
existsSync,
@@ -37,6 +37,10 @@ import { REMOTE_DENY_VISIBILITY_TOKEN } from "../../src/core/graph/visibility.ts
import { readBriefDelivered } from "../../hooks/lib/injection-ledger.ts";
import { hookStateFilePath } from "../../hooks/lib/session-state.ts";
import { CHMOD_CANNOT_DENY, homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOKS_DIR = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "hooks");
diff --git a/tests/hooks/gap-loop.test.ts b/tests/hooks/gap-loop.test.ts
index c22990d4..2116e1bc 100644
--- a/tests/hooks/gap-loop.test.ts
+++ b/tests/hooks/gap-loop.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -33,6 +33,10 @@ import { brainGapTasksDir } from "../../src/core/brain/paths.ts";
import { RETRIEVAL_DEGRADATION } from "../../src/core/search/retrieval-trail.ts";
import { writeFrontmatterAtomic } from "../../src/core/vault.ts";
import { homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOKS_DIR = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "hooks");
diff --git a/tests/hooks/hooks-json-shape.test.ts b/tests/hooks/hooks-json-shape.test.ts
index 4d2af55c..51fa4103 100644
--- a/tests/hooks/hooks-json-shape.test.ts
+++ b/tests/hooks/hooks-json-shape.test.ts
@@ -7,11 +7,15 @@
* form is forbidden because it relies solely on a PATH symlink that goes stale
* across plugin updates.
*/
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawnSync } from "node:child_process";
import { existsSync, readFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const REPO = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
const HOOKS_JSON = join(REPO, "hooks", "hooks.json");
diff --git a/tests/hooks/hygiene-digest-store-only.test.ts b/tests/hooks/hygiene-digest-store-only.test.ts
index 7cd47a46..560bc9aa 100644
--- a/tests/hooks/hygiene-digest-store-only.test.ts
+++ b/tests/hooks/hygiene-digest-store-only.test.ts
@@ -4,7 +4,7 @@
* the device-local state, nothing is written into the vault, and a second
* Stop over the same findings reads it back and stays quiet.
*/
-import { afterEach, expect, test } from "bun:test";
+import { afterEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, readdirSync, writeFileSync } from "node:fs";
import { basename, dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
@@ -14,6 +14,10 @@ import { STORE_ROOT_ENV } from "../../src/core/store/constants.ts";
import { HYGIENE_DIGEST_HASH_FILENAME } from "../../hooks/lib/hygiene-digest-state.ts";
import { homeEnv } from "../helpers/platform.ts";
import { makeStoreEnv, type StoreEnv } from "../core/store/fixtures/store-env.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/hygiene-digest.test.ts b/tests/hooks/hygiene-digest.test.ts
index c88f59c7..9e5b0a56 100644
--- a/tests/hooks/hygiene-digest.test.ts
+++ b/tests/hooks/hygiene-digest.test.ts
@@ -13,7 +13,7 @@
* `warning`) - the smallest eligible population the composer accepts.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
@@ -30,6 +30,10 @@ import {
HYGIENE_DIGEST_SEVERITIES,
} from "../../hooks/lib/hygiene-digest-text.ts";
import { homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/log-catchup.test.ts b/tests/hooks/log-catchup.test.ts
index 8a728ab4..60b11e2d 100644
--- a/tests/hooks/log-catchup.test.ts
+++ b/tests/hooks/log-catchup.test.ts
@@ -10,7 +10,7 @@
* byte-identical after every run.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdtempSync,
@@ -36,6 +36,10 @@ import {
LOG_CATCHUP_WINDOW_DATES,
} from "../../hooks/lib/log-cursor-state.ts";
import { homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/nav-inject.test.ts b/tests/hooks/nav-inject.test.ts
index 3a08e53c..a93c7d9f 100644
--- a/tests/hooks/nav-inject.test.ts
+++ b/tests/hooks/nav-inject.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -15,6 +15,10 @@ import { fileURLToPath } from "node:url";
import { indexVault } from "../../src/core/search/indexer.ts";
import { makeConfig } from "../helpers/search-fixtures.ts";
import { homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "hooks", "nav-inject.ts");
diff --git a/tests/hooks/no-vault-hooks.test.ts b/tests/hooks/no-vault-hooks.test.ts
index cd3360c4..51d4c82c 100644
--- a/tests/hooks/no-vault-hooks.test.ts
+++ b/tests/hooks/no-vault-hooks.test.ts
@@ -8,7 +8,7 @@
* catch-up, gaps, sub-agent context) have a behaviour test each; the
* matrix runs every hook `hooks/hooks.json` registers.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
@@ -20,6 +20,10 @@ import { STORE_DUAL_WRITE_ENV, STORE_ROOT_ENV } from "../../src/core/store/const
import { readPartition } from "../../src/core/store/state-digest.ts";
import { makeStoreEnv, type StoreEnv } from "../core/store/fixtures/store-env.ts";
import { treeEntries } from "../helpers/vault-digest.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOKS = join(import.meta.dir, "..", "..", "hooks");
diff --git a/tests/hooks/o2b-hook.test.ts b/tests/hooks/o2b-hook.test.ts
index cea787c9..264ab660 100644
--- a/tests/hooks/o2b-hook.test.ts
+++ b/tests/hooks/o2b-hook.test.ts
@@ -8,7 +8,7 @@
* own (possibly stale-symlinked) location, so a stale ~/.local/bin link
* cannot strand the hook on an old plugin version.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawnSync } from "node:child_process";
import {
chmodSync,
@@ -22,6 +22,10 @@ import {
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const REPO = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
const WRAPPER = join(REPO, "scripts", "o2b-hook");
diff --git a/tests/hooks/post-write-reminder.test.ts b/tests/hooks/post-write-reminder.test.ts
index 033007d8..8e4a77a9 100644
--- a/tests/hooks/post-write-reminder.test.ts
+++ b/tests/hooks/post-write-reminder.test.ts
@@ -1,8 +1,12 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/pretool-orient.test.ts b/tests/hooks/pretool-orient.test.ts
index 17a56bd1..9ab90b61 100644
--- a/tests/hooks/pretool-orient.test.ts
+++ b/tests/hooks/pretool-orient.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
existsSync,
mkdirSync,
@@ -12,6 +12,10 @@ import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/recall-inject-decision-model.test.ts b/tests/hooks/recall-inject-decision-model.test.ts
index c96b2c58..1d0961f7 100644
--- a/tests/hooks/recall-inject-decision-model.test.ts
+++ b/tests/hooks/recall-inject-decision-model.test.ts
@@ -10,7 +10,16 @@
* timeout never turns an injection into an empty one.
*/
-import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from "bun:test";
+import {
+ afterAll,
+ afterEach,
+ beforeAll,
+ beforeEach,
+ describe,
+ expect,
+ setDefaultTimeout,
+ test,
+} from "bun:test";
import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
@@ -23,6 +32,10 @@ import { resolveSearchConfig } from "../../src/core/search/index.ts";
import { FAKE_DECISION_KEY } from "../helpers/fake-credentials.ts";
import { homeEnv } from "../helpers/platform.ts";
import { createTempVault, writeMd } from "../helpers/search-fixtures.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/recall-inject-dedupe.test.ts b/tests/hooks/recall-inject-dedupe.test.ts
index cb7f287b..d84d2677 100644
--- a/tests/hooks/recall-inject-dedupe.test.ts
+++ b/tests/hooks/recall-inject-dedupe.test.ts
@@ -4,7 +4,7 @@
* operator-declared slices from `_brain.yaml`.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
@@ -16,6 +16,10 @@ import { beginInjectionEpoch, readRecallInjected } from "../../hooks/lib/injecti
import { hookStateFilePath } from "../../hooks/lib/session-state.ts";
import { homeEnv } from "../helpers/platform.ts";
import { createTempVault, writeMd } from "../helpers/search-fixtures.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/recall-inject.test.ts b/tests/hooks/recall-inject.test.ts
index 3054952a..b770040f 100644
--- a/tests/hooks/recall-inject.test.ts
+++ b/tests/hooks/recall-inject.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
@@ -15,6 +15,10 @@ import {
} from "../../src/core/brain/recall-inject.ts";
import { listRecallTelemetry, RECALL_CHANNEL } from "../../src/core/brain/recall-telemetry.ts";
import { homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
@@ -65,6 +69,16 @@ async function runHook(payload: unknown, env: Record<string, string> = {}): Prom
return { stdout, stderr, exit };
}
+/**
+ * The retrieval budget the tests that assert a decision ran give the hook:
+ * the highest value the setting accepts. The default (2.5 s) is a product
+ * bound for an interactive prompt; on a loaded Windows runner the cold
+ * retrieval of a fresh vault outlived it and the hook rightly audited a
+ * `timeout` error, which failed tests that are about the cap settings, not
+ * about the clock. A valid value, so it never shows up in `config_invalid`.
+ */
+const ROOMY_TIME_BUDGET = { OPEN_SECOND_BRAIN_RECALL_INJECT_TIME_BUDGET_MS: "6000" } as const;
+
function auditRecords(): Array<Record<string, unknown>> {
const dir = hookAuditDir(vault);
if (!existsSync(dir)) return [];
@@ -101,6 +115,7 @@ describe("recall-inject hook", () => {
VAULT_DIR: vault,
OPEN_SECOND_BRAIN_RECALL_INJECT_ENABLED: "true",
OPEN_SECOND_BRAIN_RECALL_INJECT_MAX_NOTES: "99",
+ ...ROOMY_TIME_BUDGET,
},
);
expect(r.exit).toBe(0);
@@ -113,7 +128,7 @@ describe("recall-inject hook", () => {
test("valid caps leave config_invalid off the audit line", async () => {
await runHook(
{ hook_event_name: "UserPromptSubmit", prompt: "how do receipts work" },
- { VAULT_DIR: vault, OPEN_SECOND_BRAIN_RECALL_INJECT_ENABLED: "true" },
+ { VAULT_DIR: vault, OPEN_SECOND_BRAIN_RECALL_INJECT_ENABLED: "true", ...ROOMY_TIME_BUDGET },
);
const record = auditRecords().find((rec) => rec["actor"] === "recall-inject");
expect(record).toBeDefined();
diff --git a/tests/hooks/reground-deliver.test.ts b/tests/hooks/reground-deliver.test.ts
index 47c8cd6d..c993cb0b 100644
--- a/tests/hooks/reground-deliver.test.ts
+++ b/tests/hooks/reground-deliver.test.ts
@@ -5,7 +5,7 @@
* stays silent everywhere else.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
chmodSync,
existsSync,
@@ -28,6 +28,10 @@ import { LEDGER_KEY_REGROUND, beginInjectionEpoch } from "../../hooks/lib/inject
import { hookStateFilePath, readHookStamp } from "../../hooks/lib/session-state.ts";
import { hookAuditDir } from "../../src/core/brain/paths.ts";
import { CHMOD_CANNOT_DENY, homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/reground-take-concurrency.test.ts b/tests/hooks/reground-take-concurrency.test.ts
index 0f7d181d..8ce7a93b 100644
--- a/tests/hooks/reground-take-concurrency.test.ts
+++ b/tests/hooks/reground-take-concurrency.test.ts
@@ -4,7 +4,7 @@
* is a separate bun process racing `takeRegroundPart` on one seeded queue.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, utimesSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
@@ -15,6 +15,10 @@ import {
hookStateFilePath,
readHookStamp,
} from "../../hooks/lib/session-state.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const LEDGER_MODULE = resolve(import.meta.dir, "../../hooks/lib/injection-ledger.ts");
const SESSION = "race-session";
diff --git a/tests/hooks/session-capture.test.ts b/tests/hooks/session-capture.test.ts
index 24fe254f..b932e7f9 100644
--- a/tests/hooks/session-capture.test.ts
+++ b/tests/hooks/session-capture.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawnSync } from "node:child_process";
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -7,6 +7,10 @@ import { fileURLToPath } from "node:url";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { IS_WINDOWS, homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/stop-log-guardrail.test.ts b/tests/hooks/stop-log-guardrail.test.ts
index be8557a1..e69ae9ce 100644
--- a/tests/hooks/stop-log-guardrail.test.ts
+++ b/tests/hooks/stop-log-guardrail.test.ts
@@ -1,10 +1,14 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { STOP_GUARDRAIL_TEXT } from "../../hooks/lib/messages.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/subagent-inject.test.ts b/tests/hooks/subagent-inject.test.ts
index b9997bd5..2fa2f2c5 100644
--- a/tests/hooks/subagent-inject.test.ts
+++ b/tests/hooks/subagent-inject.test.ts
@@ -12,7 +12,7 @@
* module surface.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import {
chmodSync,
existsSync,
@@ -48,6 +48,10 @@ import { readScopedRules, scopedRuleKey } from "../../src/core/brain/scoped-rule
import { STANDING_RULES_MAX_CHARS_DEFAULT } from "../../src/core/brain/standing-rules.ts";
import { parseFrontmatterText } from "../../src/core/vault.ts";
import { CHMOD_CANNOT_DENY, homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/hooks/subagent-stop.test.ts b/tests/hooks/subagent-stop.test.ts
index f347b9c8..f7c2a3e8 100644
--- a/tests/hooks/subagent-stop.test.ts
+++ b/tests/hooks/subagent-stop.test.ts
@@ -15,7 +15,7 @@
* write that never happened.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, readdirSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
@@ -24,6 +24,10 @@ import { fileURLToPath } from "node:url";
import { bootstrapBrain } from "../../src/core/brain/init.ts";
import { captureSessionLifecycleEvent } from "../../src/core/brain/session-lifecycle.ts";
import { homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const REPO = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
const HOOKS_JSON = join(REPO, "hooks", "hooks.json");
diff --git a/tests/hooks/view-render.test.ts b/tests/hooks/view-render.test.ts
index 39df3960..6d091021 100644
--- a/tests/hooks/view-render.test.ts
+++ b/tests/hooks/view-render.test.ts
@@ -3,7 +3,7 @@
* human view, prints nothing and exits 0; a failure is one line in the
* device-local hook audit, and the hook still exits 0.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
@@ -16,6 +16,10 @@ import { VIEW_AUTO_PASS_FILE, VIEW_STATE_DIR } from "../../src/core/view/constan
import { runViewPass } from "../../src/core/view/render.ts";
import { claimViewWriter } from "../../src/core/view/writer.ts";
import { homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOKS_DIR = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "hooks");
diff --git a/tests/mcp/context-receipts-reach.test.ts b/tests/mcp/context-receipts-reach.test.ts
index f20b608d..0d49558b 100644
--- a/tests/mcp/context-receipts-reach.test.ts
+++ b/tests/mcp/context-receipts-reach.test.ts
@@ -11,7 +11,7 @@
* them. At local reach the rules stay visible.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
@@ -27,6 +27,10 @@ import { TRANSPORT_REACH } from "../../src/core/graph/transport-reach.ts";
import { JSONRPC_VERSION, MCPServer, PROTOCOL_VERSION } from "../../src/mcp/index.ts";
import type { MCPServerRuntimeOptions } from "../../src/mcp/server.ts";
import { homeEnv } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const HOOK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/mcp/extract-signals-prefilter-tool.test.ts b/tests/mcp/extract-signals-prefilter-tool.test.ts
index e07e4144..06ff2fdb 100644
--- a/tests/mcp/extract-signals-prefilter-tool.test.ts
+++ b/tests/mcp/extract-signals-prefilter-tool.test.ts
@@ -12,7 +12,15 @@
* 5. The commit accepts `source_turn` through the tool's input schema.
*/
-import { afterAll, afterEach, beforeAll, beforeEach, expect, test } from "bun:test";
+import {
+ afterAll,
+ afterEach,
+ beforeAll,
+ beforeEach,
+ expect,
+ setDefaultTimeout,
+ test,
+} from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -31,6 +39,10 @@ import {
type FakeSystemOne,
} from "../helpers/fake-decision-provider.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const TOOL = "brain_extract_signals";
const SESSION = "sess-mcp-prefilter";
diff --git a/tests/mcp/extract-signals-tool.test.ts b/tests/mcp/extract-signals-tool.test.ts
index 5f951be4..3c7966f7 100644
--- a/tests/mcp/extract-signals-tool.test.ts
+++ b/tests/mcp/extract-signals-tool.test.ts
@@ -20,7 +20,7 @@
* response by name.
*/
-import { afterEach, beforeEach, expect, test } from "bun:test";
+import { afterEach, beforeEach, expect, setDefaultTimeout, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
@@ -32,6 +32,10 @@ import { importSessionRecall } from "../../src/core/brain/session-recall.ts";
import { buildToolTable, findTool } from "../../src/mcp/tools.ts";
import type { ServerContext } from "../../src/mcp/tool-contract.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const TOOL = "brain_extract_signals";
const SESSION = "sess-mcp";
diff --git a/tests/mcp/maintenance-parity-census.test.ts b/tests/mcp/maintenance-parity-census.test.ts
index a249255e..2b160bd0 100644
--- a/tests/mcp/maintenance-parity-census.test.ts
+++ b/tests/mcp/maintenance-parity-census.test.ts
@@ -46,7 +46,7 @@
* `LANE_TASK`, so a fifth task is added in one place or not at all.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -83,6 +83,10 @@ import { INVALID_PARAMS } from "../../src/mcp/protocol.ts";
import { homeEnv } from "../helpers/platform.ts";
import { runCli } from "../helpers/run-cli.ts";
import { lexSource } from "../helpers/source-lexer.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const ROOT = join(import.meta.dir, "..", "..");
const CLI_VERB = join(ROOT, "src", "cli", "brain", "verbs", "maintenance.ts");
diff --git a/tests/mcp/note-history-tool.test.ts b/tests/mcp/note-history-tool.test.ts
index 95a938b4..8043bf16 100644
--- a/tests/mcp/note-history-tool.test.ts
+++ b/tests/mcp/note-history-tool.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { execFileSync } from "node:child_process";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -7,6 +7,10 @@ import { basename, join } from "node:path";
import { TRANSPORT_REACH } from "../../src/core/graph/transport-reach.ts";
import { JSONRPC_VERSION, MCPServer, PROTOCOL_VERSION } from "../../src/mcp/index.ts";
import { buildToolTable } from "../../src/mcp/tools.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let vault: string;
diff --git a/tests/mcp/reach-readable.test.ts b/tests/mcp/reach-readable.test.ts
index 31818db9..cd547a35 100644
--- a/tests/mcp/reach-readable.test.ts
+++ b/tests/mcp/reach-readable.test.ts
@@ -5,7 +5,7 @@
* as unreadable here exactly as it does on every read surface.
*/
-import { beforeEach, describe, expect, test } from "bun:test";
+import { beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawnSync } from "node:child_process";
import { mkdirSync, writeFileSync } from "node:fs";
import { basename, join } from "node:path";
@@ -16,6 +16,10 @@ import { readableAtContextReach } from "../../src/mcp/brain/reach-readable.ts";
import type { ServerContext } from "../../src/mcp/tool-contract.ts";
import { IS_WINDOWS } from "../helpers/platform.ts";
import { pinHome, tempDirs } from "../helpers/temp-dir.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const mkTemp = tempDirs();
pinHome("o2b-reach-readable-home-");
diff --git a/tests/mcp/runtime-capabilities.test.ts b/tests/mcp/runtime-capabilities.test.ts
index 66f904fd..906c04d4 100644
--- a/tests/mcp/runtime-capabilities.test.ts
+++ b/tests/mcp/runtime-capabilities.test.ts
@@ -1,4 +1,4 @@
-import { describe, expect, test } from "bun:test";
+import { describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -6,6 +6,10 @@ import { join } from "node:path";
import { JSONRPC_VERSION, MCPServer, PROTOCOL_VERSION } from "../../src/mcp/index.ts";
import { WITHHELD_BLOCK_HEADING } from "../../src/mcp/instruction-segments.ts";
import { runCli } from "../helpers/run-cli.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
/** Any path: nothing in these tests reads the vault. */
const VAULT = "/tmp/o2b-runtime-capability-test";
diff --git a/tests/openclaw/bundle-node.test.ts b/tests/openclaw/bundle-node.test.ts
index 3b71379e..575cfc53 100644
--- a/tests/openclaw/bundle-node.test.ts
+++ b/tests/openclaw/bundle-node.test.ts
@@ -14,11 +14,15 @@
* place the bundle used to call `Bun.sleepSync`.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { cpSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
const BUNDLE = join(ROOT, "openclaw", "index.js");
diff --git a/tests/plugins/opencode-plugin.test.ts b/tests/plugins/opencode-plugin.test.ts
index 49d675a6..748539d9 100644
--- a/tests/plugins/opencode-plugin.test.ts
+++ b/tests/plugins/opencode-plugin.test.ts
@@ -9,7 +9,7 @@
* into opencode.
*/
-import { describe, expect, test, beforeEach, afterEach } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, readFileSync, writeFileSync, existsSync, chmodSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -19,6 +19,10 @@ import OpenSecondBrain from "../../plugins/opencode/open-second-brain.ts";
import { detectHookRuntime } from "../../hooks/lib/detect.ts";
import { decideOrient } from "../../src/core/brain/pretool-orient.ts";
import { decideHostBackup } from "../../src/core/brain/pretool-host-backup.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
let spoolDir: string;
let binDir: string;
diff --git a/tests/scripts/bun-precheck.test.ts b/tests/scripts/bun-precheck.test.ts
index 30f87f6a..ce0cb739 100644
--- a/tests/scripts/bun-precheck.test.ts
+++ b/tests/scripts/bun-precheck.test.ts
@@ -8,11 +8,15 @@
* installed at the standard location and simply not on the search path.
*/
-import { afterEach, describe, expect, test } from "bun:test";
+import { afterEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { chmodSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const PRECHECK = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/scripts/macos-sqlite-shim.test.ts b/tests/scripts/macos-sqlite-shim.test.ts
index 187e4f9c..62d5d81b 100644
--- a/tests/scripts/macos-sqlite-shim.test.ts
+++ b/tests/scripts/macos-sqlite-shim.test.ts
@@ -8,11 +8,15 @@
* are intentional test seams baked into the shim.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const SHIM = resolve(
dirname(fileURLToPath(import.meta.url)),
diff --git a/tests/scripts/sync-plugin-mirrors.test.ts b/tests/scripts/sync-plugin-mirrors.test.ts
index 777efd75..49d5986f 100644
--- a/tests/scripts/sync-plugin-mirrors.test.ts
+++ b/tests/scripts/sync-plugin-mirrors.test.ts
@@ -7,7 +7,7 @@
* users as nothing at all.
*/
-import { afterEach, beforeEach, describe, expect, test } from "bun:test";
+import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawnSync } from "node:child_process";
import {
existsSync,
@@ -33,6 +33,10 @@ import {
withAbsoluteLinks,
writeMirrors,
} from "../../scripts/sync-plugin-mirrors.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const REPO_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
diff --git a/tests/scripts/windows-launchers.test.ts b/tests/scripts/windows-launchers.test.ts
index 2a7efb20..ed47efe9 100644
--- a/tests/scripts/windows-launchers.test.ts
+++ b/tests/scripts/windows-launchers.test.ts
@@ -17,7 +17,7 @@
* Windows only; the POSIX launchers have no such lookup.
*/
-import { afterAll, beforeAll, describe, expect, test } from "bun:test";
+import { afterAll, beforeAll, describe, expect, setDefaultTimeout, test } from "bun:test";
import { spawnSync } from "node:child_process";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -26,6 +26,10 @@ import { dirname, join, resolve } from "node:path";
import { installCliWindows } from "../../src/cli/install-cli-windows.ts";
import { launcherCommand, WINDOWS_LAUNCHER_ENV } from "../../src/core/install/payload.ts";
import { IS_WINDOWS } from "../helpers/platform.ts";
+import { CLI_SPAWN_BUDGET_MS } from "../helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const REPO = resolve(import.meta.dir, "..", "..");
const SCRIPTS = join(REPO, "scripts");
diff --git a/tests/setup-env-scrub.test.ts b/tests/setup-env-scrub.test.ts
index 588240da..4386c8af 100644
--- a/tests/setup-env-scrub.test.ts
+++ b/tests/setup-env-scrub.test.ts
@@ -5,10 +5,14 @@
* exports them. Proved in a child `bun test` run so the variables are
* really present at preload time.
*/
-import { afterEach, expect, test } from "bun:test";
+import { afterEach, expect, setDefaultTimeout, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
+import { CLI_SPAWN_BUDGET_MS } from "./helpers/cli-timeout.ts";
+
+// Tests here spawn processes; see tests/helpers/cli-timeout.ts.
+setDefaultTimeout(CLI_SPAWN_BUDGET_MS);
const LEAKED = "OPEN_SECOND_BRAIN_EMBEDDING_MODEL";
const KEEP_OPT_OUT = "O2B_TEST_KEEP_EMBEDDING_ENV";
diff --git a/tests/setup.ts b/tests/setup.ts
index 8698ffb1..04381865 100644
--- a/tests/setup.ts
+++ b/tests/setup.ts
@@ -57,6 +57,7 @@ import { clearOriginChannel } from "../src/core/origin-channel.ts";
import { MARKDOWN_NEUTRALIZE_MODE_ENV } from "../src/core/brain/text/neutralize-markdown.ts";
import { forgetMachineStateCache } from "../src/core/state/machine-state.ts";
import { storeWriteStatusPath } from "../src/core/store/store-write.ts";
+import { installInflightRecorder } from "./helpers/inflight-recorder.ts";
import { DEFAULT_STORE_ROOT_ENV } from "./helpers/test-store.ts";
import { TEST_DEVICE_ID } from "./helpers/test-vault.ts";
@@ -103,6 +104,24 @@ if (process.env["O2B_DEVICE_ID"] === undefined) {
process.env["O2B_DEVICE_ID"] = TEST_DEVICE_ID;
}
+// Under CI's test watchdog, every process writes down which file and test
+// it is running, so a run that stops making progress names the test that
+// held it (`tests/helpers/inflight-recorder.ts`). Off for a local run.
+installInflightRecorder();
+
+// A snapshot shells out to `tar` and `zstd` synchronously, and a child that
+// never reports back blocks the whole test process: bun's per-test timeout
+// cannot fire on a blocked thread, so the run went silent until the CI job
+// timeout. The product bound is fifteen minutes (sized for a large vault);
+// the suite's trees are tiny, so a minute here turns such a hang into a
+// failure that names the tool. A test of the bound sets it itself. The name
+// is spelled out rather than imported, so the preload every file pays for
+// does not load the snapshot module's import graph; the snapshot tests pin
+// it to `SNAPSHOT_TOOL_TIMEOUT_ENV`.
+if (process.env["OPEN_SECOND_BRAIN_SNAPSHOT_TIMEOUT_MS"] === undefined) {
+ process.env["OPEN_SECOND_BRAIN_SNAPSHOT_TIMEOUT_MS"] = "60000";
+}
+
// Freshen-on-read starts a detached `o2b search index` whenever a search
// meets an index older than the interval. A test suite must never leave
// background indexers behind, so the default is off here; the tests of the