Skip to content

feat(lifecycle): share one verdict for runtime status and admission - #96

Merged
alphastorm merged 36 commits into
mainfrom
feat/lifecycle-verdict-core
Nov 14, 2026
Merged

alphastorm merged 36 commits into
mainfrom
feat/lifecycle-verdict-core

Conversation

@alphastorm

@alphastorm alphastorm commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

One verdict for runtime admission

Status and admission share one read-only verdict over runtime records, the accounted process census, retained launch/job custody and the configured port. This piece is not dormant: its consumers change as soon as it lands.

Qualification

Head 94fc9f1760fce482950c88d8a2d18b5b74b96492 has 36 signed commits over afc2d420; eight paths, source +363/-52, tests +1,846/-18. At this head, 48 focused tests pass in 11.398s; nineteen source-injection inputs yield seventeen kills, two deliberately out-of-scope survivors and zero test errors. The whole-suite result is carried from 276135ec03a869549eed7a524d98a2272a04eac1: 1,341 tests in 492.690s, ten skips and four expected failures, no unexpected failures or errors. The complete delta from that commit is confined to tests/unit/test_lifecycle_states.py, +40/-19; no production file changes, and no whole-suite run at the new head is claimed. All repository checks passed at the new head, including hygiene, compatibility, documented-route/document-reader checks, profile/route and manifest validation, and the release/profile/route diff check.

Consumers: the behavior change on landing

The individual reader on main returns no match when either creation text or executable differs. In particular, a changed calendar rendering together with a changed executable can disappear from its result even though neither change proves that the old process exited. This piece instead consumes the table's closed comparison: only different stamps of one counter clock prove another process; every other disagreement is cannot-say. Records and tables are comparable only on the same host and in the same PID namespace and time namespace; the code does not check that precondition.

Line references below are on pre-verdict main at afc2d420; lifecycle callers used running() at 1284-1291. “Not this recorded identity” is not permission to admit: another identified process under the runtime, other recorded roles, custody, records or ports can still block.

Caller and lines on main What no-match concluded before Another process (counter-clock proof) now Not enumerated now Cannot-say now
start, lifecycle.py:1781-1868 Dropped the role from running() and could pass the root-process gate; launch, installation, key, port and GPU gates still applied. Not this recorded identity; requires the whole verdict to be idle. Recorded PID absent from the accounted census; requires the whole verdict to be idle. Refuses before installation/readiness work, naming role/PID, the unproved absence/reuse and manual recovery.
idle_generation, lifecycle.py:1294-1308 — controller and optionally fenced start/install/keygen No individually matching wrapper/server/engine could satisfy the process condition if stopped/token/proof/scan conditions also passed; absent run returned a generation without census or port checks. Not this recorded identity; requires quiescence and the retained stronger stopped/token/proof/job-scan checks. Recorded PID absent; the same quiescence and stronger custody checks apply. Refuses with the role/PID and manual recovery before an expected-generation mismatch; cannot return a passing candidate generation.
status, lifecycle.py:1978-2022 Could report stopped/failed after dropping the role; an absent install returned not-installed before checking run evidence, and profile checks could precede process checks. Renders the verdict over all remaining evidence; only a fully proved idle root may be reported idle. Renders the verdict over all remaining evidence, not a three-role no-match shortcut. Active identities give degraded/unreadable-table with role/PID and manual recovery. An inactive launcher cannot degrade an identified serving server: authenticated checks and ensure_healthy still run.
cli.cmd_install, cli.py:100-110 Unfenced installation had no lifecycle identity gate; fenced installation used the older candidate check above. Requires the verdict to be quiescent before installation. Requires the same quiescent verdict. Refuses installation with the verdict's role/PID and manual recovery; the existing read-only NVFP4 staging preflight is unchanged.
stop, lifecycle.py:2048,2070-2094 — comparison unchanged Skips nonmatching recorded targets, can satisfy the recorded-survivor portion of missing-job proof, and can publish stopped when no other refusal remains. Not consumed by the stop algorithm. Not consumed by the stop algorithm. Stop still lacks this closed outcome; this change does not migrate termination or its final completion proof.

Every active-role cannot-say refusal says that absence or PID reuse cannot be proven, names each role and PID, and directs the operator to inspect those PIDs and reconcile custody; only a confirmed-stale run record may then be cleared by hand, at the named record path, before retrying status. The controller keeps its closed public reason prior_candidate_generation_unproved, and writes this detail to the existing private <root>/evidence/experiments/<time_ns>.err convention under root/output directory fences. There is no stale-record acknowledgement/reset command or documented PID-checked clearing procedure to name, and this piece adds no override.

VerdictConsumerInventory pins the four direct consumers and inventories individual-reader and census-entry references across the package and scripts by owner, count and retention reason. Reader-module star imports are rejected outright. The two permitted census entries are exactly one procs.table() reference in lifecycle.process_table and one process_table() reference in lifecycle.verdict; neither permits a separate admission decision. Ten negative controls cover an independent fifth decision, imported/module aliases, the retired running name, a reader-module escape, a star-imported reader, and both census entry spellings. This inventory is syntactic; reflection, an edited allowlist and a differently expressed semantic duplicate are outside it. Advice and stop share _stop_custody_refusal; stop keeps its target selection, native termination and completion proof, and no new stop loop is introduced. One thing stop itself does differently: it raises that structural refusal before any write, so on a host that is not Windows a record with a job token is refused with the Windows-host reason before the record is rewritten, where main first rewrote it to stop_incomplete and then failed in the job lookup, or, for a verified-stopped record, refused with another message without writing.

Three invariants

  1. Under the reader's unchecked host/namespace precondition and declared ownership boundary, idle requires readable or absent entries in which no process-role key is repeated, usable active roles, an available accounted census with no owned process or unresolved active identity, settled custody, a successfully probed free port and no conflicting installed profile; missing proof refuses with its named cause, and quiescence relaxes profile equality only.
  2. Active-role cannot-say yields unreadable-table rather than idle/quiescent and retains identified cleanup candidates; launcher evidence is active while launching or before otherwise proving quiescence, never a reason to degrade an identified non-launching server.
  3. Recovery advice preserves the structural stop gate and names manual cleanup outside legacy stop's selection, while the controller keeps its closed public reason and retains detailed refusal evidence privately.

What evidence means

Input Incomplete/unreadable or unproved condition Decision and operator message
Run/install record entry Missing directory entry alone is absence. Dangling links, nonregular entries, read/decoding/JSON failures and non-object JSON are unreadable; nonregular streams are never opened. A duplicated process-role key makes the whole record unreadable. A repeated field inside one recorded identity is not detected: its last value is read, so a hand-edited or damaged record of that form can hide a recorded process, as it could before this change (#98). Never idle/quiescent; names the run or install record and requires manual reconciliation. Readable links to regular JSON files remain readable records.
Recorded roles An active present identity needs a positive integer PID (not bool), nonempty string creation stamp and executable. Missing/mistyped fields, empty objects, invalid collection members and foreign nulls are unreadable active roles. Names the unreadable run record; unreadable_roles lists malformed active roles. Unique engine: null, omitted roles and server_tree: [] retain released meanings. An inactive launcher's shape is not consulted; duplicated role keys still invalidate the entire record.
Process census and comparison The reader accounts for enumerated PIDs and readable self or reports unavailable. Wrapper/server/engine/server-tree cannot-say always blocks; launcher cannot-say blocks while launching or when no owned process already prevents quiescence. Causes include unidentified PIDs, changed executable with equal stamp, calendar/mixed/unrecognised disagreement and lossy recorded text. Only counter-clock difference proves reuse. Degraded/unreadable-table names the unavailable census or active role/PID, missing absence/reuse proof and manual recovery. Unrelated unidentified PIDs do not attribute ownership to every root. Available identified candidates remain in live; unavailable census invents none.
Launch/job custody Unpublished children, an outstanding launch, or a retained job without stopped state and matching empty-tree token prevent quiescence. Missing launcher identity differs from gone and cannot-say. Names unpublished lifetime, pending/unrecorded launch or unproved generation; retains structural custody refusals. Candidate admission additionally performs the existing fresh job scan, including after a matching expected-generation fence.
Configured port A connection or failed bind establishes occupancy. OS failure to perform the probe is unreadable port evidence. Once occupied, missing listener PIDs or listener-query OS/subprocess/decoding/parsing errors never mean free. Port-held refusal names the configured port or unavailable PID; inspect the listener, end its holder or change the port before admission. Listener identity never grants termination authority.

Records state which roles a run recorded, not which processes exist. A never-recorded process is found, if at all, by the runtime-root census. Only engine has a deliberately nullable identity producer; wrapper/server producers require an identity, launcher is omitted rather than written null, and server-tree is a list.

Writer change and launcher relevance

start calls procs.info(os.getpid()) while holding the root publication lock and, if it gets an identity, writes launcher.as_dict() into the launching run record before detached dispatch; otherwise the key is omitted. The identity is retained after handover. Launcher relevance is determined when reading the record: shape/comparison matters only during launching or when no positively owned process already precludes quiescence. This supports retained records without changing the handover writer or requiring a publication migration. A non-launching identified server reaches authenticated checks regardless of launcher outcome. A stopped otherwise-empty root with an uncertain retained launcher still refuses: launch evidence is not discarded to prove quiescence.

Recovery advice sweep

  • Manual process recovery: unrecorded runtime PIDs; descendants rooted only at a recorded engine or server-tree member, which legacy stop does not traverse; either POSIX deleted-image spelling and its descendants, conservatively, because table comparison normalizes the marker and legacy stop does not. These name manual inspection/ending and subsequent status; authenticated status's stray advice uses the same helper.
  • Other refusals: unreadable entries require manual record reconciliation; unavailable census requires retry; cannot-say requires PID inspection/custody reconciliation before clearing a confirmed-stale record; unpublished lifetime retains custody; foreign-platform job records require their Windows host; unproved jobs use structurally admitted stop; occupied ports require inspecting/ending the holder or changing the port; quiescent profile mismatch permits reinstall/switch-back.
  • Combined launch/survivor case: structural custody refusal has priority; otherwise stop fences delayed wrapper publication, then the operator inspects/ends listed PIDs and runs status. Without survivors launch advice remains plain stop-to-fence; outside launching, survivor advice is manual-only. All three launching rows use one helper's exact advice in both message and refusal, including the pending row.
  • The deleted-image advice is deliberately conservative even when both sides carry the marker and legacy comparison could succeed; it adds no second identity comparison. Ordinary recorded roots retain effective stop advice. This piece does not promise successful native cleanup or add the final census/stop loop.

Ownership and limits

  • Recorded comparisons use only ProcessTable.observe. The verdict does not compare table identities itself or use individual matches as proof of absence.
  • A stopped root with a reused recorded PID on a calendar-stamp host is newly refused where main dropped the identity, until the unrelated process exits or the operator clears the confirmed-stale record by hand; ordinary stop followed by reuse is a common route here. Ordinary POSIX ps, including Linux, uses calendar stamps; procfs ticks are the fallback when ps is absent, and native Windows uses FILETIME. Active calendar disagreement never proves reuse. #95 tracks an operator acknowledgement mechanism; none or documented PID-checked clearing procedure is added here.
  • An empty root now needs an available census and a free configured port before idle status/install/candidate admission; main could admit without those observations. Their failures name the missing evidence.
  • scripts/realhost_gates.py remains on the old comparison, outside this piece's paths. Its server_tree at 214-217 returns an empty tree for no-match; G20's leftovers at 1532 drops such recorded identities from orphans_after_stop, and not leftovers contributes to pass_observed at 1560. Other G20 conditions still apply; no-match alone is not a passing gate. This cleanup-evidence limit is tracked in #94.
  • Ownership is an identified recorded root process, its descendants along reader-retained edges, or an identified executable whose normalized absolute path or resolution lies under the runtime. Unknown parents stop traversal; no second age check is added. A launcher is launch custody, not independently a root-owned process.
  • Relative paths, lossy executable text and unidentified rows supply no path/ancestry authority. Outside-runtime interpreters without recorded ancestry, and unidentified unrecorded processes, remain outside this ownership boundary. A port holder is refused, never adopted.
  • Comparison assumes records and tables came from the same host, PID namespace and time namespace; no code verifies this. Ordinary ps identity resolution is one second; equal PID/start-tick/executable values can repeat after reboot. The procfs second start-time read rejects reuse that changes the reported start tick, not reuse within one tick; failed confirmation is unidentified. The ps/procfs path still reads stamp/parent and executable at two instants.
  • The ps check validates only the shape of five creation tokens, not their calendar meaning or provenance; a layout failing that shape leaves its PID unidentified, and unreadable self makes the table unavailable. The Windows one-second pre-capture margin can discard true young edges; backward clock adjustments and native Windows behavior are unqualified. Calendar clocks are not ordered.
  • Evidence is not one atomic transaction across files, census, commands and native operations. The finite models do not claim arbitrary nested-metadata validation or protection against hostile concurrent filesystem mutation.
  • Structural custody first; then admitted launch fencing plus manual cleanup; otherwise manual-only for unrecorded survivors. Combined advice says “do not rely on it to end the listed processes”: a listed PID may already be gone after stop, including a selected deleted-image candidate or a fenced wrapper that exits itself. A waiting wrapper is counted only if its identified executable falls inside the runtime or recorded ancestry supplies ownership; tool_argv uses the current interpreter, which may be outside that boundary. No wrapper-specific exclusion is added.
  • Native termination, job-helper exception normalization and final stop resampling/proof remain unchanged. Existing healthy-status key-file permission/encoding behavior is outside verdict admission. Controller diagnostics use existing protected output directories; filesystem/fence failures propagate rather than permitting admission or silently dropping evidence.

Finite models

Model Finite domain
State/consumer product 3,956 combinations of written run states/flags, matching/absent/different/stale installs, recorded-process liveness, extra runtime/descendant/reused-PID cases, readable/unavailable census and port state; all thirteen rows reached.
Evidence product 16,128 combinations: six run forms, seven install/profile forms, three job-proof states, two platform flags, present/missing job, survivor/port flags and eight three-observation availability schedules; later observations are reserved dimensions for the stop projection, not extra reads by one verdict.
Custody/advice and closed rows 192 custody/advice cases; 52 row/platform/job-presence cases, reaching every row on both platform flags.
Reader outcome composition 280 = five recorded roles × seven states × four reader outcomes × two install-profile relations. Positive-reuse fixtures supply different stamps from one counter clock.
Role schema 1,820 = five roles × seven states × two platform flags × thirteen forms × survivor present/absent; plus ten engine-null equivalences, seven server-tree collection shapes and three launcher-evidence reasons.
Cannot-say consumers 630 = five roles × seven states × two platform flags × nine causes; all preserve an identified cleanup candidate and exercise all consumers. The 522 active-identity cells require PID-specific cannot-say text; 108 inactive-launcher cells instead refuse for the independently identified orphan with manual recovery. The role-schema product likewise explicitly ignores inactive launcher shapes rather than silently narrowing its domain.
Host-clock admission 30 = Windows FILETIME / procfs start ticks / calendar stamps × five roles × unchanged/changed executable. Counter-clock reuse can pass all otherwise-satisfied gates; calendar cases degrade/refuse in status, start, install and both candidate calls, never pass. A separate single-case regression pins the PID and manual-recovery message independently of this clock product.
Other boundaries Fourteen record-entry cases where FIFOs are supported (twelve otherwise), eighteen reader-vouched-edge cases, seven unreadable-input cases across consumers, eight unchanged-native-comparison fixture cases, eight fake-caller/census coherence cases, and the direct-consumer inventory.
Execution boundaries 36 launcher state/ownership/outcome cells, six authenticated serving/client cases and a retained-stopped-launcher case; ten legacy-stop/advice transitions; six actual adapter private-diagnostic cases; 32 independently expected stop-gate actions and six otherwise-quiescent candidate scan outcomes with/without generation fence; ten inventory negative controls.
Combined launch recovery 24 exact-advice cells (three rows × survivors present/absent × token present/absent × platform); three actual stop/late-wrapper-guard/orphan/empty walks; three manual-first walks that remain launching; three unpublished-without-token precedence cases; two wrapper-executable boundary cases; one mixed deleted-image/unrecorded transition.

Products overlap; their sizes are not distinct native situations. All new boundaries are host-free. The fake native seam calls the unchanged individual comparison with only info substituted; it is not another table comparator. These models do not qualify native cleanup or termination completion.

@alphastorm
alphastorm merged commit 4dc4674 into main Nov 14, 2026
11 checks passed
@alphastorm
alphastorm deleted the feat/lifecycle-verdict-core branch November 14, 2026 20:07
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.

1 participant