Skip to content

feat(harness): establish native Prime daemon foundation #3

Closed

Description

@rynfar

Outcome

Establish the safe native-daemon foundation for Comet's Prime Agent harness. The Comet host must be able to locate an installed prime-agent package, load only its public ESM API through a Comet-owned Node shim, start a scoped private daemon, validate the daemon hello and supported capabilities, and shut it down within bounded deadlines.

Parent umbrella: #1
Prime fork tracker: pylon-code/prime-agent#1
Pylon provider umbrella: pylon-code/pylon#114

Ownership

  • Repository: rynfar/comet
  • Branch: feat/prime-daemon-foundation
  • Worktree: ~/repos/comet-prime-daemon-foundation
  • Initial file area: crates/harness/src/prime/**, crates/harness/src/lib.rs, focused crates/harness/tests/**, and only required manifest/lock changes
  • Owner: rynfar

No Prime or Pylon checkout is owned by this issue. Their active worktrees must remain untouched.

Public contract

  • Resolve the configured Prime executable to its containing prime-agent package.
  • Import only the package's public exports["."] entry.
  • Validate matching package/public VERSION, DAEMON_PROTOCOL_NAME == "prime-agent.daemon", and daemon protocol >= 7.
  • Start prime-agent --mode daemon --daemon-socket <private> --offline --session-dir <private>.
  • Validate that hello reports the requested socket and the baseline capabilities needed by later Comet session work.
  • Strip inherited PRIME_AGENT_INTERNAL_* and RLM_DEPTH; preserve public configuration such as RLM_MAX_DEPTH.
  • Keep sockets, package paths, session roots, raw hello payloads, and diagnostics host-private.

Optional capabilities, including correlated_prompt_lifecycle_v1, are recorded from negotiation. Method presence, schema number, package version 0.8.1, and branch names are not support signals.

Compatibility

Stock Prime Agent 0.8.1 must pass the baseline foundation even though it lacks the Pylon correlated-lifecycle capability. This issue sends no prompts and creates no Comet sessions, so it can merge before the active Prime recovery work.

Later session/recovery slices depend on:

A fork-only capability must degrade to an explicit unsupported state. It must never prevent safe baseline probing or daemon shutdown.

Privacy and sync boundary

This slice exposes no new RPC, synchronized document field, or UI. The Rust/Node boundary may emit only a bounded, normalized handshake result and typed local errors. It must not emit credentials, environment values, native session paths, prompts, or raw daemon messages.

Tests

Use deterministic local fixtures. Do not require a real model, credentials, network access, or the active Prime worktree.

Cover:

  • valid installed-package resolution through a CLI symlink;
  • wrong/missing package and unsafe public export rejection;
  • version/protocol/hello mismatch rejection;
  • baseline and optional capability parsing;
  • private socket/session-directory construction and permissions on Unix;
  • sanitized daemon environment;
  • startup timeout, early exit, stderr redaction, graceful shutdown, and forced cleanup;
  • unknown future capabilities degrading safely.

All subprocess probes and tests must have explicit deadlines.

Non-goals

  • HarnessId::PrimeAgent registration or UI
  • session create/attach/resume
  • prompts, streaming, steering, interruption, or subagents
  • model/resource discovery
  • ACP fallback
  • Windows native-daemon support
  • changes to Prime or Pylon contracts

Merge order

  1. Merge this Comet-only foundation after its fake-protocol tests pass.
  2. Finish/audit the linked Prime fork recovery and upstream-sync work.
  3. Open a separate, jointly reviewed Comet session-lifecycle issue before consuming correlated prompt lifecycle or snapshot recovery.

Acceptance

  • A focused test proves Comet can safely negotiate and stop a fake stock-compatible daemon.
  • The module exposes a narrow reusable foundation for the later native PrimeHarness.
  • The issue contains test receipts and the exact final file list.
  • No host-private Prime state crosses the Comet sync boundary.

Activity

  1. self-assigned this
    on Aug 29, 2026
  2. rynfar commented on Aug 29, 2026

    @rynfar
    OwnerAuthor

    Claimed for implementation.

    • Worktree: ~/repos/comet-prime-daemon-foundation
    • Branch: feat/prime-daemon-foundation
    • Base: origin/main@b5209928cf1eb69d97634b5f6f34a512a9c21c6e
    • Owned files: crates/harness/src/prime/**, the crates/harness/src/lib.rs module/export seam, focused harness fixtures/tests, and only required manifest/lock changes
    • Shared contract: read-only use of Prime's public daemon package API; no Prime/Pylon code or protocol changes
    • Compatibility: stock protocol-v7 baseline plus capability-negotiated optional fork features
    • Merge dependency: none for this no-session foundation; later session/recovery work remains blocked on the linked Prime issues

    No other Comet, Pylon, or Prime Agent worktree will be modified. Implementation will begin with deterministic fake package/daemon fixtures and bounded process ownership.

  3. rynfar commented on Aug 30, 2026

    @rynfar
    OwnerAuthor

    Foundation implementation is complete and pushed in PR #4.

    Commits

    • ed843b3 — feat(harness): add native Prime daemon foundation
    • 9e26a90 — test(harness): harden Prime daemon lifecycle

    Exact final file list

    • Cargo.lock
    • crates/harness/Cargo.toml
    • crates/harness/src/lib.rs
    • crates/harness/src/prime/contract.rs
    • crates/harness/src/prime/error.rs
    • crates/harness/src/prime/mod.rs
    • crates/harness/src/prime/package.rs
    • crates/harness/src/prime/paths.rs
    • crates/harness/src/prime/process.rs
    • crates/harness/src/prime/shim.mjs
    • crates/harness/tests/prime_daemon.rs
    • crates/harness/tests/support/mod.rs
    • crates/harness/tests/support/prime_fixture.rs

    Test receipts

    • Prime-focused Rust unit suite: 15 passed.
    • Deterministic integration suite: 23 passed, 1 opt-in installed-package smoke ignored.
    • Installed stock Prime Agent 0.8.1 discovery/public-load/connect/shutdown smoke: 1 passed.
      • package manifest SHA-256: 1300cc08c354b807d1ad5288ca23ec859f40361b1cd8a0f71d09d867523dfcbb
      • public dist/index.js SHA-256: 0555400963ce5c9fa3059c3ed571748715d3ddda3830085eb8f12da00708d49b
      • canonical CLI entry SHA-256: c5dffcd16a401551986023134fbc05457775e1eeed618a5a6ae0d0cee1772d5f
    • Wider harness library suite excluding one reproduced baseline failure: 105 passed.
    • Clippy with six explicit pre-existing lint exceptions: passed.
    • Prime files rustfmt --check, Node syntax, and git diff --check: passed.

    origin/main@b520992 independently reproduces the excluded shell_env::unix::tests::falls_back_when_interactive_attempt_hangs panic at shell_env.rs:330. Existing ACP unused-assignment warnings are unrelated and unchanged.

    Compatibility and privacy

    • Stock protocol v7 is the baseline; compatible future hello versions use >= 7.
    • Stock 0.8.1 needs no correlated-lifecycle capability.
    • Optional and unknown capability tokens are bounded server offers only. Later attach must advertise the matching client capability.
    • The bootstrap bridge is non-secret and bootstrap-only. The host-private daemon preserves public provider/custom environment configuration while stripping PRIME_AGENT_INTERNAL_*, RLM_DEPTH, and Node/dynamic-loader injection.
    • Socket/session/package paths, environment values, raw payloads, stderr, and diagnostics never enter Comet sync or RPC state.
    • Stable per-provider sockets use owner-only trees plus a kernel lock. Crash leftovers are retired only after a compatible bounded handshake; incompatible live listeners fail closed without unlinking.
    • Cancellation and timeout paths transfer process ownership to bounded TERM/KILL reapers.

    Review and next boundary

    Independent architecture and adversarial security rereviews both report no remaining merge blockers for issue #3.

    This PR starts no Prime sessions. The next issue must define the asynchronous SDK session host, attach-side capability negotiation, event/response demultiplexing, authoritative detached-worker reconciliation, and recovery. Long-lived session work is blocked on bounded SDK JSONL ingress in pylon-code/prime-agent#13 and remains coordinated with pylon-code/prime-agent#8, pylon-code/prime-agent#11, and pylon-code/pylon#114.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions