Export DB-composed agent instructions for V3 cutover - #1002
Merged
Conversation
olegbrok
marked this pull request as ready for review
August 5, 2026 12:31
olegbrok
approved these changes
Aug 5, 2026
olegbrok
left a comment
Collaborator
There was a problem hiding this comment.
APPROVE — reviewed against the V3 resolver contract mapped on V3#12 (comment 5188264727):
- Composition is exclusively
build_system_prompt()from snapshot copies (WAL sidecars included, live DBs never opened in place); CLAUDE.md is read once, for the legacy sha only. - The freshness field is computed as the exact biconditional the resolver enforces — it structurally cannot violate the check.
targetSha256 == effectiveInstructionsSha256, 0600 via fchmod, absolute traversal-free targetPath, explicit authority-decision-id required fail-closed. - The cwd trap around
UserProfileStore's relative path is handled correctly (invocation_root captured before chdir; agent_root anchored to it). - Record carries hashes only — the artifact travels out-of-band at 0600, tighter than the CLAUDE.md it supersedes.
- Live evidence: real-agent export detected genuine #955-class drift on first run; isolated V3 dry-run 1,365 rows / 0 fatals.
Extras beyond spec (per-channel provenance shas, generated-output evidence with REGENERATE_FROM_OWNER_AUTHORITY) are the right instinct. Merging on CI green.
🤖 Reviewed by Barsik
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the missing V2-side instruction export leg for the V3 cutover contract described in PinkyBotV3#12.
AgentRegistry.build_system_prompt()from copied agent, skill, and user-profile databasesdata/agents/<name>/CLAUDE.mdas authority; it is read only as bytes for drift hashing0600agentandagent-instructionsinventory rows with the full resolver evidence contract, including composition-set hashes, generated-output classifications, target hash/mode, and exact freshness stateRoot cause
The existing cutover exporter covered memory/project rows only. V3 already fails closed unless completed import evidence contains one exact DB-composed instruction record and a retained private artifact, so V2 had no valid way to supply instruction authority.
Validation
uv run ruff check scripts/v3_export.py tests/test_v3_export.pyuv run ruff format --check scripts/v3_export.py tests/test_v3_export.pyuv run pytest -q tests/test_v3_export.py tests/test_agent_registry.py— 120 passedgit diff --check0600; DB-composed and legacy hashes differed, producingDIFFERS_FROM_DB_COMPOSITIONas expectedINVENTORY_SUPPORTEDThe isolated target was intentionally empty, so existing memory/project rows remained omitted as unresolved scopes; that is the normal pre-agent qualification state and did not produce exporter fatals.