fix(pi): retain ownership for uncertain mutations

This commit is contained in:
2026-08-25 23:53:54 +08:00
parent 621ebb1781
commit 019cbb115a
21 changed files with 1113 additions and 67 deletions

View File

@@ -8,10 +8,23 @@
- Worktree: D:\Datas\OthersProjects\makelore-pi-background-run-lease-6a4e2c91
- Base commit: 92f4c91088e79252aca76af3279b184da68e1eb7
- Owner: codex-root
- Status: Ready for integration
- Status: Implementing follow-up
## Scope
- Follow up the installed `621ebb1` Windows artifact: treat an RPC
confirmation timeout for an already-written Pi top-level mutation as
uncertain ownership rather than a definite terminal failure. Keep the
target run permit, process ownership, and Main background lease until a
correlated late result/event, worker failure, abort, recover, or other
authoritative cleanup converges it.
- Prevent prompt, follow-up, steer, compact, model reconfiguration, and fork
mutations from overlapping an unresolved uncertain mutation in the same
Conversation, while preserving sibling Conversation independence.
- Give manual compact a long-mutation lifecycle through compaction completion
and authoritative settle, and keep `CODING_REQUEST_UNCERTAIN` distinct from
local-runtime-unavailable UI semantics.
- Add a Main-owned authoritative background lease for every queued or accepted
top-level Pi Conversation run, acquired before mutation queueing and held
through parent/child work until authoritative terminal cleanup.
@@ -71,6 +84,18 @@
## Plan
Follow-up plan from cumulative HEAD `621ebb17810394f6f7b97154cb01217bc9112857`:
1. Add deterministic red tests for delayed Pi prompt preflight confirmation,
delayed compact confirmation, late failure/exit/abort convergence,
same-Conversation mutation exclusion, sibling isolation, and Renderer
uncertainty unlock.
2. Make RPC confirmation timeout preserve authoritative uncertain ownership
without replay, then converge exactly once from late response/events or
explicit cleanup.
3. Extend final-ASAR packaged proof beyond the old ten-second threshold and
re-run the full Windows release gate from a clean follow-up commit.
1. Trace actual background lifecycle, Pi mutation/dispose, composition, and
stop-reason callers; build a deterministic combined red test for the exact
hidden-active-run failure and the in-flight sleep race.
@@ -90,6 +115,34 @@
## Outcome
### Installed-package P1 follow-up
- Pi RPC mutation confirmation now has an explicit retained-correlation mode.
Crossing the former 10-second Host confirmation threshold returns the safe
recoverable `CODING_REQUEST_UNCERTAIN` contract but does not retire the RPC
id or release the pool's active run, revision run, process permit, or Main
background lease.
- A late correlated success clears the provisional run error without ending
the run; a late explicit RPC failure terminalizes only the target; worker
invalidation, abort/recover cleanup, or authoritative `agent_settled`
converge the same ownership exactly once. `agent_settled` also confirms a
mutation when it arrives before the RPC success response, avoiding a hung
Host acceptance promise or terminal-state regression.
- Prompt, queued follow-up/steer, compact, model reconfiguration, and fork are
blocked for the same Conversation while uncertainty is unresolved. The
service performs model/fork rejection before metadata persistence or fork
target creation; sibling Conversations retain independent permits.
- Manual compact uses the same retained ownership through
`compaction_start`, `compaction_end`, authoritative settlement, and hydrate.
The final-ASAR proof now arms a controlled 12-second compact response and
records its running/uncertain and completed/idle states.
- Renderer submission errors retain their stable backend code. An uncertain
submission keeps the draft and prevents overlap, shows the actionable delay
message instead of a runtime-outage banner, and automatically removes the
transient message when the authoritative run reaches a terminal state.
Model, thinking, compact, and fork controls are disabled while the run is
active; abort and recover remain available.
- Implemented a Main-owned per-Conversation top-level run lease in the Pi
runtime. Prompt and compact acquire before optimistic/queue acceptance;
steer/follow-up reuse the parent run lease. Settle, definite rejection,
@@ -121,6 +174,30 @@
## Verification
### Installed-package P1 follow-up candidate
- Red phase — 5 expected failures across RPC correlation, pool ownership,
Main background lease, compact overlap, and Renderer reconciliation: the
old implementation retired the correlation and released active ownership at
10 seconds, returned a raw timeout, and retained the UI uncertainty after a
completed run.
- Focused green gate — passed: 8 files / 115 tests, including delayed prompt
and compact, late success/failure, settled-before-response, same-target
mutation exclusion with zero fork/model persistence, sibling isolation,
safe Host error mapping, Renderer automatic unlock, and final-ASAR wiring.
- `pnpm run typecheck` — passed after the final runtime/Renderer/proof changes.
- `pnpm run lint:check` — passed with zero errors and the same 5 pre-existing
warnings in `src/pages/Home/index.tsx` and `src/pages/Makelore/index.tsx`.
- `pnpm test` — passed: 181 regular files / 1535 tests passed / 2 skipped,
followed by the isolated pressure file / 1 test passed.
- `pnpm run build:vite` — passed for Renderer, Main, Preload, and utility
bundles; only existing dynamic-import and chunk-size warnings were emitted.
- `pnpm run test:electron:windows` — passed: 2 files / 4 tests.
- Final amended-HEAD NSIS, artifact closure, 12-second packaged UI/Main proof,
Authenticode, and zero-residual-process results are completed after the task
documentation/registry commit so the returned artifact binds to a clean
cumulative HEAD.
- `pnpm install --frozen-lockfile` — passed with package-manager-pinned pnpm
`10.33.4` and locked Pi `0.84.2`.
- Red phase: the new background lifecycle in-flight test observed one unwanted