Skip to content

Commit 7e7f5d2

Browse files
committed
feat: implement CrewMergeJournal for atomic persistence of integration records
- Added CrewMergeJournal class to manage integration journal records with atomic persistence. - Implemented methods for adding, updating, and retrieving records, including handling interrupted states. - Introduced tests for CrewMergeJournal to ensure correct behavior during restarts. feat: introduce suggestedCrewChecks for package scripts verification - Created functions to suggest crew checks based on package.json scripts. - Implemented tests to validate the behavior of suggestedCrewChecks and resolveSuggestedCrewCheck. test: add security boundary tests for plugin capabilities - Developed comprehensive tests to verify that plugins cannot exceed their declared permissions. - Ensured that various scenarios of permission denial are correctly handled. test: establish security configuration tests to prevent silent weakening - Added tests to ensure that critical security configurations, such as CSP and window isolation flags, cannot be altered without explicit approval. feat: implement audio input worklet for microphone PCM capture - Created an AudioInputWorklet to handle microphone input efficiently using the AudioWorklet API. - Provided a method to create and manage the audio input worklet node. fix(voice): improve local playback reliability and navigation UX - recover and retry transcription after local CUDA sidecar crashes - keep the full voice overlay scoped to its originating chat - show an animated notification while voice replies play elsewhere - dismiss the notification automatically when playback finishes - strip Markdown and Unicode asterisks from natural spoken replies - add regression tests and update realtime voice documentation
1 parent ef2f462 commit 7e7f5d2

56 files changed

Lines changed: 2799 additions & 150 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ AGENTS-CJ.md
4141
docs-website/dist/
4242
docs-website/.astro/
4343
social-media-post.md
44+
Work/

‎AGENTS.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ src/renderer/src/
7171

7272
Always use the primary working directory (the worktree) for all file reads and edits. Never follow absolute paths from subagent results that point to the main repo.
7373

74+
Crew merges must not equate a clean Git merge with behavioral correctness. Keep the cross-lane collision analysis explainable and advisory, preserve the explicit review gate, and persist source worktree/commit provenance before starting a merge. On restart, process-local runtime ids must be cleared and a still-running merge audit or verification check must become `interrupted`, never inferred successful. Verification IPC accepts only main-discovered `typecheck`/`test` ids, displays the exact command and package script before execution, and must never become arbitrary command execution. See `docs/behavioral-merge-review.md`.
75+
7476
## Cross-Platform Support
7577

7678
Orca targets macOS, Linux, and Windows. Keep all platform-dependent behavior behind runtime checks:

‎README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ It targets MacOS (I'd appreciate if someone can help with testing Mac), Linux, a
3838

3939
- Run **CrewCoder agent**, **Claude Code agent**, **Codex**, **OpenCode**, **pi**, **Ollama**, **Hermes**, **OpenRouter** and **Grok Build**from one app
4040
- Mix **structured agent bridges** and **PTY-backed terminals** depending on provider
41-
- Keep multiple chat **sessions per workspace**, each with its own agent, model, mode, and effort
41+
- Keep multiple chat tabs **sessions per workspace**, each with its own agent, model, mode, and effort
4242
- Resume persistent sessions instead of starting from scratch every time
4343
- Extend CrewCode with local plugins, custom panels, MCP servers, browser/git actions, and plugin-powered agent providers
4444
- Switch Providers Mid Session and it creates an hand-off Summary for new agent to continue work with out leaving chat and losing context
@@ -52,6 +52,8 @@ It targets MacOS (I'd appreciate if someone can help with testing Mac), Linux, a
5252
- Initialize new projects from scratch
5353
- Create, switch, merge, and remove **git worktrees** inside the app
5454
- Keep parallel work isolated without stashing or branch juggling
55+
- Surface exact file overlap and likely cross-file contract collisions before crew merges
56+
- Recover crew worktree/commit ownership and interrupted merge audit state after restart
5557

5658
### Crew orchestration
5759

‎docs/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ internal references).
2828

2929
| Doc | What it covers |
3030
| --- | --- |
31+
| [security-model.md](./security-model.md) | Authority-boundary audit: untrusted content -> agent -> MCP/plugin -> exec -> Git/SSH, per-hop gates, tests, and residual risk |
3132
| [remote-ssh-workspaces.md](./remote-ssh-workspaces.md) | Opening projects over SSH: setup, auth, host pinning, what works remotely |
3233
| [canvas-mode.md](./canvas-mode.md) | Workbench: multiple chats and terminals side by side on one worktree _(nav label: "Workbench")_ |
3334
| [chat-archiving.md](./chat-archiving.md) | Right-click a chat to archive it; the Archive page, restoring, and retention flagging |
@@ -37,6 +38,7 @@ internal references).
3738
| Doc | What it covers |
3839
| --- | --- |
3940
| [git-workspace.md](./git-workspace.md) | The full-page Git tab and its relationship to the Git Sidebar |
41+
| [behavioral-merge-review.md](./behavioral-merge-review.md) | Cross-lane collision signals, merge review gate, provenance, and restart recovery |
4042
| [git-authentication.md](./git-authentication.md) | One-shot push credential prompts; nothing is persisted |
4143
| [git-commit-signing.md](./git-commit-signing.md) | Signing passphrase prompts for GPG/SSH-signed commits |
4244

‎docs/behavioral-merge-review.md‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Behavioral merge review
2+
3+
Git worktrees prevent concurrent writers from editing the same checkout, but they do not make independently valid changes compatible. CrewCode therefore treats a clean Git merge as **combined, not verified**.
4+
5+
## Cross-lane review
6+
7+
For isolated crews, **Cross-lane Diff** and the merge sidebar show:
8+
9+
- every lane's changed files relative to the crew base branch;
10+
- the lane branch, worktree, and current commit SHA that own those changes;
11+
- whether the lane currently has a running agent;
12+
- exact files changed by more than one lane; and
13+
- likely cross-file contract collisions.
14+
15+
The contract heuristics are intentionally narrow and explainable. They cover database migration/schema changes versus model/API consumers, API schemas versus clients/generated code, dependency manifests versus runtime source, and configuration versus consuming source. The sidebar lists the implicated lanes and paths. These warnings are review signals, not proof of a defect; no warning is not proof that combined behavior is correct.
16+
17+
## Combined integration gate
18+
19+
Crew lanes are no longer merged into the base one at a time. **Verify combined lanes** snapshots the base and every committed lane SHA, creates a detached disposable worktree under `.worktrees/`, and merges all candidate SHAs there in displayed order. The user's base checkout remains untouched.
20+
21+
CrewCode then discovers the allowlisted `typecheck` and `test` package scripts using the repository's lockfile-selected package manager and runs them against that exact combined tree. This catches failures that no lane can expose alone—for example, a DB migration in one lane changing a column while a model/API lane independently changes the consumer to an incompatible name. Agents cannot submit arbitrary commands through this route; main runs only discovered check IDs, with `CI=1`, a two-minute local timeout, and bounded output. Local and SSH workspaces are supported.
22+
23+
A passing candidate is retained by an internal Git ref. **Apply checked integration** rechecks all of the following before updating the base:
24+
25+
- the base checkout is clean and still has the expected base branch checked out;
26+
- the base branch still points to the verified base SHA;
27+
- every lane branch still points to its verified SHA; and
28+
- the retained ref still points to the exact checked integration commit.
29+
30+
Only then does CrewCode use `git merge --ff-only` to apply the checked commit. A changed input makes the candidate stale and requires another verification.
31+
32+
## Restart recovery and evidence
33+
34+
The main process atomically persists a merge journal under CrewCode's user-data directory before combination begins and at every phase transition. Each record contains the session, base branch/SHA, lane label, branch, worktree path, owned files and SHA, current phase, discovered check commands, outputs, status, and timestamps.
35+
36+
After restart, an in-flight operation is shown as `interrupted` instead of implying that its process survived. Any running check is likewise marked interrupted. A candidate that had already passed is reconciled against Git; moved base/lane/ref inputs make it stale. If CrewCode stopped while applying but the base now equals the retained integration SHA, reconciliation records the operation as applied. The base is never inferred to be updated merely because a subprocess had started.
37+
38+
Crew session ownership is also persisted locally. Process-local bridge and terminal IDs are cleared on recovery, and lanes that previously said `running` recover as `ready`; the UI never claims an agent process survived without evidence.
39+
40+
## Limits
41+
42+
Path heuristics and project tests cannot understand every runtime assumption, data semantic, deployment order, or external system. The combined gate makes a clean merge testable and auditable; it does not replace migration drills, production safeguards, or human review.

‎docs/current-state.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Task distribution (`session.distribution`, default `split`) is a live header tog
2626

2727
Crew control stops are scoped intentionally: `stop all` in `CrewSurface` aborts every runtime, the supervisor composer stop button calls `abortSupervisor()` only, and lane composer stop buttons call `restartLane()` for that lane only. The supervisor sidebar width is local UI state in `CrewSurface` and is resized with the shared `Splitter`; the supervisor thread also has a scroll-to-bottom affordance. Shared timeline lane groups (`crew-lane-group`) are locally collapsible with chevrons so dense multi-agent rounds remain scannable.
2828

29+
Isolated crew review treats clean Git merges as unverified. Cross-lane Diff shows branch/commit ownership, runtime state, exact file overlap, and narrow cross-file contract heuristics; the crew merge sidebar requires explicit acknowledgment when signals exist. Crew sessions persist locally so restart retains lane/worktree provenance while clearing process-local runtime ids. A merge audit is written before Git starts and recovers a leftover `running` operation as `interrupted`. After a clean merge, the sidebar discovers and visibly presents allowlisted package `typecheck`/`test` scripts; main runs only those discovered ids with `CI=1`, and persists pass/fail/interrupted evidence for local and SSH workspaces. See `docs/behavioral-merge-review.md`.
30+
2931
## Delegated Threads
3032

3133
Delegated threads let a solo-chat agent spawn real, persistent chat sessions through a loopback HTTP API (per-session bearer token, ephemeral port, `useDelegatedThreads` answering marshalled IPC in the renderer). `mode` is permissions and `isolation` is placement — they are independent, and `build` + `shared` is the legitimate "run the test suite in this checkout" case; never re-couple them. **Depth-1 must stay enforced at three layers, not by withholding credentials alone**: `canSessionDelegate()` (`origin !== 'delegated'`) gates the ChatPane toggle, credential minting in `useSessionDelegation`, and — authoritatively — every route in `useDelegatedThreads.perform()` with a 403, so a leaked token cannot read siblings or merge their branches either. The bearer token **is** the caller's identity, so `containsDelegationToken` must reject any create prompt or thread message carrying a live token (checked against every registered token, not just the caller's); refuse rather than redact, because a 64-hex string is never legitimate task text. **An agent must never be able to archive a chat.** `POST /v1/threads/:id/close` sets `Session.delegationClosedAt`, which frees a concurrency slot and dims the drawer row; it must never call `setArchived`, because archived sessions vanish from every live surface and only the user decides they are finished with a thread. Sending a closed thread a message reopens it, `focus` works on a done thread and refuses an archived one, and `closed` in the API projection means either state because both free a slot. Reporting is push, not poll, and is modelled directly on the crew Supervisor loop: `useDelegationReports` subscribes to the bridge registry's `subscribeTurnEnd` and routes a finished worker's bounded final reply into the parent's running turn as a follow-up, wakes an idle parent with a fresh turn, or buffers it in `delegation-inbox-store.ts` for the parent's next prompt; every failure falls back to buffering so a report is never dropped. **Reports must be coalesced, never delivered one wake per thread** — waking costs a full parent turn at that chat's whole context, so a fan-out finishing together gets one wake carrying every report (`REPORT_COALESCE_MS`), and a `delivering` flag must be claimed synchronously before the first `await` (crew's `busy`) or parallel workers all see an idle parent and fire concurrent prompts at one bridge. Autonomous waking is `settings.wakeParentOnDelegatedReport` (default on) and is bounded by `MAX_AUTONOMOUS_WAKES = 4`, which counts **recursion, not volume**: a wide fan-out from a user-driven turn is free however many threads it contains, while a wake caused by threads spawned during an autonomous turn (`Session.delegatedDuringWake`, stamped at spawn) costs one. Only a real user message refills the budget (an auto-wake bypasses the send path, so it cannot refill its own), follow-ups into a running turn never spend it, and an exhausted budget must say so in the transcript. A finished thread must be re-read on a settle retry (`REPORT_SETTLE_ATTEMPTS` × `REPORT_SETTLE_INTERVAL_MS`, mirroring crew's `reportLaneReply`) before its reply is extracted — `turn_end` fires before the renderer flushes stream buffers, so a synchronous read captures the agent's opening line and none of its result. One logical turn must report exactly once: `useAgentBridge` routes `turn_end`, `error` and `closed` through the same callback, so the guard is a consume-once `reported` set released only by the child's next `turn_start` (crew's `waiting.delete`), **never reply-text comparison** — the settle retry guarantees an early and a late event see different text, so text dedup silently delivers every report twice. `Session.delegationRunId` is the cohort stamped at spawn so a batch can report "1 of 3 done — do not summarize as finished yet"; it is unrecoverable after the fact, so never try to infer it at report time. The idle watchdog (`shouldAbandonThread`, mirroring crew's `shouldAbandonRound`, fed by `subscribeActivity` + `nextToolsInFlight`) reports a thread that is still running with no tool open and no bridge event for 3 minutes — it must **report, never close or archive**, and must keep the tool-in-flight gate or a single long tool call looks identical to a hang. A wake must revive a bridge reclaimed by the 10-minute idle sweep (`ensureBridgeForSession`), and both the preamble and the `woke` report block must tell the agent the user is not present so an auto-started turn never ends in a question. Every report also lands as a visible system row in the parent transcript, is framed as `<system>` (never user text), is clamped to 1,600 chars, caps at 12 buffered per parent, and drains exactly once at wire-text assembly. See `docs/delegated-threads.md`.

‎docs/realtime-voice.md‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ it.
3535

3636
Voice mode survives chat and tab navigation during that turn. The persistent
3737
runtime remains pinned to the session where the user started it, so navigating
38-
cannot reroute the request or its result to another agent. Individual chat panes
39-
only present the runtime: when the originating pane unmounts, the next visible
40-
chat adopts the live overlay while the original transport, activity tracking,
41-
and eventual speech continue. A non-chat page may have no overlay host, but the
42-
voice turn continues and reappears when a chat surface is visible again.
38+
cannot reroute the request or its result to another agent. The full overlay
39+
belongs only to the originating chat and does not move into another workspace or
40+
chat. If the spoken reply begins while that chat is not visible, a compact
41+
animated voice notification identifies the originating chat for the duration of
42+
playback. Clicking it returns to that chat, and it dismisses itself when speech
43+
completes.
4344

4445
The orb microphone can also be started with **Ctrl+Alt+V** and ended with
4546
**Ctrl+Alt+X**. Both shortcuts are editable under **Settings → Shortcuts** or
@@ -198,7 +199,7 @@ renderer transport; selection speech remains capped at 4,000 total characters.
198199
agent providers.
199200
- `voice-session-runtime.ts` owns the active transport and original agent target
200201
independently of chat-pane mounts, and holds tool calls for confirmation.
201-
- `useVoiceSessionController` attaches visible chat presenters to that runtime;
202+
- `useVoiceSessionController` presents that runtime only in its originating chat;
202203
unmounting it must never stop an active voice turn.
203204
- `voice-session-store.ts` owns high-frequency voice state outside `App.tsx`.
204205
- `ComposerDictationButton` and `one-shot-audio-capture.ts` own the
@@ -208,6 +209,10 @@ renderer transport; selection speech remains capped at 4,000 total characters.
208209
- `FakeVoiceTransport` provides deterministic local lifecycle testing without a
209210
microphone, network, or paid request.
210211

212+
## Audio capture implementation
213+
214+
Microphone capture uses `AudioWorkletNode` for Local voice, one-shot dictation, and xAI Realtime. The shared worklet batches PCM frames off the renderer main thread and transfers them through a message port; a zero-gain sink keeps the graph active without microphone feedback. Do not reintroduce deprecated `ScriptProcessorNode` capture.
215+
211216
## Installing local voice
212217

213218
Local voice requires Python 3.11, `espeak-ng`, and `libsndfile`. Kokoro uses the

0 commit comments

Comments
 (0)