Skip to content

Pin registered project folders before chat launch - #6443

Merged
BunsDev merged 10 commits into
mainfrom
fix/issue-6215-pin-project-root-v2
Nov 20, 2026
Merged

BunsDev merged 10 commits into
mainfrom
fix/issue-6215-pin-project-root-v2

Conversation

@BunsDev

@BunsDev BunsDev commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Refs #6215.

Pin each registered project to its saved directory identity, refuse moved or unconfirmed folders at the server launch boundary, and retain registered identity across canonical/alias resumes. Registration captures the pin before registry I/O; explicit confirmation and root edits recheck their approved directory under the registry lock. Stored root keys remain unchanged.

Confirm folder and root edits require fresh macOS Touch ID authentication without password/watch fallback, following Val’s current clarification. Familiar-relayed approval and mobile ingress are refused. Confirmed canonical roots feed forwarded grants and Claude write scope, with checks repeated before dispatch, spawn and retries. The retained snapshot from owner session 7fcd2b86 (641530e7d) was ported against current main and strengthened with behavioral regressions.

Validation: full API suites passed 617 files under both /tmp/... and /private/tmp/... HOME, run serially; app 1,505 files; mobile contracts 106; typecheck, lint, test wiring and production build passed. The focused production Project access browser run passed eight checks without retries. Failing-first controls, first failures, screenshots and the acceptance matrix are retained in delivery-receipts/issue-6215-2026-11-10/. The isolated-HOME app suite’s two existing Chromium-canvas skips are recorded separately from the successful browser run.

Visual sign-off is needs-Val. The production screen was inspected in the default browser and both legacy and confirmed states are captured; Val observed and approved the replacement Touch ID-only native prompt. The original broad device-owner policy succeeded without a prompt and failed acceptance; the failure and repair are retained in the receipt history. Windows/Linux native confirmation is currently unavailable and fails closed; Macs without available enrolled Touch ID also fail closed. Light/alternate-theme review and installed-package acceptance remain needs-Val.

Hosted validation: required Frontend build and all 28 latest checks passed at this head. The full second attempt passed all 1,190 iOS cases; the first WebView startup failure, browser skips and one runner-level browser retry are retained in the morning criterion checkpoint.

Hold for Val’s merge approval at exact head fd3a5da028e22c0fc0b6b06a33c27df5dfaae7b8. Automatic merge and issue closure are outside this delivery.

Bind project authority to confirmed directory identities across admission, forwarded grants, write scope and spawn. Require native human authentication for confirmation and root edits, preserving alias identity, grant-level merging and legacy refusal.

Refs #6215.
Exclude device-owner password and watch fallback after the native retry succeeded without a visible prompt. Preserve the failure evidence and record Val’s observed approval of the replacement Touch ID ceremony.

Refs #6215.
BunsDev added a commit that referenced this pull request Nov 12, 2026
## Summary

Adds a resumable first-use introduction and persistent default project, familiar scope and acting familiar. New work starts with concrete context; unavailable defaults and interrupted launch briefs remain available for explicit repair. Installation success and dismissing guidance do not complete the introduction.

Existing conversation bindings, explicit All projects browsing, drafts and reviewed access choices retain their authority. Bound chats reopen guidance from Session options or Tools without taking transcript space.

## Behavior

- Host-owned, revision-checked progress/defaults with cross-process locking, live eligibility inspection and a separate starter-folder/access review.
- A short practice outcome teaches project, actor, effective access, approval, progress, Stop, retry and evidence without calling a model or modifying project files.
- Shared main/Tray/Notch admission rules refresh the full saved scope, preserve files until admission, reject superseded reads and pending follow-ups after accepted Stop, and wait for voice project readiness.
- Effective access follows direct/group grants; supreme designation cannot imply Write. Passive runtime checks follow the selected SSH, Hermes API, paired OpenClaw Gateway or local transport and authorized project root; send-time authorization remains authoritative.
- Reuses #6450’s Read-grant Build admission and grant preconditions from `119a775f2a228c2ddfead75c327b2d90460f42dd`; its other UI remains separately owned. #6443 root pinning is not ported.

## Verification

- Complete local suites: 1,514 app test files, 620 API test files passed; the integrated head subsequently passed all 107 mobile contract test files. After the final initialization-focus guard, 29 guide/route behavior tests, final typechecked production build and focused lint passed.
- Final production browser run: 121 cases passed without retries, covering 99 first-use cases across desktop Chromium, Pixel 5 and iPhone 13 WebKit plus 22 phone transcript/composer cases. The unchanged keyboard oracle also passed 30 repeated cases without retries.
- Affected legacy browser suites passed with explicit installation/workspace fixtures. Existing assertions, layout/performance thresholds and timeouts were preserved. A subsequent flag-enabled production build passed all 33 Board/Research cases without retries, with one expected disabled-capability skip. The final remaining-shard selection passed 181/181 cases, including its dependencies, without retries; the hosted canonical gate remains separate.
- Full lint, UI/token contracts, all 2,250 test files wired and production bundle/standalone budgets passed. Final read-only source review found no Critical or Important findings.
- [Local evidence, retained first-failure hashes, screenshots and acceptance limits](https://github.com/OpenCoven/coven-cave/blob/d4f7c99f98073a717550e415b2024ae8b8ea37e3/delivery-receipts/issue-6458/README.md). Approval repairs are published in `2412f6f7081da7bfade2e10cfc642ed397142c2f`. Main’s already-landed iOS work was integrated in `fe0c0631cd74861d1ee37f42f8deb6459853db21`. Final head `d4f7c99f98073a717550e415b2024ae8b8ea37e3` adds fixture declarations and receipts, with product source unchanged; that exact head passed the [complete hosted run](https://github.com/OpenCoven/coven-cave/actions/runs/43235522428), including the required [Frontend build](https://github.com/OpenCoven/coven-cave/actions/runs/43235522428/job/131249672025). All 27 check runs are complete: 26 successful and the iOS job skipped by path selection. The Code Desk drawer-floor case passed after retry; its first failure is retained separately from the retry-free local qualifications.

## Acceptance boundaries

An absent first-use record requires the introduction on fresh and existing installations. Saved defaults grant no access and cannot replace current permission/runtime authority. Verification used synthetic state and changed no real-account grants.

Installed native/Tauri handoff, physical-device and human/screen-reader acceptance remain unqualified. The limited default-browser inspection covered opening screens and keyboard focus; complete practice and interruption evidence comes from production browsers. Release delivery is separate. The issue-owned worktree remains intentionally preserved for recovery and verification.

Implements #6458. Overlap coordination was recorded on the existing issues; owner-session acknowledgement and private execution coverage remain unknown.

Signed-off-by: Val Alexander 👑 <val@opencoven.ai>
@BunsDev
BunsDev requested a lite review from Copilot November 13, 2026 08:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Active critical authorization and packaging issues remain, including stale root validation that can permit dispatch to a retargeted project and a packaged helper path that makes confirmation fail.

7 open issues
What changed in this PR

This PR pins each registered project to its resolved directory identity and enforces that identity before chat, Board, voice, and resumed-generation launches. It adds Touch ID-only confirmation for legacy projects and deliberate root changes, fail-closed behavior for moved folders or unavailable authentication, and broad regression coverage.

Changes:

  • Persists and validates rootRealpath across registration, edits, confirmation, aliases, resumes, worktrees, grants, and runtime launch boundaries.
  • Adds project-settings confirmation UI/API, macOS native authentication, and user-facing web and iOS error handling.
  • Adds integration and regression tests, native build wiring, documentation, and delivery receipts.
File Description
src/​lib/​voice/​start-voice-chat.ts Maps folder-pin launch failures to actionable voice-chat messages.
src/​lib/​voice/​start-voice-chat.test.ts Tests voice-chat messages for moved and unconfirmed project roots.
src/​lib/​use-projects.ts Adds the project-folder confirmation mutation and state handling.
src/​lib/​use-projects.test.ts Updates mutation-notification coverage for folder confirmation.
src/​lib/​server/​project-root-pin.ts Validates pinned directory identity before launch, grant forwarding, and spawn.
src/​lib/​server/​project-root-pin-regression.test.ts Covers redirected roots, legacy pins, races, and forwarded-grant regressions.
src/​lib/​server/​project-folder-confirmation.ts Coordinates native authentication with locked project-root confirmation.
src/​lib/​server/​project-folder-confirmation.test.ts Tests Touch ID policy requirements and confirmation races.
src/​lib/​server/​native-folder-authentication.ts Invokes the macOS native folder-authentication helper.
src/​lib/​server/​chat-project-launch.ts Adds shared project-pin launch authorization and moved or unconfirmed error handling.
src/​lib/​server/​chat-project-launch.test.ts Tests pinned-root authorization across aliases, worktrees, grants, and resumed launches.
src/​lib/​chat-project-access.ts Preserves pinned project identity across aliases, resumes, and moved roots.
src/​lib/​chat-project-access.test.ts Tests pinned resume identity, ambiguity handling, and worktree containment.
src/​lib/​cave-projects.ts Captures and updates project pins during registration, root edits, and confirmation.
src/​lib/​cave-projects.test.ts Tests pin persistence, registration races, and locked confirmation behavior.
src/​lib/​cave-projects-types.ts Adds the persisted rootRealpath project field.
src/​components/​projects-view.tsx Connects project settings to the folder-confirmation mutation.
src/​components/​projects-view.test.ts Verifies project-view confirmation handler wiring.
src/​components/​project-settings-modal.tsx Adds folder status, confirmation controls, errors, and announcements.
src/​components/​project-settings-folder-pin.behavior.test.tsx Tests project folder-pin confirmation UI states and behavior.
src/​components/​familiar-studio-projects-tab.tsx Exposes folder confirmation in familiar project settings.
src/​components/​familiar-studio-projects-tab.test.ts Verifies familiar-studio folder-confirmation wiring.
src/​components/​chat-view.tsx Routes moved or unconfirmed project failures to the Projects recovery surface.
src/​components/​chat-project-launch-gate.test.ts Tests Chat handling of folder-pin launch failures.
src/​app/​api/​projects/​route.ts Registers projects through pin-aware server-side persistence and project listing.
src/​app/​api/​projects/​route-pin.integration.test.ts Covers project registration, confirmation, root edits, grants, and ingress restrictions.
src/​app/​api/​projects/​[id]/​route.ts Adds authenticated folder confirmation and root-edit API handling.
src/​app/​api/​chat/​send/​route.ts Applies pinned-root checks to grants, write scope, dispatch, spawn, and retries.
src/​app/​api/​chat/​send/​harness-routing-codex-direct.test.ts Tests redirected roots and canonical forwarded-grant routing.
src/​app/​api/​chat/​conversation/​route.ts Supplies pinned project identity to conversation launch authorization.
src/​app/​api/​board/​[id]/​chat/​route.ts Supplies pinned project identity to Board chat authorization.
src/​app/​api/​api-contracts.test.ts Adds the project route PATCH contract coverage.
scripts/​run-tests.mjs Wires the new server, integration, UI, and behavior tests into validation suites.
scripts/​build-folder-confirmation.mjs Builds the macOS Touch ID helper for supported deployment targets.
playwright.config.ts Gives the disposable E2E project an explicit saved directory pin.
package.json Runs native confirmation-helper compilation during the production prebuild.
native/​confirm-project-folder.swift Implements fresh biometric-only macOS folder confirmation.
docs/​specs/​ios-new-chat-project-contract.md Documents folder-pin project-selection errors for iOS.
docs/​project-permission-integrity.md Documents pinned-folder permission behavior, confirmation, and launch enforcement.
delivery-receipts/​issue-6215-2026-11-10/​README.md Records validation evidence, acceptance status, and platform limitations.
delivery-receipts/​issue-6215-2026-11-10/​.gitignore Retains scoped delivery artifacts while excluding raw receipt data.
apps/​ios/​CovenCave/​CovenCaveTests/​ChatProjectContractTests.swift Tests iOS handling of unconfirmed and moved project roots.
apps/​ios/​CovenCave/​CovenCave/​Networking/​CaveConnection.swift Classifies folder-pin launch errors as requiring project selection.
.gitignore Ignores the generated macOS confirmation-helper executable.

Review effort: Lite

throw error;
}
},
projectRootPin: projectRootPinIn(projects),
Comment thread src/app/api/chat/send/route.ts Resolved
Comment on lines +8 to +9
const helper = path.join(process.cwd(), "native", "confirm-project-folder");
if (!existsSync(helper)) return Promise.resolve(false);
Comment thread src/app/api/projects/[id]/route.ts Outdated
Comment on lines +78 to +89
if (!validatedRoot.ok) {
return NextResponse.json({ ok: false, error: validatedRoot.error }, { status: 400 });
}
// Changing a root also changes its pin, so it must not bypass the native
// confirmation ceremony by spelling the operation as an ordinary edit.
if (body.familiarId != null || body.proposedBy != null || body.claimedHumanApproval === true) {
return NextResponse.json({ ok: false, error: "folder changes must come directly from the human" }, { status: 403 });
}
const current = (await loadProjects()).find((entry) => entry.id === id);
if (!current) return NextResponse.json({ ok: false, error: "not found" }, { status: 404 });
const realpath = realpathSync.native(/* turbopackIgnore: true */ validatedRoot.root);
if (!await authenticateProjectFolder(`Change ${current.name}’s project folder to:\n${realpath}`)) {
Comment thread src/app/api/projects/[id]/route.ts Resolved
Comment on lines +20 to +23
const validated = validateCaveProjectRoot(project.root);
if (!validated.ok) return { ok: false as const, status: 400, code: "project_root_unavailable", error: validated.error };
const expected = { root: project.root, realpath: realpathSync.native(/* turbopackIgnore: true */ validated.root) };
const approved = await deps.authenticate(`Confirm ${project.name}’s project folder:\n${expected.realpath}`);
Comment thread docs/project-permission-integrity.md Resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Val Alexander 👑 <val@opencoven.ai>
@BunsDev BunsDev self-assigned this Nov 18, 2026
@BunsDev
BunsDev requested an adaptive review from Copilot November 18, 2026 04:47
@BunsDev

BunsDev commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request and resolve by implementing changes recommended

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical launch paths still permit folder-pin bypasses or use stale authorization, and the packaged macOS app omits the authentication helper needed for legacy-folder confirmation and root edits.

11 open issues
2 previously missed issues

In code that hasn't changed since last review

Medium severity Report pin refusals separately and offer folder confirmation

src/​app/​api/​chat/​send/​route.ts:3192

This filter also excludes unconfirmed and moved projects, but omittedGrantCount reports all excluded grants as “unavailable on this host” at line 3950. Existing legacy directories therefore get the wrong diagnosis and no confirmation guidance. Count pin refusals separately and direct those users to Confirm folder in project settings.

Medium severity Offer folder recovery for streamed moved-root errors

src/​components/​chat-view.tsx:5863

This recovery only handles an HTTP 409, but the new last-moment spawn guard also reports project_root_moved through an SSE error event after returning HTTP 200. handleEvent's error branch only sets the message/failed request, so that refusal never sets projectsFixNeeded and offers Retry instead of Open projects. Apply the same code-based folder recovery to streamed error events so a late redirect has the same repair action as an early refusal.

1 resolved since last review

Review effort: Max (adaptive)

Comment thread src/app/api/chat/send/route.ts Outdated
let localRecoveryAttempted = false;
let stopChildOnLaunch = false;
const spawnChild = (mode: "gateway" | "local") => {
args.assertLaunchFoldersUnchanged();
Comment thread src/app/api/chat/send/route.ts Outdated
});
})()
: (() => {
assertLaunchFoldersUnchanged();
Comment on lines +287 to +288
const launchRoot = realpathNativeOrResolve(validated.root);
if (!registeredMatches || !isInsideRoot(pin, launchRoot)) {
Comment on lines +24 to +26
if (!approved) {
return { ok: false as const, status: 403, code: "project_folder_authentication_required", error: "Authenticate on this Mac to confirm the folder. Use Touch ID, then retry." };
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 25b2c8687, per Val's decision to return a truthful unavailable result. authenticateProjectFolder now returns true | false | "unavailable". It returns "unavailable" when not on macOS, when the helper is missing, when the helper exits 2 (canEvaluatePolicy fails, so no usable Touch ID), and when the helper cannot start. Confirmation and root edits then return 409 project_folder_authentication_unavailable, saying Touch ID isn't available on this device and naming the way forward (remove and re-add the project, or add the new folder as its own project). A declined or timed-out prompt keeps 403 project_folder_authentication_required. Tests cover the exit-status mapping using stub helpers (0, 1, 3, 2 and missing) and the route responses. docs/project-permission-integrity.md is updated to match.

…oject-root-v2

# Conflicts:
#	docs/project-permission-integrity.md
#	playwright.config.ts
#	scripts/run-tests.mjs
#	src/app/api/chat/send/route.ts
#	src/app/api/projects/[id]/route.ts
#	src/components/chat-view.tsx
#	src/lib/cave-projects.ts

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request and resolve by implementing changes recommended

Resolved the conflicts and implemented the review recommendations. Current project pins are reloaded at Board/chat launch boundaries, root snapshot failures now fail closed with structured errors, and the Touch ID helper is included at the packaged sidecar path. Added regression coverage; lint and the production build pass. Merge commit: 48d79c2 (two parents). CodeQL reported no alerts but timed out before completing language analysis.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@BunsDev

BunsDev commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Read-only verification of all 12 Copilot threads at head ae654c06e

Every finding was checked against the code at the current head, not against the fix commit's message. (Commit 48d79c29a is a main merge that also carries the fixes.) Verdict: 9 fixed, 1 not a bug, 2 still open. Not ready to merge.

# Thread Verdict Evidence at ae654c06e
1 Board pin recheck Fixed board/[id]/chat/route.ts: recheckProjectRoot() → assertCurrentPinnedLaunchRoot before session reuse, around resolveRepoRoot/provisionIssueWorktree, before the native reservation and before callDaemon
2 Stale projects closure Fixed chat/send/route.ts assertLaunchFoldersUnchanged reloads loadProjects() before each launch and each attempt
3 Packaged helper path Fixed scripts/sidecar-bundle.sh copies the helper to resources/server/native/confirm-project-folder and fails if it is missing; release.sh signs it. Docs line 39 still says the helper is "included in the trace" when it is actually copied
4 Root-edit realpath race Fixed projects/[id]/route.ts realpath in try/catch → 400 project_root_unavailable; a mismatch under the lock → 409
5 Password copy Fixed Copy now says Touch ID
6 Confirmation realpath race Fixed project-folder-confirmation.ts try/catch → 400 before authentication
7 Docs password ceremony Fixed docs/project-permission-integrity.md:37 says Touch ID only
8 OpenClaw moved-folder escape Fixed (leftover) spawnChild catches the moved-folder error and calls failChild. Leftover: any other loadProjects error is still rethrown into void finalizeChild(code), an unhandled rejection that leaves the run registered. Minor
9 Hermes API ordering Fixed The folder check now runs before runHermesApiAttempt, so every retry goes through it. No test pins this ordering
10 Re-resolve after await Not a bug The re-resolved root must stay inside the saved pin, and the registered root must equal the pin. assertPinnedLaunchRoot refuses any later swap
11 Confirmation skips isAllowedNewProjectRoot Still open: blocking confirmProjectFolderWithHuman uses only validateCaveProjectRoot and the realpath. If a registered root is retargeted to $HOME or /, launch refuses it as moved, but confirmation then pins the realpath, and the project's grant covers the whole home or volume. Registration and root edits both forbid that. Fix: apply isAllowedNewProjectRoot to the realpath before authenticating and again under the lock
12 Unavailable prompt reported as a denial Still open: Val's decision Non-macOS, a missing helper and no Touch ID all return false, so the copy says "Use Touch ID, then retry" when no prompt can appear. It fails closed, but projects created before pinning can't be confirmed there. This is the Windows/Linux limitation #6215 already routes to Val; a distinct unavailable result (the helper's --check mode) would make it truthful

Item #11 was also confirmed by a second read. Covering tests exist for #1–#6 and #8 (source-shape tests plus project-root-pin-regression, project-folder-confirmation, and the route-level moved-folder 409). None covers #7, #9's ordering or OpenClaw's local retry behaviour.

Checks: 30 pass, including the required Frontend build. The one failure is iOS transcript (ChatScrollBounceUITests.testThousandMessageConversationKeepsRichRenderingBounded: "real view-hierarchy and renderer ownership metrics must be captured"). That is the native scroll-metrics lane and is unrelated to this web/server change; it needs a whole-workflow rerun for exact-head evidence.

The 12 threads are left unresolved for the owner. The local branch copy in .worktrees/issue-6393-grant-sandbox (stale at fd3a5da) was not touched.

…irmation

Folder confirmation pinned whatever a registered root resolved to, so a root
retargeted to the home folder or a drive root could be confirmed and widen
the project's grant to it. Registration and root edits already refuse those
roots. Confirmation now applies isAllowedNewProjectRoot to the realpath
before the Touch ID prompt and again under the registry lock, and root edits
re-check the realpath they authenticate.

Where no prompt can appear (not macOS, no bundled helper, or no usable
Touch ID: the helper exits 2), confirmation and root edits returned the
"Use Touch ID, then retry" denial. They now return
409 project_folder_authentication_unavailable with copy that says so and
names the way forward. Declined or timed-out prompts keep the 403.

Addresses review findings 11 and 12 on PR #6443 (#6215).
@BunsDev

BunsDev commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

CI on head ddd951852 (the main merge on top of repair commit 25b2c8687):

  • Attempt 1 failed: iOS build → testWidthReflowKeepsTheLastLinePaintedInsideTheNativeBubble, XCTAssertNotNil failed. That made Frontend build fail. This PR changes no iOS source, and the same test passed on main 5652dedae and on this PR's earlier head ae654c06e.
  • Attempt 2 (whole-workflow rerun of run 44660101791) succeeded. Frontend build passed. The separate iOS transcript, iOS release toolchain and Windows startup workflows passed on their first attempt.

Treat the first failure as a native layout flake candidate, not a pass. Finding #8 (an unhandled rejection on other loadProjects errors) is still a minor leftover from the earlier review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants