Skip to content

Personas: old personas and running workers survive the upgrade #777

Closed

Description

@bryantderosier

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 with definitionDigest = sha256(JSON.stringify(definition)), and refuses a mismatch.
  • Assignments. Each running worker's assignment stores its authorityPolicy by name (for example critic-review). agentPersonaRuntime.ts:43-46 checks that name against the snapshot's definition.authority.allowedPolicies on every turn.
  • Contracts. OrchestrationV2AgentPersonaAssignment already accepts any policy name, so an older app survives a newer server. AgentPersonaReportedAuthorityPolicy exists 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, and RuntimePolicy.ts rows already say to validate against immutable snapshot content and to preserve legacy assignment compatibility.

Proposal

  1. A tolerant decoder. It accepts both the old two-route modelRoute and the new ordered list, maps old policies, and ignores artifact fields.
  2. 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.
  3. 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.
  4. Imports reuse the decoder. Imported definitions and local overrides go through the same tolerant decoder, so nothing in the library gets rewritten.
  5. 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 modelRoute loads 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. diagnostic and publish-only load as invalid definitions whose repair message names the three valid levels.
  • Artifact fields are ignored and never cause a decode failure.
  • readSnapshot checks 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 diagnostic definition reporting its repair message.

Out of scope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions