Skip to content

feat(edge): run MOI user runners in the background - #1227

Merged
mergify[bot] merged 30 commits into
matrixorigin:mainfrom
loveRhythm1990:feat/user-runner-background
Nov 21, 2026
Merged

mergify[bot] merged 30 commits into
matrixorigin:mainfrom
loveRhythm1990:feat/user-runner-background

Conversation

@loveRhythm1990

@loveRhythm1990 loveRhythm1990 commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Capability assessment: Unchanged: User Runner execution stays Partial with the same explicit Edge binding. Local supervision of the existing MOI connect command does not change admission, profiles, or the capability matrix.

Summary

MOI asks people to paste astra-edge --edge-id runner-… --server-url … --token … --reconnect true and leave the terminal open. A new binary now detaches only that interactive command, waits until the existing authenticated-ready signal, and returns the prompt with status, logs, and stop. Old binaries keep running the same command in the foreground because no flag was added.

Sandbox, containers, and image-managed runners stay in the foreground. They start astra-edge with credentials in the environment and do not use this argv. The parent does not hold the MOI installation lease. The child calls setsid, ignores SIGHUP, and holds the lease until it exits.

Related issue

Closes #1226

Change type

  • Feature
  • Bug fix
  • Documentation
  • Refactor or performance improvement
  • Test
  • Build, CI, or maintenance

User and compatibility impact

The generated MOI connect command is unchanged. A new astra-edge backgrounds it only from a terminal when the argv contains an explicit runner- edge id, server URL, non-empty token, and --reconnect true. ASTRA_EDGE_FOREGROUND=1 keeps that invocation in the foreground. Environment-only identity does not detach.

Before the child reports ready, SIGINT or SIGTERM to the parent stops and reaps it. After ready, the child survives terminal closure. astra-edge status, stop, and logs accept --edge-id and --server-url. A second launch does not start another worker; only a connected phase is reported as already connected. Logs stay outside the workspace. The runner checks rotation every 30 seconds and rotates a log that exceeds 8 MiB. The command token is not stored in runner metadata.

Token renewal and the product refresh action are unchanged. Refresh still revokes the current token. Dialog copy is a Matrixflow follow-up because the page cannot see which binary the user has.

When switching from an Edge version that used a journal without a Server identity, pause submissions, let the old Edge deliver and settle its outstanding results with its Server, then stop it before starting the new binary. Carry unresolved outcomes forward as unknown and exclude them from automatic resubmission. The new binary opens the server-scoped journal and leaves old journal files untouched.

Architecture and complexity delta

  • Canonical owner changed or extended: crates/astra-edge owns the managed lifecycle for the existing MOI argv. The existing connection owner withdraws readiness at detach and settles admitted work before reconnecting. The journal stays scoped to the Server, Edge identity, and workspace.
  • Existing implementations and callers searched: edge main, the post-auth ready signal, the installation lease, sandbox environment startup, and the MOI connect command bytes.
  • Superseded code, states, tables, shims, or self-only tests removed: the pre-server reader, cross-version lock, cutover marker, and outbox conversion were removed. The local stop command publishes its existing stop request for the live instance to consume.
  • If parallel implementations remain, their boundary and retirement condition: foreground remains the path for old binaries, non-interactive runs, containers, and sandbox or image-managed runners. No second supervisor is introduced.

Verification

  • cargo test --locked -p astra-edge passed 150 tests, including two runs of the actual Edge binary through a PTY and local WebSocket server.
  • cargo clippy --locked -p astra-edge -p astra-cli --all-targets -- -D warnings, make format-check toolchain-check, python3 scripts/ci/validate_repository.py, and git diff --check passed.
  • CI contract tests passed with 266 cases run and 7 skipped.
  • The PTY tests cover authenticated startup, terminal closure, status and logs, rejection before readiness, disconnect while a tool is active, result replay and ACK, and explicit stop. A two-Server test uses the same Edge identity and workspace and verifies that both connections open their own journals.
  • Database verification: this PR changes no schema, queries, or migrations. Live MOI product verification remains separate from the offline CLI tests.

Final checklist

  • I added or updated tests at the layer that owns the behavior, or
    explained why no test is needed.
  • I updated public or design documentation for contract changes, or the
    change needs no documentation update.
  • I checked the diff for credentials, private URLs, customer data,
    generated files, and other sensitive information.
  • The PR title follows the repository's Conventional Commit format.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The background runner needs changes before it can reliably replace the foreground MOI connect journey. I found four lifecycle and usability problems below. In an isolated worktree, targeted counterexample tests reproduced the ignored replacement token, duplicate identity and delayed-readiness race; the command-path finding follows the current MOI installer. These are tests of the proposed behavior, not CI failures.

Please use the existing connection lifecycle as the authority and cover the actual refresh, reconnect, and installed-client paths without adding another parallel state machine.

Comment thread crates/astra-edge/src/main.rs Resolved
@loveRhythm1990

Copy link
Copy Markdown
Collaborator Author

Addressed the four review findings in c75c3d9.

  • A refreshed connect command now restarts the locked runner with the new token. The token stays out of runner metadata; the child uses the existing startup selection, and later reconnects use that process's current token.
  • Equivalent server URL spellings share one instance key and one status/stop match, using the same websocket destination as edge_ws_url.
  • A readiness callback captured before disconnect cannot overwrite a later reconnecting or stopping phase, and does not tell the parent that attempt is ready.
  • status, logs, and stop are printed with the installed executable path and shell quoting. ASTRA_EDGE_FOREGROUND is documented.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed the latest head and the four earlier findings. The changed code now normalizes destination identity, fences stale readiness, prints the executable path, and no longer silently ignores a different command token. Those review threads are still open on GitHub. The new replacement path, however, introduces the in-flight-work problem below, and lock I/O errors also produce an incorrect success.

All 18 existing managed-background tests passed locally. A separate test holding the actual lock while making it unreadable reproduced the false stopped result; the active-work effect follows the existing shutdown and invocation-owner implementation.

@loveRhythm1990

Copy link
Copy Markdown
Collaborator Author

Addressed the two new findings in ca7b7a9.

  • A refreshed credential is queued for the running runner and staged as an unproven candidate on its next connection. Admitted work is not signalled. If that candidate cannot authenticate, the existing one-shot fallback restores the working credential, and the token file is left unchanged until a credential proves itself.
  • status and stop return an error when the instance lock cannot be inspected. They report stopped only after the lock is positively unheld.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Request changes at ca7b7a95176a2475075de14953294974ab96d701.

The background-connect user journey is useful, and reusing serve_connection, authenticated readiness, the installation lease and TokenManager is the right direction. I also checked latest main 77ab026883ebe2249d5e0cc1e7fcf10306105a88: its two commits after this PR's base do not modify the Edge/background/token/installation owners. The findings below still apply.

There are three verified issues: a newly handed-off credential can be abandoned on permanent authentication failure, a newer pending credential can be deleted by an older consumer, and a readiness test fails with ordinary higher-numbered file descriptors. The first two leave the connect command reporting a successful handoff without delivering the credential. They need a coherent handoff through the existing credential/connection owner, with atomic consumption and accurate acknowledgement; another retry/status state machine would add complexity without resolving ownership.

Earlier comments: URL normalization, readiness generation ordering, executable-path quoting and lock-inspection error handling have been addressed. Refresh no longer terminates the process, so that earlier cancellation regression has been removed structurally. However, the original refreshed-credential recovery concern is not completely closed: the public binary still exits without trying a token submitted during authentication. The added admitted-work test operates on a separate TokenManager beside a connection; it does not exercise the actual supervisor-to-runner handoff and reconnect.

Complexity: Git reports +2,261/-44, net +2,217 across six files. Splitting at the Rust test modules gives approximately +1,416 production lines, +785 test lines and +16 documentation lines (physical lines, including comments/blanks; Cargo feature edit has zero net lines). Background process management justifies some of that code, and there is no added SQL or per-tool persistence path. The credential fingerprint, pending file and in-memory token still disagree in the failing interleavings, so that part of the added complexity has not earned its maintenance cost. Simplify its ownership rather than preserving the races with extra states or compatibility paths.

Validation performed:

  • Built the PR's real astra-edge binary successfully.
  • cargo test -p astra-edge --bin astra-edge: 65 passed, 1 failed; the failure is the FD-dependent readiness test identified inline.
  • Real binary + local WebSocket peer: initial managed startup, refresh before disconnect, reconnect using the fresh credential and public stop all passed. Holding the old-token authentication response until after the refresh command returns reproduced the terminal failure, with the fresh token still queued and never attempted.
  • Compiled the unchanged background source with an external interleaving fixture: a newer queued token was deleted by the older reader's acknowledgement.
  • The readiness test passes alone with low FDs and fails deterministically when inherited descriptors force its pipe above 9 (/bin/sh: Syntax error: Bad fd number).
  • git diff --check passed; source worktree remains clean. GitHub currently shows 38 successful checks, one skipped and one neutral; those do not invalidate the local reproductions.

No subagents or source edits were used. No live MOI deployment, paid model harness or macOS execution is claimed. Review fixtures/logs remain outside the repository. Ordinary review used the current agent; no independent-review model gate was invoked.

Comment thread crates/astra-edge/src/main.rs Resolved
@loveRhythm1990

Copy link
Copy Markdown
Collaborator Author

Addressed all three findings in 36c4b72. The handoff now goes through the existing owners only (TokenManager, the start lock and the connection loop). There is no new retry or status state.

  • [P1] Queued refresh during in-flight authentication. The connection loop now lives in run_connection_loop. Before it gives up on a rejected credential, it takes start.lock and claims any credential handed to it. If one is queued, it reconnects with that credential instead of exiting. The connect command also queues under start.lock, so the two are ordered. Either the credential is queued before this decision and is tried, or the command waits until this runner has exited (the lock is held until process exit) and then starts a new runner itself. Before readiness the starting command still holds that lock, so no handoff can race the first attempt. credential_handed_off_during_authentication_is_tried_before_exiting replays your interleaving against the real loop and a local WebSocket peer. The first attempt sends the old token and the peer holds the response. The fresh credential is queued with the same helper the connect command uses, and only then is the old token rejected. The test asserts the second attempt sends Bearer fresh-token and that the loop does not exit with an error.
  • [P2] Acknowledging an older credential removed a newer one. The runner claims by atomically renaming credential.next to credential.claimed, then reads and removes only the claimed file. A handoff published after the rename stays queued for the next claim. Staging into TokenManager is now infallible: outstanding persistence debt ends there, the same as swap_to_fallback, and mark_proven heals the file. So a claimed credential is never dropped. claiming_a_credential_never_removes_a_newer_handoff covers read gen-1 → publish gen-2 → acknowledge gen-1 → gen-2 still claimable.
  • [P2] FD-dependent readiness test. The pipe is now mapped to the child's stdout, so the shell never redirects to a multi-digit descriptor.

Also:

  • The separate-TokenManager admitted-work test is replaced by handed_off_credential_reconnects_without_interrupting_admitted_work. It runs the real loop: a Bash invocation is admitted, a credential is handed off while it runs, and the test asserts that the invocation completes normally. After the server closes the connection, it asserts that the reconnect sends the fresh credential.
  • The connect command now says the running runner uses the credential from its next connection attempt, instead of implying immediate delivery. A runner in the stopping phase refuses a handoff.
  • write_private uses <name>.tmp, so credential.next and credential.fingerprint no longer share a temporary path.

Validation: cargo test -p astra-edge --bin astra-edge 69 passed (three consecutive runs). cargo clippy -p astra-edge --all-targets -- -D warnings is clean, and cargo fmt was applied.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The nine earlier threads are marked resolved and the previously reported nominal interleavings have corresponding changes. However, the credential and process-lifecycle guarantees still fail under the counterexamples below. The main design issue is that submitted, pending, in-memory and proven credentials can diverge, while process decisions are made from separately updated lock, PID and status files. Please simplify the ownership and ordering of those existing facts rather than adding another parallel state machine.

Validation at this head: all 69 existing astra-edge binary unit tests passed locally on macOS. Eight additional isolated counterexample tests failed, covering the seven findings below (the credential-claim finding has two independent cases). The connection-order test uses the real connection loop and a local WebSocket peer; the startup/stop test uses the real supervisor and management paths with a controlled child. The PID test signals only a test-owned helper. No live MOI product integration was run.

The patch adds 1,590 production lines and removes 61, plus 913 test lines and 18 documentation lines (excluding one-line Cargo feature change). The idle log rotator also adds one thread and a filesystem metadata check per second per local runner; no high-runner-count benchmark was available. These costs are worth reassessing along with the duplicated lifecycle/credential state, especially as the present abstractions do not yet preserve the required guarantees.

Comment thread crates/astra-edge/src/token_manager.rs Resolved
@loveRhythm1990

Copy link
Copy Markdown
Collaborator Author

Addressed review 5810084084 in c2f4471. Instead of patching each finding locally, this round removes the duplicated facts that caused them: lifecycle state now comes from kernel locks, and the credential decision has a single owner.

  • [P1] Proven fallback across several candidates — TokenManager tracks the credential that last authenticated (proven). Staging a new candidate keeps proven as the fallback, so after old → bad-one → bad-two the runner falls back to the old credential (superseded_handoffs_still_fall_back_to_the_proven_credential). Token renewal carries proven over as well.
  • [P2] Last submitted ≠ active credential — the fingerprint file is gone. Every connect command against a running runner hands its credential over; only TokenManager decides whether it differs from the one in use, so resubmitting a previously rejected credential is tried again.
  • [P2] Claim/read failure — credential.claimed stays until the value is staged (finish_claim). A failed read or an interrupted consumer retries it, and a newer handoff still replaces it by rename (claims_survive_read_failures_and_interrupted_consumers).
  • [P1] Stop vs. a start in progress — stop takes start.lock while inspecting the owner and signalling, so it either waits for the start and stops that runner, or the start begins afterwards (stop_waits_for_a_start_in_progress_and_stops_its_runner).
  • [P2] PID ownership — instance.lock is now a POSIX record lock and stop signals the pid that F_GETLK reports as its owner. The pid file and the executable-name check are removed. A decoy pid in a stale pid file is not signalled (stop_signals_only_the_process_that_owns_the_instance_lock).
  • [P2] Stale connected — connected is published only by holding connected.lock, which is released when the runner leaves that phase. Releasing needs no filesystem write, and a recorded connected without the lock reads as unknown (non-zero status) (a_failed_phase_write_does_not_leave_the_runner_reported_connected).
  • [P2] Unreadable metadata — live runners whose state cannot be read are reported, and status/stop/logs fail rather than conclude "No managed runner". Positively unlocked directories are still skipped (live_runner_with_unreadable_metadata_is_never_reported_absent, unreadable_lock_is_not_reported_as_stopped).

Found in self-review and fixed in the same commit:

  • A handoff left by an exited runner could override the credential of a fresh start; it is now discarded under start.lock before spawning.
  • Token renewal dropped the proven marker (covered by a_renewed_proven_credential_stays_the_fallback).
  • Log rotation runs as a 30s tokio task instead of a dedicated thread.

Lifecycle tests use a real separate lock-holder process instead of in-process locks, and the key assertions were mutation-checked (e.g. reverting the fallback rule, stop without start.lock, trusting the phase file).

Known residuals: a small window between F_GETLK and kill, and a runner in a container pid namespace can report l_pid 0, in which case stop fails instead of guessing.

Validation: cargo nextest run -p astra-edge --bins --profile ci 77/77 and cargo clippy -p astra-edge --all-targets -- -D warnings on macOS; cargo test --locked -p astra-edge --bin astra-edge 77/77 and clippy clean on Linux (rust:1.97, non-root, dash /bin/sh).

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Request changes at 48023bc.

The background runner is useful, but the lifecycle and credential owners still disagree in six reproducible cases below. Two can leave a remote execution endpoint running after the initiating terminal or an explicit stop has gone away. The fix should make the existing start/stop ownership and TokenManager ordering authoritative; adding another independent state machine would leave the same coordination problem.

Earlier review: 15 of 16 previous threads are marked resolved. The remaining thread's old → bad-one → bad-two sequence is now covered and passes, but the renewal/authentication interleaving below still loses the usable fallback. The new stop test begins only after metadata exists, and the readiness test covers callback ordering without checking whether the reported child is still alive.

Incremental cost (physical lines including comments and blanks): implementation +1,706/-80, tests +1,262/-0, documentation +19/-0; total +2,987/-80. The feature adds no SQL or per-session database path. Each managed runner also schedules a log metadata check every 30 seconds (about 33 checks/second averaged over 1,000 runners, potentially burstier); phase transitions perform synchronous file writes. I did not benchmark 1,000 runners, so this is not a scalability claim.

Validation on macOS at this exact head: the unchanged cargo test --locked --offline -p astra-edge --bin astra-edge passed 78/78 and git diff --check passed. Eight isolated counterexample tests failed across the six findings. They exercised the real connection loop and renewal cycle with local WebSocket/HTTP peers, and real supervision/management functions with test-owned lock-holder processes and signals. No live MOI deployment or Linux reproduction was run. The main checkout was not modified.

Comment thread crates/astra-edge/src/token_manager.rs Resolved
Comment thread crates/astra-edge/src/main.rs Resolved
@loveRhythm1990
loveRhythm1990 force-pushed the feat/user-runner-background branch from 48023bc to 3e24aca Compare November 9, 2026 07:11
@loveRhythm1990

Copy link
Copy Markdown
Collaborator Author

Addressed review 5812893202 in 3e24aca, rebased onto main 7593e30.

The six cases were the same ordering problem: start, stop, and the proven credential were each observed from a fact that could still change. This round makes start.lock and TokenManager the decision points, instead of adding another state file that those owners can disagree with.

  • [P1] Stop during an unpublished start — stop takes start.lock for a state directory whose start has not written metadata yet. It then stops the runner that start publishes, or removes the unpublished directory so that start cannot launch after stop returns (stop_claims_a_start_that_has_not_published_metadata, stop_discards_an_unpublished_start_that_has_no_runner).
  • [P2] Credential accepted after SIGTERM — stop writes its decision before releasing start.lock. A connect command that runs after that decision sees stopping and does not queue a credential, even while connected.lock is still held (a_stop_rejects_a_credential_while_the_runner_is_still_connected).
  • [P2] Late AuthOk rewinds a renewed credential — once renewal has installed the replacement as both current and proven, mark_proven of the pre-renewal snapshot does not replace it. Renewal also records that replacement before the in-flight AuthOk (late_authentication_does_not_rewind_a_renewed_credential).
  • [P1] Supervisor hangup leaves the child running — the waiting supervisor handles SIGHUP as well as SIGINT/SIGTERM. If the readiness pipe's read end is gone, the child treats that as a rejected startup and exits (hangup_cancels_startup, a_closed_readiness_pipe_is_not_accepted).
  • [P2] Buffered ready byte — readiness is accepted only when the child is still alive and startup has not been cancelled (a_buffered_ready_byte_is_not_success_after_the_child_exits, a_buffered_ready_byte_does_not_override_startup_cancellation).
  • [P2] Invalid argv still hands off — supervise runs the canonical parser before taking the startup lock, so an unknown option cannot queue a credential (an_invalid_connect_option_does_not_hand_off_a_credential).

Found while checking the same ordering, and fixed in the same commit:

  • A start blocked in lock_start checks that start.lock is still the file it acquired, so removing the directory cannot make it publish into a later start's directory.
  • stop does not delete unreadable state unless start.lock is actually held. A stopped runner with unreadable metadata keeps its log (stop_does_not_delete_unreadable_state_that_is_not_starting).

Validation: cargo test -p astra-edge --bin astra-edge 88/88 and cargo clippy -p astra-edge --all-targets -- -D warnings on macOS.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The background runner is useful, but the existing start/stop and credential owners still disagree in four reproducible cases below. In particular, three are gaps in the earlier resolved review threads: an in-progress start can still escape stop, an unaccepted ready signal can leave a remote execution endpoint running, and a late authentication can still overwrite a newer renewed token. Please resolve these at the existing ownership boundaries rather than adding independent lifecycle state.

All 22 earlier threads are marked resolved. The normal cases now have targeted coverage, but the three interleavings above remain open in substance. I also reproduced a separate misleading success in the public logs command.

Validation at head 3e24aca on macOS: the unchanged cargo test --locked --offline -p astra-edge --bin astra-edge passed 88/88. Four additional isolated counterexample tests failed: one uses equal-generation synthetic tokens, one pauses the actual startup sequence between directory creation and lock acquisition, one runs the real supervisor with a controlled child while stopping/killing the parent before it reads the ready byte, and one makes the log unreadable. The stop-gap fixture executes the same remaining startup operations in order; it is not a live MOI deployment. All processes were test-owned and cleaned up. No source in the main checkout or contract tests were changed.

Incremental cost: approximately +1,996/-79 production lines, +1,545 test lines and +22 documentation lines (physical lines, including comments/blanks; plus a one-line Cargo feature change). The 30-second log check adds about 33 filesystem checks per second across 1,000 runners on average, before bursts; this is an arithmetic estimate, not a load test. There is no added SQL. The added lifecycle and token coordination needs to cover the counterexamples to justify its maintenance cost.

The live DeepSeek harness job is currently red: 18/19 cases passed and flash_child_question_parent_answer observed two matching calls where it expected one. That observation does not establish a causal connection to this Edge-only PR. No live MOI or Linux execution is claimed.

Comment thread crates/astra-edge/src/token_manager.rs Resolved
@loveRhythm1990
loveRhythm1990 force-pushed the feat/user-runner-background branch from 3e24aca to e313995 Compare November 9, 2026 15:41

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Request changes: the latest startup coordination still has two reproducible user-visible races, described inline. In particular, the fix for publishing a start now makes an unrelated runner's control operations wait for a duplicate start, and the previously resolved delayed-readiness issue has reopened in the new lock arrangement.

The four previously open discussions have targeted changes/tests in this head, but those fixes do not establish that the combined lifecycle is correct. Keep the useful properties (one runner per identity, authenticated readiness, credential handoff without cancelling admitted work), while reducing the coordination surface: never wait for an individual runner while holding a registry-wide lock, and make the connection lifecycle the single owner of readiness/phase ordering. Low-probability failures can be reported honestly; they need not be hidden behind more persistent state.

The diff is +3,800/-82: approximately +2,104/-82 implementation/config, +1,672 tests, and +24 documentation. A local managed process and its credential lifecycle do need some coordination, but this amount of new locking, phase publication, files, and handshakes is not yet justified by the resulting robustness. The quickstart should describe user-observable behavior rather than the internal lock sequence. There are no new MatrixOne queries in this diff; I did not validate 1,000 concurrent runners or a real MOI deployment.

Validation on this exact head: Linux cargo test --locked -p astra-edge --bin astra-edge passed 92/92 and cargo test --locked -p astra-edge --lib passed 35/35. Two additional isolated, deterministic probes failed as described below; the second used a test-only scheduling barrier to expose the interleaving. Current GitHub CI still has harness, shared CLI executables, and online integration pending.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The current startup and log lifecycle still has reproducible correctness and robustness gaps; please address the inline findings before merging.

Validation: all 94 existing astra-edge binary tests pass. A real PTY-launched Edge with an unreachable local server continued reconnecting after its starting process was killed before readiness. Three additional isolated, deterministic probes reproduced the stale readiness acknowledgement, the blocked Tokio worker, and unrecoverable log rotation. These probes were review-only and were not committed.

The diff adds no MatrixOne SQL, but its size and coordination cost still need scrutiny: approximately +2,139/-81 implementation lines, +1,760 test lines, and +23 documentation lines. The runner now coordinates connection state through a readiness channel, phase file, several locks, credential files and process-global flags. Please use the existing lifecycle/connection ownership to reduce those overlapping facts rather than adding another recovery state machine. There is no evidence in this PR of behavior under large numbers of independently deployed clients.

Of the 28 existing review threads, six are still open. The code now includes fixes/tests for the start/stop publication race, global registry blocking, same-generation renewal and log-read errors, but the startup-owner and readiness-order concerns still have the distinct gaps demonstrated below. One previously resolved startup-owner thread also does not cover losing the parent before a first connection is ready.

Comment thread crates/astra-edge/src/main.rs Resolved
Comment thread crates/astra-edge/src/main.rs Resolved
@mergify

mergify Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Queue requested — the merge queue status continues in this comment ↓.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Request changes at e86dc660948c1ed6c447ec48297443d16efd364a. The new readiness work fixes several earlier cases, including parent loss before the first successful connection in a real PTY/child-process check, but the two inline findings remain user-visible: cancellation can be reported as success during the final confirmation, and independently managed runners can overwrite each other's persisted credentials.

Earlier review: 9 of 32 existing threads are still marked unresolved. Current code/tests address the specific earlier start-publication gap, global registry blocking, equal-generation renewal, unreadable logs, and the common buffered-ready/disconnect ordering. The revised parent-closure path also passed a real local executable check before first readiness. These observations are not proof that every earlier discussion is resolved; in particular, the two new counterexamples are not covered by those tests.

Design and scale: The current diff is +4,491/-80 (approximately +2,506/-80 implementation/config, +1,961 tests, and +24 documentation lines, counting physical lines). The latest lifecycle commit alone adds +661/-91. The feature does not add MatrixOne SQL, and locally scoped process ownership is appropriate. However, the extra registry/start/instance/connected locks, metadata/phase/stop/credential files, readiness handshake, epoch and process-global flags still disagree in the scenarios below. Please simplify around the existing lifecycle and credential owners, rather than adding another round of confirmations or persistent states. Low-probability failure can be returned honestly; the user must not receive a false success. No claim of 1,000 distributed clients has been validated here.

Validation: 101 existing Edge binary tests passed, both serially and with the normal parallel runner; the 35 Edge library tests passed. Two review-only tests failed on the concrete interleavings below. A built public binary launched from a PTY exited its reconnecting child when the starting parent was killed before first readiness. git diff --check passed. The current GitHub Test Suite and static/title workflows report success. No live MOI deployment, real credential refresh, macOS execution, or large-scale load test was performed locally. Temporary probes were not committed.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Deep review of be701b0 on machine57. Reviewed the complete 7-file change, the process/start/stop/readiness/credential/journal ownership paths, all 34 earlier threads, and implementation/test/documentation increments separately.

Request Changes for the two inline findings: (P1) startup-parent loss can abandon already admitted execution and its durable outcome; (P2) the newly independent Server identities still collide in the old workspace/edge-scoped journal. These are ownership integration problems, rather than a request for more manager states or another storage/execution path.

The earlier fixes are present: canonical argv validation and destination identity, installed-path management commands, stop/start ordering without a global wait, lock-owner PID lookup, unknown/error reporting, credential claim/proven fallback/renewal ordering, phase/readiness ordering and cancellation, log-rotation recovery, and per-runner persisted token placement. However, resolving the startup-parent threads by terminating the wrapper/worker did not close its interaction with active tool custody. Likewise, isolating credentials alone did not isolate the existing journal. The resolved flags do not establish those end-to-end invariants.

Local validation: all 103 existing astra-edge binary tests passed with two test threads. Two temporary review-only probes then failed at the expected production boundaries: a separate managed-loop subprocess + actual Bash + journal replay yielded outcome unknown after parent loss; two authenticated Server destinations contended on one journal lock. The probes reused the existing runtime/executor/journal and were removed from the test workspace afterward. No real MOI credentials, production endpoints, installation leases, or deployment were used. Required CI/head/conflict eligibility is rechecked before publishing this review.

Comment thread crates/astra-edge/src/main.rs Resolved
@loveRhythm1990
loveRhythm1990 force-pushed the feat/user-runner-background branch from be701b0 to 35c2800 Compare November 12, 2026 20:20

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Request changes on 06d5922782bd484dd728b24756fd1880dfe167c2 for the false custody detection below. It makes a previously used, fully settled Edge fail to start even though no invocation needs recovery, and it affects foreground/container runners as well as this PR's new managed runner.

The last review's two concurrency cases are addressed in the current design: new Server owners can share the legacy guard, and an old exclusive owner is fenced for the new owner's lifetime. Those properties should remain. However, a nonempty file is not the same as outstanding durable work; the requested correction can use the canonical journal facts or an explicitly chosen fresh-start contract instead of another state machine.

I reproduced the refusal with the exact current custody functions and a valid v3 snapshot containing zero records. This was a narrow extracted-code diagnostic, not a full MOI end-to-end run. git merge-tree against the fetched latest main reported no textual conflict; GitHub still marks the PR behind. The current head has 38 successful checks, one skipped and one neutral check, but the PR description does not claim a real MOI journey.

The total diff is +5,620/-89: approximately +2,781/-87 outside test modules, +2,802/-2 in inline test modules, and +37 documentation lines. In particular, managed_background.rs is 3,799 added lines, about 2,187 before its test module. The lifecycle, credential handoff and legacy custody handling deserve particular simplification scrutiny; tests need to cover the settled-log user journey, not only byte-empty files.

An acknowledged or compacted journal stays nonempty on disk. Replay is the
custody check, so settled history no longer blocks startup.

Co-authored-by: Cursor <[email protected]>

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Request changes on 89ec71e5c83cd72da0e2fc40e1fa684726550d1b for the new custody-reader issues below.

The previous false refusal for an acknowledged WAL and a compacted, valid empty snapshot is addressed, and the new tests cover simultaneous Server owners. The new reader, however, conflates a missing snapshot with a corrupt zero-byte snapshot and fully reads oversized files before enforcing limits. The former can discard an unknown execution fact; the latter adds substantial synchronous memory/I/O to every affected connection.

I ran narrow probes against the extracted production reader with minimal stand-ins for replay/validation, not the full Edge binary. An existing zero-byte snapshot was classified as no custody while the canonical opener's JSON parser rejects it. Reading a sparse 256 MiB + 1 WAL reached 263,928 KiB peak RSS before the limit was applied. The probes do not establish end-to-end behavior on a particular filesystem.

The current CI harness failed before any regression case: the safe artifact reports terminal_protocol, exit 3 for deepseek-v4.1-flash; the Kimi model was registered, and the separate candidate Edge shell contract passed. This does not identify the provider/root cause. The branch is behind current main, though merge-tree showed no textual conflict.

Diff: +5,902/-88, approximately +2,816/-86 outside test modules, +3,047/-2 inline test modules, and +39 documentation lines. The 3,799-line background supervisor and the added custody path still merit simplification against the actual runner lifecycle; a non-default legacy recovery path should not impose unbounded work or fabricate certainty.

… its budget

A zero-byte snapshot is not a missing file, and an oversized journal is
refused from its length before the connection worker reads it.

Co-authored-by: Cursor <[email protected]>

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed fc20704d3fdef5ee26fc09d25a15f18598a369e3; no remaining material code finding was established in this review.

The previous settled-journal false refusal is fixed by replaying custody; an existing zero-byte snapshot is now distinguished from a missing snapshot; snapshot/WAL reads enforce their byte limits before and during the read and execute in the blocking pool. The shared legacy guard still permits independent new Server owners while fencing a live old owner. The added tests target these cases.

I also ran two narrow checks against the extracted production reader with minimal stand-ins for empty-WAL replay/record validation: missing versus valid-empty versus corrupt-empty snapshots, and an oversized sparse WAL. Both passed. This was not a full Edge or live MOI end-to-end run; earlier unchanged WebSocket/owner review evidence and the current source were also considered.

The PR is behind current main, though a local merge-tree found no textual conflict. Current CI is not green: the regression harness stopped before any case at DeepSeek terminal_protocol preflight, exit 3; Kimi registration and the separate Edge shell contract succeeded. The artifact does not reveal the underlying reason, so this approval does not claim CI or the live MOI journey passed. Required checks and the integration result still need to be resolved before merge.

Diff: +6,046/-89, approximately +2,871/-87 outside test modules, +3,135/-2 inline test modules and +40 docs. The size of the background supervisor and retained legacy-custody handling remains a maintenance cost; I found no specific new correctness blocker that justifies another review cycle solely to reduce line count.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Request changes on 40a642197780ba861ad268e65591d13adc2d1e02 for the background runner's reconnect task leak described inline. The runner is intended to remain alive after the terminal closes, so tasks and cancellation-token children must not accumulate across failed or completed connections. This can be solved by using one process-lifetime shutdown bridge or by tying the bridge to the connection's lifetime; it does not require another state machine or SQL.

The recent main merge does not change the reviewed Edge production code. I rechecked the process/connection ownership path, the recent Server-side dispatch integration, and the existing review history. The previously raised journal-custody threads are marked resolved and their fixes remain present. No other new blocking finding was established in this pass.

Validation: I extracted the current shutdown-link function unchanged into a small executable using the same Tokio and tokio-util versions, with a stand-in shared managed token. After 10,000 simulated connection lifetimes ended, 10,000 spawned tasks remained; cancelling the process token left them alive, and cancelling the managed token released them. This isolates the leak but is not a live WebSocket/MOI end-to-end test. git diff --check passed. The latest head has CI checks still running; this review does not claim CI or a live MOI journey passed.

The full diff is +6,046/-89; approximately +2,871/-87 is outside inline test modules, +3,135/-2 is inline tests, and +40 is documentation. The 3,799-line background module and legacy-custody handling remain significant maintenance cost; the concrete issue above is a case where connection-lifetime ownership can be simpler and bounded.

Comment thread crates/astra-edge/src/main.rs Resolved
…nner

Each reconnect left a task waiting on the managed shutdown token. One
bridge now serves every attempt, and the process token stays available
so admitted work can still settle.

Co-authored-by: Cursor <[email protected]>
…anup

Reconnect backoff now cancels through the same shutdown token as an
in-flight connection, and repeated failures share the one bridge the
connection loop already created.

Co-authored-by: Cursor <[email protected]>

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Request changes on 9e6f98eccef56f795c5005b52caa4c02f535544a for the obsolete-journal compatibility path below, in light of the user's explicit clarification that old implementations do not need compatibility. It adds a second custody path and startup failure mode to every current Edge connection, including foreground and container use, for behavior the requested product contract does not require. Keep current-version invocation ownership and outcome truthfulness; make any fresh-cutover limitation explicit rather than pretending old in-flight results can be recovered.

The previous reconnect task leak is fixed in the latest code: a single process-lifetime bridge feeds the connection loop instead of spawning a detached waiter per connection. The production loop is now exercised by a new repeated-failure test. I will resolve the earlier leak thread. An isolated executable with the exact bridge function, the repository's Tokio versions and a stand-in managed token kept one task after 10,000 connection-token lifetimes and verified both managed and process shutdown; that is not a live MOI/end-to-end test.

The full diff is +6,135/-89. managed_background.rs alone adds 3,799 lines (roughly 2,187 production lines before its test module); the journal file adds 943 lines, including extensive legacy-specific tests. That complexity should be assessed by actual user value: the server-specific canonical journal and admitted-work settlement are useful, while a persistent pre-server-format compatibility/custody protocol is not required under the clarified scope. No new SQL or separate durable execution path is needed. git diff --check passes. Latest-head harness and online integration are still running; I did not run a live MOI journey or the full Edge suite in this review.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed 9e6f98eccef56f795c5005b52caa4c02f535544a. The code is unchanged since my last review; the existing old-journal gate finding remains open. The user has explicitly said old-implementation compatibility is not required and again requested simplification. The pre-server journal replay, cross-version locks, error cases and tests are a permanent second custody path and can block an otherwise unrelated new Server, while current-version durable execution and replay must stay intact.

I replied on the existing thread to clarify the cutover: no old compatibility does not authorize retrying an old side effect. Quiesce/settle old work before switching or truthfully retain unresolved old outcomes as unknown without admitting them as new execution, using the existing ownership boundary. Do not claim old in-flight results are recovered, and do not replace the legacy gate with another ongoing state machine.

The prior per-reconnect task leak is fixed by a single process-lifetime shutdown bridge; the earlier thread is resolved. Previous isolated bridge verification and prior process/ownership review are retained only for unchanged code. The full diff remains +6,135/-89, including 3,799 lines in the background module and 943 added journal lines; old-format compatibility is a concrete removable part of that maintenance burden. git diff --check passes. Current-head CI reports no failed checks, with some jobs skipped; I did not run a new live MOI journey or full Edge suite.

@XuPeng-SH

Copy link
Copy Markdown
Collaborator

Please scope this PR to the user journey in #1226. A user starts the Runner, gets the prompt back after authenticated readiness, can close the terminal, and can later check status, read logs or stop it. Reuse the existing connection, admitted-work settlement and server-scoped invocation journal. Keep one owner for process lifetime and readiness. Foreground and container runners should continue through the same execution and result path.

Please remove the pre-server journal reader, cross-version locks and old-format checks from current connections. For a fresh cutover, stop old Runners and settle their outstanding work before admitting work to the new version. If the outcome remains uncertain, report it as unknown and keep that old work from being automatically admitted again. Preserve current-version replay and its tool results so the model can distinguish completion, confirmed non-execution and uncertainty.

Please verify the flow through the actual CLI with terminal closure, a failed startup, reconnect while work is in flight, and stop. This should need no additional lifecycle state machine or database traffic.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed the current head against main. The head is unchanged since my previous request for changes. The existing old-journal gate finding remains open, and the requested product direction has not yet been implemented.

The supported new-version Runner should continue to own admitted work, server-scoped results, reconnect/replay and truthful unknown outcomes. The user has explicitly removed the requirement to support old implementations. Stop and settle old work at cutover, or leave an unresolved outcome unknown and prevent its automatic re-execution. That allows removal of the pre-server journal reader, cross-version locks and permanent startup dependency, rather than introducing another ongoing compatibility state machine. The earlier connection-lifetime task leak is fixed by the process-lifetime bridge; its previously resolved thread remains resolved.

The full diff remains +6,135/-89. The background supervisor adds 3,799 lines including inline tests; the journal adds 943 lines including legacy-specific tests. The existing tests cover many real ownership interleavings, but the legacy gate remains a user-visible startup failure and ongoing cost for a compatibility path outside the agreed scope. Validate terminal closure, startup failure, in-flight reconnect and stop via the actual CLI after simplification.

Current CI has no failed checks; SDK, web and hosted macOS lanes were skipped. git diff --check passed. This pass traced the current call path and retained prior evidence for unchanged code; it did not rerun a live MOI journey or the full Edge suite.

Every connection was locking and replaying the pre-server journal, and an unresolved record blocked an unrelated server. Read that file once, keep a dispatched invocation from running again, and do not present its old output as a recovered result.

Co-authored-by: Cursor <[email protected]>

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Request changes on the current head. The revision changes an old unresolved journal from an unconditional startup refusal into a per-Server conversion to unknown. That retains and expands the old-format compatibility path despite the explicitly requested fresh-cutover scope. More importantly, records copied into a different Server's outbox can never receive its ACK, as described below. The new marker lookup also synchronously reads and decodes the current snapshot on each new connection.

Keep the current Server-scoped journal, authenticated readiness, in-flight settlement and accurate result reporting. At fresh cutover stop old Runners and settle existing work; unresolved historical work must not be silently admitted again. Remove the per-connection old-format reader and cross-version conversion once that boundary is explicit, rather than creating permanent unknown records on unrelated Servers.

The total diff is +6,249/-87. The 3,799-line background module includes inline tests; the journal includes extensive old-format conversion tests. The existing new test explicitly confirms one old record is copied to two Server journals but stops at local replay, so it does not cover Server acceptance, ACK and capacity reclamation.

Validation: traced current journal import, startup replay, the Server's exact dispatch acceptance/ACK and admission capacity. The non-owning-Server scenario is a source-level integration finding, not a newly executed live MOI/WebSocket test. git diff --check passes. Current CI has no failed checks; the edge-fs-tools check is pending and SDK, web and hosted macOS lanes were skipped.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed this unchanged head. Request changes remains appropriate for the open unattributed-record/outbox finding and synchronous duplicate snapshot read.

I compiled the unmodified current production journal implementation in a small isolated test crate with stand-in protocol identity/hash/types. A valid old snapshot containing 1,024 unacknowledged completed records was imported into both Server journals as 1,024 unknown results. With no ACK in the second journal, its next new invocation returned JournalError::Full. This directly verifies import and capacity behavior, not a live WebSocket/MOI or Server-ACK journey. The non-owning Server's missing-dispatch rejection and withheld ACK remain supported by the actual Server code path, not by this isolated test.

The requested scope is a fresh cutover: settle old work first, leave unresolved work truthful and prevent automatic duplicate execution. Retain current Server-scoped result replay while removing permanent old-format processing from the new connection path. The diff is +6,249/-87 and includes large inline test modules; old-format tests do not prove cross-Server ACK and capacity reclamation. CI has no reported failures, one edge-fs-tools check pending, and SDK, web and hosted macOS lanes skipped. I did not run the full Edge suite or live MOI journey in this pass.

Use the canonical server-scoped journal without reading or importing pre-server state. Withdraw readiness before settling disconnected work and route stop through the live runner. Exercise authentication, terminal close, reconnect, and shutdown through the shipped CLI.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The earlier blockers are addressed. The pre-server reader, cross-version locks, conversion marker and outbox import are removed, restoring one current server-scoped journal. The cutover contract stops and settles old work before using the new journal and treats unresolved results as unknown. The duplicate current-snapshot read introduced by the removed conversion is gone.

I traced the current startup/readiness, credential handoff, detach/settlement, stop and journal paths, including CLI callers. The new actual-binary PTY/WebSocket tests cover authenticated start, terminal closure, disconnect with admitted work, result replay/ACK, stop and rejected startup; both passed in the current CI core job. The two-server journal isolation test also passed. The change removes more than 1,000 lines from the previous revision, including the legacy path and its tests. The remaining full diff is +5,492/-67; the background module includes substantial inline tests and still carries maintenance cost, but I found no new blocking defect against main.

The current regression/harness job is red: 17/19 passed. flash_model_name_is_output failed the child-adoption count assertion and recovered_validation_user_facing_completion observed two failed Bash calls where the hard criterion allows one. Both returned exit 0; the available safe artifact does not establish their root cause or a connection to this Runner change. I am not calling them provider timeouts or claiming the harness passed. SDK, web and hosted macOS lanes were skipped. The product journey tests use a local WebSocket peer, not a live MOI deployment. Approval covers the code review, with those verification limits visible.

@mergify mergify Bot added the queued label Nov 21, 2026
@mergify

mergify Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as d33c809 at 15:44 UTC

Less than a minute in the queue, with no time running CI.

So far

  • ✅ Entered the queue Sat 21 Nov, 15:44 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged 15:44 · d33c809 · squash
17 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = Check PR title
    • check-neutral = Check PR title
    • check-skipped = Check PR title
  • any of · required by GitHub branch protection:
    • check-success = check
    • check-neutral = check
    • check-skipped = check
  • any of · required by GitHub branch protection:
    • check-success = Test: core crates + bridge hooks
    • check-neutral = Test: core crates + bridge hooks
    • check-skipped = Test: core crates + bridge hooks
  • any of · required by GitHub branch protection:
    • check-success = Test: astra-runtime
    • check-neutral = Test: astra-runtime
    • check-skipped = Test: astra-runtime
  • any of · required by GitHub branch protection:
    • check-success = Test: astra-cli (edge-fs-tools)
    • check-neutral = Test: astra-cli (edge-fs-tools)
    • check-skipped = Test: astra-cli (edge-fs-tools)
  • any of · required by GitHub branch protection:
    • check-success = Test: astra-cli (edge-git-gix)
    • check-neutral = Test: astra-cli (edge-git-gix)
    • check-skipped = Test: astra-cli (edge-git-gix)
  • any of · required by GitHub branch protection:
    • check-success = Test: astra-cli (edge-rest)
    • check-neutral = Test: astra-cli (edge-rest)
    • check-skipped = Test: astra-cli (edge-rest)
  • any of · required by GitHub branch protection:
    • check-success = Test: astra-cli (edge-shell)
    • check-neutral = Test: astra-cli (edge-shell)
    • check-skipped = Test: astra-cli (edge-shell)
  • any of · required by GitHub branch protection:
    • check-success = Test: astra-cli (non-edge)
    • check-neutral = Test: astra-cli (non-edge)
    • check-skipped = Test: astra-cli (non-edge)
  • any of · required by GitHub branch protection:
    • check-success = Test: online (core)
    • check-neutral = Test: online (core)
    • check-skipped = Test: online (core)
  • any of · required by GitHub branch protection:
    • check-success = Test: online (integration)
    • check-neutral = Test: online (integration)
    • check-skipped = Test: online (integration)
  • any of · required by GitHub branch protection:
    • check-success = Test: turn-core + services + plan
    • check-neutral = Test: turn-core + services + plan
    • check-skipped = Test: turn-core + services + plan
  • any of · required by GitHub branch protection:
    • check-skipped = web (typecheck, test, build)
    • check-neutral = web (typecheck, test, build)
    • check-success = web (typecheck, test, build)
  • any of · required by GitHub branch protection:
    • check-skipped = Astra SDK (typecheck, test+coverage, build)
    • check-neutral = Astra SDK (typecheck, test+coverage, build)
    • check-success = Astra SDK (typecheck, test+coverage, build)
  • any of · required by GitHub branch protection:
    • check-success = Test: macOS workspace coordination
    • check-neutral = Test: macOS workspace coordination
    • check-skipped = Test: macOS workspace coordination

Times in UTC · dashboard · how the merge queue works

@mergify
mergify Bot merged commit d33c809 into matrixorigin:main Nov 21, 2026
40 of 41 checks passed
@mergify mergify Bot removed the queued label Nov 21, 2026
mergify Bot pushed a commit that referenced this pull request Dec 1, 2026
…ffs (#1431)

Capability assessment: Unchanged: existing User Runner capabilities, identity and wire protocol are preserved.

## Summary

Fix three issues in the managed User Runner lifecycle.

- Include the absolute, shell-quoted Astra state directory in every printed management command. An operator can copy the command into a fresh terminal after installing with a custom state directory.
- Send the startup credential over a private Unix socket attached to the child process input. The detached process receives the explicit credential without retaining it in its command line or inheriting ASTRA_TOKEN.
- Discard outstanding credential handoffs under the runner startup lock when stopping. A later process can safely receive its own handoff. The proven credential used for reconnects keeps its existing lifecycle.

## Related issue

Follow-up to #1226 and #1227.

## Change type

- [x] Bug fix
- [x] Test
- [x] Documentation

## User and compatibility impact

Operators can keep using their existing MOI connect command. The printed status, logs and stop commands select the original state directory, including when the user opens another terminal. The original interactive invocation still accepts the token on its command line.

## Architecture and complexity delta

The managed Edge supervisor owns the initial parent-to-child transfer, the credential handoff files and the printed management commands. The credential reaches the existing token manager through the same explicit-token input. The Server, release installer and database schema require no changes.

## Verification

- On macOS ARM64, `cargo nextest run --locked -p astra-edge --profile ci` passed all 159 tests. The PTY test executes the printed commands in a clean shell, checks the WebSocket credential, and exercises reconnection and shutdown. Regression assertions cover split and inline token flags, pending and claimed handoff files, and refusal of a late handoff while stopping.
- `make format-check`, `python3 scripts/ci/validate_repository.py`, `make audit` and `git diff --check` passed.
- Workspace Clippy (`make lint`) and the complete native macOS lane (`bash scripts/ci/run-macos-lanes.sh all`) passed.
- Local test traffic used loopback and synthetic credentials. Linux CI and Docker-dependent fresh-Server integration remain for GitHub Actions. The local Docker daemon did not respond.

## Final checklist

- [x] Tests exercise the managed runner entrypoint and failure paths.
- [x] Updated the production User Runner guide.
- [x] Reviewed the diff for sensitive material and generated files.
- [x] Conventional Commit title.


Approved-by: XuPeng-SH <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add managed background execution for local User Runners

2 participants