Repository navigation
Conversation
…e lifecycle boundaries
Confidence Score: 4/5The PR is not yet safe to merge because an unrelated same-user daemon can persistently block extension invocation through the orphan quarantine path. The new orphan mitigation avoids directly killing ambiguous processes, but it still treats timing and reparenting as sufficient attribution and stores unrelated live identities in a quarantine that rejects all later invocations. Files Needing Attention: bin/fm-extension.mjs Reviews (8): Last reviewed commit: "no-mistakes: apply CI fixes" | Re-trigger Greptile |
|
Speaking as Kun's firstmate: Reviewed HEAD Class: opt-in (home-local registry, explicit consents, absent registry inert) with security. Security (immediate): sudo env "PATH=$PATH" FM_TEST_OWNER_ONLY=1 FM_TEST_REQUIRE_FOREIGN_OWNER=1 \
bin/fm-test-run.sh tests/fm-extension-binding.test.shThat widens privilege on the CI runner for fork PR code (root execution of the PR's test harness). First-time fork CI is withheld for this HEAD under the security-risk exception. Pending runs left unapproved: VISION (per rule, inspected evidence):
What is not cleared:
Captain / Firstmate flag: YES — security (workflow privilege widening via Merge-eligible: NO. |
| if (pid === tracker.rootPid || entry.ppid !== 1 || entry.uid !== tracker.uid || entry.state.startsWith("Z")) continue; | ||
| if (entry.startedAt < tracker.startedAt - 1000 || tracker.baseline.get(pid) === entry.identity) continue; | ||
| if (tracker.descendants.get(pid) === entry.identity) continue; | ||
| if (tracker.unrelated.get(pid) === entry.identity) continue; | ||
| candidates.push({ pid, identity: entry.identity }); | ||
| } | ||
| return candidates; |
There was a problem hiding this comment.
Unrelated processes block invocation
When an unrelated long-lived same-user process starts and reparents to PID 1 during an extension invocation, ambiguousInvocationOrphans attributes it from timing and reparenting alone and persists it in the extension quarantine. The current invocation fails with process-attribution-ambiguous, and later invocations remain blocked with process-quarantined until the unrelated process exits.
|
Speaking as Kun's firstmate: closing this for the sudo-root CI job ( You can reopen without that job. |
|
@coderabbitai review |
Intent
Implement the smallest ergonomic, upstream-reviewable, vision-aligned Firstmate extension binding contribution on the exact fetched default-branch HEAD of github.com/kunchenguid/firstmate, and open a public PR against that exact repository without merging it. The first contribution must be a genuinely usable end-to-end vertical slice for trusted external process-event-adapter/1 adapters—not framework scaffolding: an external adapter must be registerable, configurable, discoverable from an explicit home-local registry, strictly validated, invokable, and safely retired, with a minimal runnable example, concise operator documentation, and executable-interface conformance/integration tests. Keep it narrow to this one extension type and aligned with Firstmate's explicit opt-in, flat, inspectable, deterministic, vendor-independent operating model; do not add lifecycle sinks, delivery-provider plugins, dynamic runtime backends, worker-launch grants, arbitrary before/after hooks, brief or instruction injection, project-local discovery, or any private names, paths, credentials, policy, behavioral constants, packages, or code.
An absent binding registry must remain permanently inert and state-free, preserve all built-in process-event behavior, and impose only a bounded cheap absence check. Discovery must read only explicit home-local bindings under the repository's configuration ownership conventions; project files, current directories, worker text, task copies, environment variables, and Pi packages must not register extensions. Separate a package manifest from a per-home enabled binding, pinning exact extension identity/version, host protocol, process-event-adapter/1 capability/version, allowed adapter names, canonical package root, complete code-tree digest, enabled capability subset, and required explicit consent facts. Provide repository-native setup, verification, inspection, registration, invocation, and retirement commands so operators do not hand-author opaque hashes or duplicate generated state.
Never source, eval, or shell-expand extension code. Invoke one exact executable without a shell using strict bounded UTF-8 JSON on stdin/stdout, bounded stderr, exact request identity, deterministic version negotiation, and a fixed handshake/invocation contract. Before accepting evidence, validate package-root confinement, same-user ownership and safe modes, canonical paths, symlink and hard-link hazards, manifest and complete-tree integrity, executable identity, protocol/capability agreement, response schema and size, timeout, process cleanup, and request-id matching. State honestly that this is trusted same-user code, not an OS sandbox. Keep lifecycle and authority transitions in existing Firstmate core owners: extension bytes are untrusted evidence and never authorize captain decisions, merges, destinations, force, discard, cleanup, credential use, or stronger operations.
Extend process-event registration to pin extension identity, capability version, package digest, and an owner identity, and require owner-matched conditional retirement so a stale owner cannot retire a replacement. Preserve built-in adapter behavior and compatibility during the documented migration window. Put each contract in exactly one current owner: docs/configuration.md for home-local layout, a focused maintainer architecture document for manifest/envelope/capability contracts, script headers and --help for mechanics, concise process-event supervision cross-references, and current repository verification evidence. Do not inflate AGENTS.md with conditional procedure.
Conformance coverage must exercise absent-registry parity; manifest, path, mode, owner, link, and full-tree digest checks; handshake and deterministic negotiation; malformed, invalid-UTF-8, unknown, duplicate-key, and oversized JSON; bounded stderr; timeout and process-tree cleanup; crashes, nonzero exits, and missing executables; replay/idempotence and request identity; owner-matched retirement; unhandled captured output; authority-injection attempts; and independent local and remote-home paths. Tests must validate executable interfaces, not implementation-source bytes. Inspect every supported primary worker runtime and session-provider integration ownership boundary and mark an axis not applicable only after real inspection. Run the current repository's lint, documentation-audience checks, focused tests, broad tests, and maintainer verification, reviewing the complete final branch diff after every automated correction. Use GitHub author/committer M00NLIG7 [email protected]. The PR title should be "feat(extensions): bind trusted external process-event adapters" unless current upstream conventions require a clearer equivalent. The authorized PR base is exactly github.com/kunchenguid/firstmate; do not merge the PR.
What Changed
process-event-adapter/1packages.Risk Assessment
Testing
Scoped the supplied diff and CLI contracts, ran the focused executable-interface suite, and completed a fresh-home bind-to-retirement flow captured in the attached transcript; all exercised behavior passed, but the suite skipped its foreign-owner fixture because chown privilege was unavailable.
Evidence: Fresh-home extension-binding end-to-end CLI transcript
Source: Fresh-home extension-binding end-to-end CLI transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed (7) ✅
tests/fm-extension-binding.test.sh:448- Required criterion: “Conformance coverage must exercise ... owner ... checks.” This test reports a pass whenchownis unavailable, so normal unprivileged CI can merge without executing the owner-mismatch path. Make this case mandatory in a supported test environment instead of treating inability to construct the fixture as success.tests/fm-extension-binding.test.sh:621- Required criterion: conformance coverage must exercise “independent local and remote-home paths.” Both homes here are ordinary local temporary directories and invoke the scripts directly; no supported remote-home execution or transfer boundary is exercised. Add an executable remote-home-path case, or explicitly approve same-host simulation as containment.🔧 Fix: Enforce owner and remote-home conformance
1 error still open:
tests/fm-extension-binding.test.sh:693- Required criterion: remote-home coverage must use an “independently addressed remote home” and preserve its “serialization and path boundary.” The bind passes controller-local$P_REMOTEthroughfm-on, while the fake SSH process shares the same filesystem, so no package bytes cross a remote transfer boundary and this would not work against a genuinely remote host. Stage the package through an existing supported remote transfer mechanism into a remote-only path, or re-escalate if none exists.🔧 Fix: Enforce serialized remote extension package lifecycle
2 errors still open:
docs/configuration.md:616- Required criteria say an external adapter must be “safely retired” and require repository-native retirement commands. The only extension retirement command isretire-transfer; the documentation explicitly says it leaves the enabled binding intact, so the adapter remains discoverable and invokable unless an operator manually deletes registry state. Add identity-conditional binding retirement with local and remote lifecycle coverage.bin/fm-extension.mjs:1497- Transfer retirement validates the staged package structurally but never compares the returned manifest identity or tree digest with the receipt. A modified staged tree can therefore be moved as the purported exact transfer. Compare the validated package id, version, and digest—and its version directory—with the receipt before renaming it.🔧 Fix: Enforce identity-conditional extension retirement
2 errors still open:
bin/fm-extension.mjs:1553- Required criterion: bindings must be “safely retired,” and retirement must refuse while a registration depends on the binding.register-extensionresolves the binding before acquiring its source lock, while retirement separately runs this preflight and then removes the binding. A registration can resolve, retirement can observe no registration and remove the binding, and registration can then publish a dangling owner record. Serialize resolve-and-publication with preflight-and-removal at one home-local lifecycle boundary.bin/fm-extension.mjs:1524- Required criterion: transferred adapters must be safely and reversibly retired through repository-native commands. A crash after moving the binding intostaging/.../binding.jsonbut before moving the staging directory leaves a partial retirement. Retrying fails earlier withbinding-missing, so the laterretirement-partialcheck cannot recover or complete it. Makeretire-transferrecognize and resume or restore this exact digest-bound partial state.🔧 Fix: Serialize extension retirement and recover crash cuts
2 errors still open:
bin/fm-extension.mjs:1778- Required criterion: an external adapter must be “safely retired.” The executable dispatcher exposesretire-binding-lockedandretire-transfer-lockeddirectly, bypassing the lifecycle lock. A registration can therefore resolve and pause before publication, a direct locked retirement can observe no registration and remove the binding, and registration can then publish a dangling owner record. Keep the locked implementation unreachable from the public dispatcher, or enforce serialization at the shared Node retirement boundary.bin/fm-procevent.sh:1243- Required criterion: retirement must remain safely serialized. The shell owns the lifecycle lock while a separate Node child performs retirement. If that shell process dies without also terminating the child, lock recovery can admit registration while the original child continues preflight and removal, recreating the registration/retirement race. Make the process performing retirement own the lock for its full lifetime, or ensure owner death cannot release serialization while its child remains active.🔧 Fix: Unify retirement worker and lifecycle lock ownership
3 errors still open:
bin/fm-procevent.sh:408- Required criterion: an external adapter must be “safely retired.”register-extensioncan replace source X while X’s previous extension runner is still polling. Retirement of the old binding then sees only the replacement registration, removes the old binding, and the old runner can subsequently capture an unclassifiable result pinned to that retired binding. Track the binding dependency through the active claim lifecycle or prevent replacement until the prior runner stops.bin/fm-extension.mjs:964- The SIGTERM/SIGINT handler releases the lifecycle lock while an asynchronous retirement rename may still be in flight. Registration can acquire the released lock, resolve the binding, and publish before that rename commits, recreating a dangling registration. Keep the lock until process exit and let dead-owner recovery reclaim it, or join all mutations before releasing.bin/fm-extension.mjs:1707- Retirement propagatesFM_STATE_OVERRIDEto the lock-owning worker, but the worker drops it when spawningbinding-retirement-preflight. With registrations under the overridden state root, preflight scans$FM_HOME/state, finds no dependency, and can remove an in-use binding. Propagate the same override into the preflight environment.🔧 Fix: Harden extension lifecycle retirement serialization
2 errors still open:
bin/fm-procevent.sh:416- Required criterion: external adapters must be “safely retired.” The new active-runner refusal only guardsregister-extension; ordinaryregistercan still overwrite the same source with a built-in record while its extension runner is polling. Retirement then sees neither an extension registration nor a captured result, removes the binding, and the old runner subsequently captures evidence pinned to the retired binding. Enforce the extension-claim dependency at the shared registration-publication boundary for every registration owner transition.bin/fm-extension.mjs:1052- An extension registered withFM_STATE_OVERRIDEcaptures results below the overridden state root, but the host only accepts result files below$FM_HOME/state/procevent-inbox. Consequently terminal/silent evaluation andclassifyreject valid captures as path-unsafe. Derive the effective state root consistently for captured-result confinement and extension working state.🔧 Fix: Unify extension registration and overridden-state lifecycle boundaries
✅ Re-checked - no issues remain.
tests/fm-extension-binding.test.sh:289- The authoritative intent requires conformance coverage for same-user ownership checks, but the foreign-owner rejection fixture was skipped because this environment lacks chown privilege. Captain, either rerun this focused test in an isolated environment able to create foreign-owned fixtures or accept that this required behavior was not demonstrated locally.git diff --statandgit diff --name-status 7ee0c192e9d664b022361bd4609303bebfc7de14..b76e5e6832039a4a5bd43a307addc6db098eaf6ebin/fm-extension.sh --helpandbin/fm-procevent.sh --helpbash tests/fm-extension-binding.test.shFresh-home operator flow:list→bind→list/inspect/verify→register-extension→ supervisedstart→ captured-result inspection →classify/list→handled→ owner-matchedretire→ digest-matchedretire-bindingInitial manual bind through macOS’s/varalias, which correctly rejected symlink traversal; retried successfully through canonical/private/vargit status --shortafter testing to confirm no worktree artifacts remained✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix: Captain: fix extension binding ShellCheck findings
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.