Resolve conflicts in bootstrap-electron.ts and ios-simulator.test.ts.
- bootstrap-electron.ts: keep our teardownGhostProjectionBoundary including
device-link ownership release, lifecycleDbClient dispose, localDbCloseDb,
agentIslandService reset, and AggregateError on blocking failures
- ios-simulator.test.ts: include both the new IOSSimulatorToolRegistry import
from main and our vi.mock for isAppSessionBoundaryPending
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
In getLegacyGhostRecoveryStatus, the target-root scan now only runs
when there are legacy sources or pending recovery IDs. In a normal
profile with no legacy plugins, a corrupt ghost.json in the owner root
could block the recovery-status IPC or report a spurious deferred
status (P2, review #3757054096).
Add checklist item 6.5a to plugin-security-and-authoring.md codifying
the TOCTOU defense pattern for path-based workers: pre-check (fast fail)
→ atomic operation → post-operation verification → identity-guarded
cleanup. The pre-check-to-rename gap is the irreducible platform
boundary (Node.js does not expose renameat).
Add header comments to ghostSnapshotWorkerProcess.ts and
forgeScaffoldWorkerProcess.ts documenting their defense strategies,
identifying the platform hard boundary, and referencing the checklist
item so future reviewers understand the final achievable layer.
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
Resolved conflicts in index.ts and nodeRuntimeBroker.ts:
index.ts (market update path): Union of both sides — keep main's
agent/errand slot clearing before rename (Windows EPERM fix) AND the PR's
expectedInstalledApproval receipt-token guard (required for receipt-based
authorization model).
index.ts (local .cindy install): Keep PR's lock ordering (owner lease
outside per-id install lock, per documented invariant that prevents
deadlock). Absorb main's runtime.stop + stopAndWait calls inside the
lock for safe directory replacement on Windows.
nodeRuntimeBroker.ts (child process dispatch): Union of three independent
safety gates — main's worker entry identity check (skip stale entries),
main's stoppedGhosts check (refuse fork during shutdown), and the PR's
ownerScopeUsable check (reject stale owner scope callbacks).
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
When the durable Ghost projection boundary is missing or quarantined while
the app session is already committed to the same owner, the repair tears down
the owner-bound Ghost runtime but commitActiveAppSession's same-owner early
return did not advance the owner generation. Async work that captured the
pre-repair activeOwnerScopeKey() could then pass the stale-scope guard after
the boundary was released.
commitActiveAppSession now accepts forceBumpGeneration to advance generation
even on the same-owner path, and withCloudOwnerCommit sets it after a
same-owner projection repair so the scope key changes across the teardown.
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
A legacy lock without processStartIdentity whose pid is alive can be the
original holder still running mid-drain with a stale mtime, so it must never
be taken over. isRecordOwnerActive now treats a live non-self pid as the
active holder unconditionally (timing- and platform-independent), and a
PID-reuse takeover is only accepted when the recorded processStartIdentity
demonstrably does not match the current process.
This replaces a birthtime-based comparison that decided differently on
filesystems without a usable birthtime (Linux CI failed the PID-reuse test),
and a mtime-fallback that made the 'live owner must not be squeezed out'
guard depend on the parent process's age. The PID-reuse test now records a
mismatching identity ('start-ms:0') instead of relying on a sentinel
startedAt + stale mtime.
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
Second merge of origin/main into the plugin-approval branch. Conflict
resolution and integration decisions are recorded in
docs/dev-rules/plugin-approval-main-merge-2026-08-10.md; the invariants from
the 2026-08-09 merge carry forward unchanged:
- GhostManager.ts: keep the PR's legacy approval projection, receipt-backed
install/update/setEnabled/uninstall transactions, journal/quarantine, and
no-follow checks; keep main's host-unsupported manifest hint. The mutable
.cindy-trust.json mirror is not projected (removed readInstalledHostMetadata).
Icon byte cap normalized to the shared GHOST_ICON_MAX_BYTES.
- index.ts: keep the owner-boundary pending guard on availableGhosts/
findAvailableGhost and the exported *ForAuthorization helpers; keep the
builtin approval reconcile loop and resident heal; every slot/broker keeps
the durable owner scope instead of a bare list().find().
- shared/ghost.ts: keep the PR's superset permission fingerprint (kind,
normalized labelKey, labelArgs, detail*) for baseline, diff, and unreviewed
gates so a permission-surface change is never masked.
- crossProcessLock.ts: keep main's EBUSY/EPERM/EACCES retry handling together
with the PR's nonce-bound release marker and malformed-gate fail-closed
reclaim.
- Tests: keep the PR's legacy/update helpers and receipt-model assertions; add
main's host-unsupported and ios-simulator suites (owner-boundary mock only
overrides the module default for non-boundary suites; production code is
byte-identical to origin/main).
- Docs: keep the receipt row in plugin-security-and-authoring.md alongside
main's reformatted table and new paragraphs.
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
- Legacy approval backfill no longer fails because an optional icon is missing,
oversized, or unreadable: icon data is presentation-only and degrades to no
icon instead of marking the migration failed (Codex P1). The projection hash
stays deterministic (iconDataUrl ?? null).
- Mutable .cindy-trust.json mirrors no longer project trust; Host receipt is the
only authorization fact, and a corrupted mirror cannot override a valid
official receipt. Built-in provisioning writes cindy-github trust through the
same staged swap under the durable seeded ledger claim.
- Cross-process reclaim gates publish a nonce-bound .released sidecar when the
released record cannot be flushed, and malformed gates are reclaimed only
after proving the owner died or the PID was reused; cleanup removes both the
gate and its marker.
- Market default-plugin upgrades bind the confirmed approval token
(expectedInstalledApproval) and re-verify it under the per-ghost lock; a
legacy-unapproved/invalid plugin still requires the full host-side review and
cannot be silently re-approved. Default-upgrade baseline now uses the
installed manifest key, and a vanished installed record skips the upgrade.
- Windows ssh-add path probe treats win32 'UNKNOWN' errno on absolute paths as
no_such_file.
- Adds zh-TW reapproval/legacy-recovery UI copy and updates the main-merge
decision record.
Regression tests cover the optional-icon backfill, trust-mirror corruption,
reclaim-gate marker recovery, and default-upgrade approval binding.
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
Resolve merge conflicts with origin/main per the decision record in
docs/dev-rules/plugin-approval-main-merge-2026-08-09.md:
- Trust and GhostManager: keep main's complete official-trust validation and
the PR's rule that a mutable .cindy-trust.json cannot mint approval; keep the
PR's receipt, approval projection, journal, owner, and failure-closed paths.
- Bounded reads: combine the PR's no-follow/stable-read implementation with
main's optional non-blocking, hard-link, and stat-returning APIs.
- Built-in provisioning: retain the PR's seed fingerprint, link-free checks,
durable tombstone/seed ledger, and rollback semantics; wrap the complete
per-id installed-directory exchange in main's Ghost install lock.
- Market install/update: retain expectedInstalledApproval, reviewed manifest and
baseline checks, and the receipt token at the final commit; also retain main's
beforeCommitInLock callback and stale-baseline behavior.
- Permission fingerprints: use main's detailKey/detailArgs projection while
preserving the PR's stable approval baseline and diff behavior.
- Auth cold start and subscription hooks: keep the PR's owner-bound recovery and
captured-owner validation, incorporating main's fast paths and deadline-aware
wake while remaining fail-closed.
- Tests and documentation: union of security regression tests and main
behavioral tests.
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
* feat(ghost): align roster summary limit with manifest
Use the plugin-protocol 300-character summary limit for Desktop validation and cindy-tools roster truncation. Include the author-provided recall hint in live ghost_list results, preferring whenToUse over description.
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
* feat(ghost): add precise ghost_info discovery tool (#2031)
Add the fixed read-only ghost_info tool for targeted plugin detail lookup while keeping ghost_list as the live full inventory.
Depends on feat/roster-desc-max-align for the recall field and shared visibleChipGhosts filtering.
Visibility behavior changes:
- missing or uninstalled targets now take precedence over stale workdir-disable preferences and return GHOST_NOT_FOUND
- account-unavailable targets now use the explicit #907 not-signed-in message
- workdir-disabled plus asleep targets consistently return GHOST_DISABLED_IN_WORKDIR in ghost_call and setup waiter revalidation
- initial, setup, grant, pre-dispatch, post-context, and coordinator waiter checks now share one visibility classifier
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
* docs(ghost): align handbook wording with manifest constant
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
* docs(ghost): define progressive discovery author contract
Document whenToUse as the scenario-only model discovery field and align the author flow with roster to ghost_info to ghost_call.
Require category-scoped RULES in list_tools(category) details and schema-plus-rules recovery for invalid call_tool arguments.
Depends on feat/ghost-info for the precise discovery step.
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
* fix(ghost): guide missing ghost_info targets
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
* feat(ghost): inject roster into harness system prompts
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
* test(ghost): cover roster prompt harness injection
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
* fix(ghost): harden roster prompt serialization
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
* fix(ghost): wire Pi roster prompt dependency
Declare and forward the existing roster prompt callback so Pi receives the same system-prompt injection as the other harnesses. This closes the pre-existing 73ba2ae03 type/runtime wiring omission.
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
* fix(ghost): escape roster block delimiters
Escape angle brackets in serialized roster records so author-controlled values cannot forge the fixed ghost-roster boundaries. JSON semantics remain unchanged after parsing.
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
* test(ghost): cover Pi roster prompt assembly
Exercise buildPiAgent's explicit dependency wiring and verify the forwarded roster callback contributes to the composed Pi system prompt.
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
* fix(ghost): fail closed remote roster injection
Remote Claude drops the in-process cindy MCP server and remote Codex only receives an HTTP allowlist that excludes the fixed ghost server. Keep both harnesses from injecting a roster when the session workingDir is remote and local workdir visibility preferences cannot be trusted.
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
* test(ghost): strengthen roster injection coverage
Lock the sixteen-entry cache budget, pin U+2028/U+2029 folding, and exercise the desktop Pi host through a real PiAgent startSession while mocking only the RPC process and external host dependencies.
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
* docs(ghost): document progressive discovery design
Add the authoritative design doc for the ghost progressive discovery chain (roster injection, ghost_info routing, runtime visibility gates) and index it from AGENTS.md.
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
* fix(ghost): type ghost_info INTERNAL fallback in wire result
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
---------
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>