Repository navigation
fix(agent): isolate Goal recovery failures and stabilize model admission - #6616
Conversation
Read pre-provenance accepted request controls without rewriting durable receipts. Keep individual Goal record failures from stopping healthy goals, and capture current admission settings after shared inventory discovery. Generated-by: Codex
Keep the strict current AcceptedModel representation and request preparation path. Provide an offline migration Gist in PR #6616 for existing durable authorities and their linked submit receipt digests. Retain per-Goal failure isolation and current-settings admission after shared discovery. Generated-by: Codex
Astro-Han
left a comment
There was a problem hiding this comment.
Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.
I reviewed all seven changed files at e63817a6f558a4df3f2cb774d7c8cd2decff9682, the Goal dispatch loop, selected-model observation and stored submit-receipt checks. I also reviewed the linked migration at Gist revision 004250a6cd1da9f4e93c24cf3f91694a9d556e2a. I found no confirmed P0–P2 issue in the reviewed changes.
The recovery premise is supported by the historical code: before #6580, AcceptedModel stored context, provider_configuration and basis; the current reader uses the route / model_override / body_overlay representation and rejects the old fields. The parent Repository::sessions decoded every authority before filtering Goal status and returned on the first decoding error. In plugins/agent/goal/src/goal.rs:470–512, this change first inspects scheduling state while ignoring the grant payload, then returns individual record errors. plugins/agent/native/src/owner/goal/dispatch.rs:101–130 continues through healthy records before reporting errors through the existing diagnostic loop. Storage failures still propagate. A malformed active record conservatively keeps monitoring awake; it is isolated, not automatically repaired.
In plugins/agent/native/src/model.rs:132–216, new admission re-observes the selected identity and rebuilds its provider definition after shared discovery. The production configuration read checks both connection and model enablement in one SQL snapshot, including credentials and request settings. Existing accepted work still uses the separate restore/observe path and retained controls. The README capacity wording now matches that existing per-logical-request behavior.
I ran the Gist's four unmodified SQLite tests on Linux/Python, all passing. Three additional checks also passed: a removed connection is not recreated and its original execution policy/language survives; an incomplete old snapshot aborts before any backup or write; and the backup includes committed WAL data while leaving unrelated content intact. These used temporary fixture databases only. The migration targets explicit authority locations and updates submit execution digests, preserving content digests and revisions. It deliberately seeds overrides from current saved settings and discards old resolved capacities/options; it does not promise identical historical request parameters. Users with affected records still need the documented offline migration after stopping Maka and its background Host.
Exact-head hosted Goal isolation/continuation/restart coverage passed in 14.234 seconds, and admission during a held discovery passed in 0.780 seconds. I read both raw logs. Overall CI failed: the only failing concrete job was Windows preparation, at the unchanged scripts/ci/run.mjs:65 ProgramFiles path construction already failing on the target branch. A static merge into current rust-preview 8fd3a365 succeeded.
I did not run Rust, the strict Rust reader against migrated snapshots, live provider requests, a real user's database recovery or the Windows lease branch locally. The author's native migration-output verification remains author-provided evidence. This PR does not implement an automatic legacy-format migration or repair other unrelated Goal/client-state migration issues.
Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.
Reuse the original pending admission rather than regenerate its identity after authority normalization. Cover queue-driven execution and original fingerprint retention. Read Windows CI bootstrap paths from the native case-insensitive environment. Generated-by: Codex
Astro-Han
left a comment
There was a problem hiding this comment.
Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.
This updates my earlier review for the final f2560e691c28ac1b92b880f8dc0104d552276b03 increment and corrects its migration coverage statement.
Correction: the earlier Gist revision and its fixture used native_basis, but production ActivationCheckpoint is serialized with nativeBasis (plugins/agent/facts/src/native_approval.rs:40–50). I missed that mismatch. The old script therefore did not migrate actual saved activation checkpoints. Gist revision 96f5f437509ef3f8e7dec371e31bb27a71aef158 corrects that field and also migrates maka.bot worker-watch return routes. I checked the latter against the production Watch/ReturnRoute records.
I ran the old planner against the corrected production-shaped fixtures: it planned zero checkpoint updates and zero Bot-watch updates. The revised script migrated both, preserving checkpoint invocation/suspension and the watch's prior notification identity. Its four unmodified SQLite tests passed locally, including preview, receipt consistency, lease exclusion and rollback. These remain temporary fixture tests, not a Rust-reader or real-user recovery run.
The three-file code increment also fixes scheduler reconciliation in plugins/agent/native/src/owner/scheduler/dispatch.rs:352–377: when the original admission is still pending, it reuses that stored admission instead of regenerating an execution fingerprint from normalized fire metadata. This matches the existing admission identity checks and leaves the unaccepted-work authorization checks in place. On current merged 561fe244, whose scheduler file is identical to this final head, the new pending-admission normalization case passed in 6.900 seconds, retaining the original run and fingerprint without a user message driving execution.
The Windows bootstrap change reads the native environment rather than its copied plain object. The subsequent #6619 further handles uppercase environment maps. Current merged CI succeeded, including all five actual Windows shell tests; the earlier target's Windows preparation failure is no longer a current-branch blocker.
I found no confirmed remaining P0–P2 issue in this increment or the revised migration. Affected old records still need the documented offline migration; it adopts current model-preparation semantics rather than guaranteeing identical historical capacities/options. I did not run Rust, the Windows migration lease branch, live providers or a real user's database locally. The earlier review must not be read as validation of the old Gist's checkpoint coverage.
Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.
Summary
Refs #6580 and #6615.
A completed Goal written before #6580 could stop every active Goal from continuing: the scheduler decoded every saved execution authority before checking whether the Goal needed work, and the current model reader rejects the previous stored format. This reproduced the reported Goal staying active after its turn finished until another user message arrived.
One-time migration for existing data
Migration script, instructions and executable tests — Python 3 standard library only.
The first run only previews changes. Quit Maka and stop its background Host, then apply:
python3 migrate_6580.py --host-root "$HOME/.maka/application/host" --applyUse the actual Host root if yours differs. Windows commands and backup restoration instructions are in the Gist.
The script migrates Goal state and original arming receipts, scheduler authorizations, Workhub return routes/notifications, Bot worker-watch return routes, pending message admissions and native activation checkpoints across the runtime root and partitions. It also updates matching message-submit execution digests. It acquires the existing Host writer lease, backs up affected databases beside the Host root, uses SQLite transactions, restores earlier commits if a later database fails, and is safe to run again. It does not rewrite user messages, historical events or content-addressed artifacts.
Migration semantics: the original identity, thinking/tool policy, route and body overlay are retained. Old records did not save user overrides separately, so the script seeds them from the connection's currently saved model override and pins the original adapter. Resolved capacities/options then follow the current format's model-preparation rules. This deliberately adopts current semantics rather than preserving a second historical execution behavior. Credentials, connection settings, operation identities, content digests and stored revisions are not changed. Keep the generated backups until normal use has resumed successfully.
Verification
PRAGMA integrity_checkreturnedok. The user's actual databases were not modified.cargo fmt --all --check,git diff --check, and affected-crate Clippy with-D warningspassed.AI use
Tool(s) and scope: Codex investigated the incident, implemented the runtime fixes and standalone migration, updated documentation and ran the checks.
Checklist
Does this PR entail a change in behavior?