Skip to content

fix(agent): isolate Goal recovery failures and stabilize model admission - #6616

Merged
M4n5ter merged 3 commits into
rust-previewfrom
fix/codex-provenance-recovery
Nov 4, 2026
Merged

M4n5ter merged 3 commits into
rust-previewfrom
fix/codex-provenance-recovery

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

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.

  • Skip authority decoding for inactive Goals without pending work. Isolate individual record and execution failures, continue healthy Goals, and report the offending record through the existing Host diagnostic loop. Storage failures still propagate.
  • After shared ChatGPT discovery finishes, capture the current enabled model and current settings for new admission. Saving an override during discovery no longer rejects an otherwise available selection. Already admitted work retains its accepted controls.
  • Reuse the original pending admission when reconciling an already accepted scheduler fire. Metadata normalization no longer regenerates its execution fingerprint and strands the queued work before settlement.
  • Read Windows native CI bootstrap paths through Node's case-insensitive native environment lookup rather than the copied plain object.
  • Keep one strict current model format and one request preparation path. Old data is handled by the one-time migration below; there is no legacy snapshot reader, compatibility enum or legacy preparation branch in the product.

One-time migration for existing data

Migration script, instructions and executable tests — Python 3 standard library only.

gh gist clone 41d1efe9f9f48bb3ccbf7981de6e0744 maka-6580-migration
cd maka-6580-migration
python3 migrate_6580.py --host-root "$HOME/.maka/application/host"

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" --apply

Use 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

  • Focused native model, Goal and Workhub run: 15 passed (14 repository tests plus a temporary migration-output verification, removed after validation).
  • The temporary check used the strict current Rust model reader on migrated real snapshots and the actual Codex provider preparation path on the Gist fixture, checking output/context overrides and body overlay.
  • Independent GPT-6-Astra high advisor review passed after resolving the checkpoint field name, Bot watch coverage and scheduler admission-identity findings.
  • Entire scheduler test group: 4 passed, including original pending-admission reconciliation and lost-settlement recovery. The new scenario drives the original pending work without a user message and retains its original run and fingerprint.
  • Node CI tests: 12 passed.
  • Migration script: 4 behavior tests passed, covering authority copies and receipt updates, content/revision preservation, read-only preview, repeat execution, live writer-lease refusal and rollback after a later database fails.
  • Applied the script only to a temporary SQLite backup of the reported local Goal data: 2 old snapshots migrated, the second run found 0, and PRAGMA integrity_check returned ok. The user's actual databases were not modified.
  • cargo fmt --all --check, git diff --check, and affected-crate Clippy with -D warnings passed.
  • Full workspace checks and live paid-provider requests were not run. The Windows script lease branch has not been executed on Windows.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex investigated the incident, implemented the runtime fixes and standalone migration, updated documentation and ran the checks.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

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
@M4n5ter M4n5ter changed the title fix(agent): restore durable model snapshots and isolate Goal recovery fix(agent): isolate Goal recovery failures and stabilize model admission Nov 4, 2026

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
@M4n5ter
M4n5ter merged commit 56257b9 into rust-preview Nov 4, 2026
1 check passed
@M4n5ter
M4n5ter deleted the fix/codex-provenance-recovery branch November 4, 2026 04:13

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

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.

2 participants