Skip to content

Receipts-model migration gap: pre-receipts kit.json leaves ak-authored opencode artifacts permanently 'user-owned' with no self-heal #92

Description

@robertlee-ioactive

Summary

A kit.json written before the receipts-based artifact ownership model (i.e. by the #67-era builds, 4.0.0-alpha.29 + the merged opencode-host work) has no providers.opencodeManaged.artifacts map. After upgrading past that model, every ak-deployed artifact (plugin, converted agents, platform skill) reads as "user-owned/edited" forever — deploy refuses to manage it, and there is no self-heal path short of deleting the files and letting sync redeploy.

Hit live on a real machine during ak setup --opencode:

✓ opencode plugin: ⚠ ~/.config/opencode/plugins/ruflo-hooks.js differs from ak's last-written receipt (user-owned/edited) — left untouched
✓ opencode agents: 107 agents from override@3.32.24 (0 written, 0 removed, 1 skipped, 10 collision-renamed, 107 user-owned preserved; scanned 108)

The files were provably ak-authored: every agent carried the generated-by: agentic-kit marker comment, and the plugin was byte-identical to the shipped template (src/templates/opencode-ruflo-hooks.js). deployPlugin's gate is !receipt || contentHash(cur) !== receipt — a pre-receipts install has receipt: null, so the refusal is unconditional even when content is exactly current.

Why this matters

Everyone who enabled opencode on the #67-era build and then upgrades hits this on their next ak sync: the ownership model goes permanently blind over its own artifacts. The markers (agent generated-by comment, plugin src/templates/… header, skill deployed by agentic-kit) are already the proof of authorship the pre-receipts model used — the receipt gate just doesn't consult them.

Suggested fix (sketch)

An adoption path before the refusal: when receipt is null (or mismatched) but the on-disk content carries ak's marker AND equals either the current template (deployPlugin) or the content the converter/stamp would produce (syncAgents/deploySkill), treat it as ak-owned, record the fresh receipt, and converge — instead of permanently preserving it as foreign. That preserves the anti-clobber guarantee (a user file without the marker, or with edits, still refuses) while giving pre-receipts installs a one-time migration onto the ledger.

Workaround (verified just now)

As the machine owner, with the artifacts provably ak-authored: back up, remove the plugin file, the generated agents + stamp, and the platform skill, then ak sync — fresh deploys record fresh receipts and subsequent syncs are no-ops. (~/.config/opencode/.ak-receipt-migration-backup holds the pre-state on the machine where this was hit.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions