Repository navigation
Description
Item 2 of 11 in the Personas v2: simpler specialists milestone. It ships in one release with #778 and #779.
The problem
The persona YAML is about to change shape: an ordered model list instead of two routes, and one access level instead of a policy list. But three things depend on the old shape:
- The team library. It lives in a shared folder (
monorepo/j5/personas), and teammates on older J5 builds read it too. - Running workers. Each one points at a saved snapshot, and the server re-hashes that snapshot on every read.
- Clients. Mobile builds can lag behind the server.
If the decoder only understands the new shape, running workers break the moment we upgrade.
Where this sits
Decision 9 of the Personas v2 proposal, and the policy mapping from decision 10. Bastian's review called out the snapshot problem specifically: decoding an old snapshot into the new shape would change its digest and break every running worker.
What we already have
- Snapshots. They're stored as
agent-persona-snapshots/<sha256>.json.readSnapshot(apps/server/src/j5/agents/agentPersonaLibrary.ts:754) decodes the file, re-hashes it withdefinitionDigest = sha256(JSON.stringify(definition)), and refuses a mismatch. - Assignments. Each running worker's assignment stores its
authorityPolicyby name (for examplecritic-review).agentPersonaRuntime.ts:43-46checks that name against the snapshot'sdefinition.authority.allowedPolicieson every turn. - Contracts.
OrchestrationV2AgentPersonaAssignmentalready accepts any policy name, so an older app survives a newer server.AgentPersonaReportedAuthorityPolicyexists for the same reason (packages/contracts/src/j5/agentPersona.ts:59-65). - One decode path. Imports and local overrides go through the same library decoder as folder sources.
- FORK.md. The
Orchestrator.ts,ProjectionStore.ts, andRuntimePolicy.tsrows already say to validate against immutable snapshot content and to preserve legacy assignment compatibility.
Proposal
- A tolerant decoder. It accepts both the old two-route
modelRouteand the new ordered list, maps old policies, and ignores artifact fields. - Verify snapshots as stored. Check the digest against the snapshot file exactly as it was written, and only then run it through the tolerant decoder. Snapshots are never rewritten or renamed.
- Map stored policies at run time. A running worker's assignment keeps its stored policy name. The runtime maps it to the new access level, instead of checking it against the dropped
allowedPolicies. - Imports reuse the decoder. Imported definitions and local overrides go through the same tolerant decoder, so nothing in the library gets rewritten.
- Tolerant clients. Web, desktop, and mobile read the new contract fields and tolerate the old ones until the release that drops them.
There's no in-app migration tool.
Policy mapping:
| Old policy | Maps to |
|---|---|
read-only |
read-only |
critic-review |
read-only |
workspace-write |
workspace-write |
critic-fix |
workspace-write |
full-access |
full-access |
diagnostic, publish-only |
Invalid definition, with a repair message |
No driver can enforce diagnostic or publish-only today, so personas using them already can't run. They stay blocked until their author picks one of the three levels. The decoder never picks a level for them.
Acceptance criteria
- A definition with the old two-route
modelRouteloads as a two-entry ordered list, in the same order. - A definition with the new ordered list loads.
- Old policies map as in the table above.
diagnosticandpublish-onlyload as invalid definitions whose repair message names the three valid levels. - Artifact fields are ignored and never cause a decode failure.
-
readSnapshotchecks the digest against the stored file before decoding. An old snapshot still passes, and a tampered one still fails. - No snapshot is rewritten or renamed during an upgrade.
- A worker launched before the upgrade keeps taking turns after it: same instructions, and its stored policy is mapped to the new access level at run time.
- Imported definitions and local overrides in the old shape load without being rewritten.
- Web, desktop, and mobile render a persona from a server that sends both the new fields and the old ones.
- An older J5 build can still read the team folder until Personas: update the 11 team personas (monorepo PR) #780 lands. In practice, the release ships before the folder changes.
- Focused tests cover each policy mapping, an old snapshot passing digest verification, an old assignment taking a turn, and an invalid
diagnosticdefinition reporting its repair message.
Out of scope
- The ordered-list selection logic and editor (Personas: an ordered model list #778).
- The access-level editor and provider table (Personas: three access levels #779).
- Editing the team definitions (Personas: update the 11 team personas (monorepo PR) #780).
Activity