name: hcs-schema-change description: Change an HCS entity schema correctly — Zod source, generated JSON Schema, docs, tests, and fixtures all move together in a single PR. allowed-tools: Read, Grep, Glob, Edit
Skill: Change a schema
Use when adding, modifying, or removing an entity in packages/schemas/. Schema drift is the most expensive early mistake (per research plan §18 regression corpus); this skill enforces the "schema + docs + JSON Schema + tests move together" discipline.
Inputs
- The entity to change (e.g.,
HostProfile,OperationShape,Evidence) - The nature of the change (add field, remove field, change type, add new entity)
- The reason (cite an ADR, a policy need, or an observed failure)
Procedure
- Read
packages/schemas/src/entities/<entity>.ts— the Zod source. - Read
docs/host-capability-substrate/ontology.md— the human-facing description. - Read any tests under
packages/schemas/tests/orpackages/fixtures/covering the entity. - Read the generated JSON Schema at
packages/schemas/generated/<entity>.schema.json(if present). - Determine whether the change is:
- Additive with defaults — no
schema_versionbump; backward-compatible - Breaking —
schema_versionmust bump; consumers may need migration
- Additive with defaults — no
- Make the change in the Zod source.
- Update
docs/host-capability-substrate/ontology.mdin the same commit. - Regenerate JSON Schema in the same commit (
just generate-schemas). - Update tests to cover the new shape, including edge cases.
- Update fixtures if the entity is used in test data.
Rules
- One PR per schema change. Do not bundle schema changes with unrelated kernel work.
schema_versionbumps require an ADR unless the change is strictly additive with defaults.- Evidence-shaped fields keep provenance. Any new fact-returning field must include
source,observed_at,valid_until,authority,parser_version,confidence— either directly or via embedding anEvidence<T>wrapper. - Ring 0 imports from nowhere above Ring 0. Schemas do not import kernel types.
- Generated JSON Schema is regenerated, not hand-edited.
- Deprecated fields get
@deprecatedin Zod.describe()and are removed only after a deprecation window.
Required reviewers
A PR with schema changes must receive objections from:
hcs-ontology-reviewer(always; this is their scope)hcs-policy-reviewerif the change affects policy input/output shapeshcs-security-reviewerif the change touches Evidence authority, ApprovalGrant scope, or audit event schema
Escalate each via the appropriate subagent before requesting human review.
Every reviewer re-verifies every cited path:line against the file state under review before returning a verdict — do not carry file/line claims from an earlier read or recollection.
Output
The committed change, containing in a single diff:
- Zod source edit
- Generated JSON Schema regeneration
ontology.mdupdate- Test additions/edits
- Fixture updates (if applicable)
- Schema version bump if breaking (ADR referenced in commit message)
Never do
- Bundle a schema change with unrelated work.
- Skip JSON Schema regeneration.
- Skip the
ontology.mdupdate. - Remove a field without a deprecation window and an ADR.
- Hand-edit
packages/schemas/generated/**.
Reference
- Charter invariants 3 (layer discipline), 9 (skills location), 10 (public/private)
- Research plan §2 (Ontology) and §18 (evals)
- Ontology reviewer:
.claude/agents/hcs-ontology-reviewer.md