Repository navigation
feat(edge): run MOI user runners in the background - #1227
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
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.
|
Addressed the four review findings in c75c3d9.
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
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.
|
Addressed the two new findings in ca7b7a9.
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
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-edgebinary 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
stopall 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 --checkpassed; 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.
|
Addressed all three findings in 36c4b72. The handoff now goes through the existing owners only (
Also:
Validation: |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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.
|
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.
Found in self-review and fixed in the same commit:
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 Known residuals: a small window between Validation: |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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.
48023bc to
3e24aca
Compare
|
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
Found while checking the same ordering, and fixed in the same commit:
Validation: |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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.
3e24aca to
e313995
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
|
Queue requested — the merge queue status continues in this comment ↓. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
be701b0 to
35c2800
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
…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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
|
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
✅ Merged into
|
…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]>
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 trueand leave the terminal open. A new binary now detaches only that interactive command, waits until the existing authenticated-ready signal, and returns the prompt withstatus,logs, andstop. 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-edgewith credentials in the environment and do not use this argv. The parent does not hold the MOI installation lease. The child callssetsid, ignoresSIGHUP, and holds the lease until it exits.Related issue
Closes #1226
Change type
User and compatibility impact
The generated MOI connect command is unchanged. A new
astra-edgebackgrounds it only from a terminal when the argv contains an explicitrunner-edge id, server URL, non-empty token, and--reconnect true.ASTRA_EDGE_FOREGROUND=1keeps 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, andlogsaccept--edge-idand--server-url. A second launch does not start another worker; only aconnectedphase 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
crates/astra-edgeowns 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.main, the post-auth ready signal, the installation lease, sandbox environment startup, and the MOI connect command bytes.Verification
cargo test --locked -p astra-edgepassed 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, andgit diff --checkpassed.Final checklist
explained why no test is needed.
change needs no documentation update.
generated files, and other sensitive information.