Skip to content

schema(v4): P0-2 — strict v4 GA JSON schemas (coexist with preview, docs+schema only)#42

Merged
Davincc77 merged 1 commit into
mainfrom
schema/v4-ga-strict-p0-2
May 24, 2026
Merged

schema(v4): P0-2 — strict v4 GA JSON schemas (coexist with preview, docs+schema only)#42
Davincc77 merged 1 commit into
mainfrom
schema/v4-ga-strict-p0-2

Conversation

@Davincc77
Copy link
Copy Markdown
Owner

Summary

  • Ships the strict v4 GA candidate schemas required by ROAD-TO-V4-GA.md §P0-2:
    • schema/klickd-v4.schema.json (unified)
    • schemas/klickd-payload-v4.schema.json (split — payload)
  • Coexists with klickd-v4-preview.schema.json / klickd-payload-v4-preview.schema.json — preview schemas are unchanged and remain authoritative for preview files.
  • No SDK bump, no Git tag, no npm/PyPI/Zenodo release. Phase B governance respected.

What's strict, what's not

Strict (sections frozen by Accepted RFCs):

  • RFC-001 v1 media_profileversion: 1, entries[], closed modality enum (voice · image · document · embedding), BLAKE3 hash mandatory.
  • RFC-002 v1 core — verification_gates (five-level enum, structured + flat forms both accepted), human_veto_policy (incl. min_level), claim_sources v1 (prefer, require_citation_for).
  • RFC-004 v1 frozen migration fields.
  • Envelope crypto (v3 contract unchanged per §33.10 chore: publication hygiene v3.5.1 + RFC-001 media_profile draft #2): encrypted: truekdf + cipher + ciphertext required via if/then.

Permissive (sections still Draft):

  • RFC-002 v2-additive: reversibility, blast_radius, contract_tests, success_criteria, verification_artifacts, error_journal[].rule_created.
  • risk_thresholds, preflight_checks, context_cost, gaming_profile.
  • payload_schema_version enum accepts both "4.0" (GA) and "4.0.0-preview.1" for round-trip parity.

Preserved: top-level additionalProperties: true on both schemas — SPEC.md §33.7 unknown-field preservation is unconditional.

Test plan

  • python3 scripts/validate_v4_schemas.py — all 5 persona examples + examples/v4-preview/minimal.klickd + 7 expected_payload entries from tests/vectors_v40_preview.json validate against strict schemas; 5 negative cases each fail as expected.
  • python3 verify_vectors.py — 59/59 existing vectors pass (v2.5, v3.0, adversarial, v4.0-preview). Zero regression.
  • CI: existing test-vectors workflow continues to run unchanged. Strict-schema validator is local-only in this PR (CI wiring deferred to keep the PR focused).

Impacts on next P0 tracks

  • P0-3 (SDK Python klickd 4.0.0) and P0-4 (SDK TS @klickd/core 4.0.0) can now load these two schemas as the strict validation entry points. Recommended SDK surface: validate(payload, strict=True) cross-references schemas/klickd-payload-v4.schema.json while strict=False keeps the preview schema. The schema choice of accepting both "4.0" and "4.0.0-preview.1" in payload_schema_version was made specifically so SDKs can default to the strict schema for both populations.
  • P0-6 (strict + cross-impl vectors) — strict vectors do not exist yet; once authored, the validator script (scripts/validate_v4_schemas.py) is the obvious place to hook them. The R4-P0-3 persona README explicitly notes P0-6 is still pending.

Governance reminder

This PR is docs + schema only. No code under packages/ is touched. No version bump. No tag. Do not merge without Vince's explicit sign-off, even though the previous Phase A PRs were merged on the same governance terms.

🤖 Generated with Claude Code

…preview)

Ships the GA strict equivalents of klickd-v4-preview.schema.json /
klickd-payload-v4-preview.schema.json:

  - schema/klickd-v4.schema.json (unified)
  - schemas/klickd-payload-v4.schema.json (split — payload)

Strict on the v4 surface frozen by Accepted RFCs:
  - RFC-001 v1 media_profile (version + entries[], BLAKE3 hash, closed
    modality enum), with a permissive "summary" branch retained for
    round-trip parity with vectors_v40_preview.json
  - RFC-002 v1 core verification_gates (five-level enum, structured + flat
    forms), human_veto_policy (incl. min_level), claim_sources v1
  - RFC-004 v1 frozen migration fields

Permissive on Draft surface (reversibility, blast_radius, contract_tests,
success_criteria, verification_artifacts, error_journal.rule_created,
risk_thresholds, preflight_checks, context_cost) so a future strict bump
can tighten them without breaking GA writers.

Envelope contract retained from v3 (Argon2id + AES-256-GCM, §33.10 #2):
encrypted=true requires kdf + cipher + ciphertext via if/then.

Top-level additionalProperties: true is preserved on both schemas to
honor the SPEC.md §33.7 unknown-field preservation invariant.

Coexistence: the preview schemas remain in place unchanged and remain
authoritative for preview files. payload_schema_version accepts both
"4.0" (GA) and "4.0.0-preview.1" so the 5 personas and every
expected_payload of tests/vectors_v40_preview.json validate against
the strict payload schema.

Tooling:
  - scripts/validate_v4_schemas.py — local validator (positive +
    5 negative cases), exit 1 on failure.

Docs:
  - SCHEMA_INDEX.md, schema/README.md, schemas/README.md — list the
    GA strict files and the coexistence rules.
  - docs/roadmap/ROAD-TO-V4-GA.md §P0-2 — status note; P0-6 strict
    vectors remain pending before the full DoD is ticked.
  - examples/v4/personas/README.md — DoD checkbox for strict
    validation flipped, P0-6 vectors checkbox kept open.

Governance: no SDK bump, no new vectors, no Git tag, no npm/PyPI/Zenodo
release. Existing verify_vectors.py suite (59/59) still passes — no
regression on v2.5, v3.0, adversarial, or v4.0-preview tracks.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Davincc77 Davincc77 merged commit a08ad7a into main May 24, 2026
3 checks passed
@Davincc77 Davincc77 deleted the schema/v4-ga-strict-p0-2 branch May 24, 2026 21:40
Davincc77 added a commit that referenced this pull request May 24, 2026
…ma (#43)

* sdk(python,v4): P0-3 — align klickd Python SDK with v4 GA strict schema

Adds a v4 schema validation surface to the Python SDK (P0-3) without
bumping the package version (`4.0.0a1`) and without touching the v3
envelope crypto contract (SPEC.md §33.10 #2 frozen).

What ships:

- `klickd.validate(payload, strict=True|False, target="payload"|"unified")`
  with the strict GA candidate (P0-2) and permissive v4 preview schemas
  bundled as package data under `klickd/schemas/`.
- `klickd.validate_iter_errors(...)` non-raising variant for wizards
  (R4-P0-1 reload-verification surface area).
- Optional `[validate]` extra (`pip install klickd[validate]`) —
  `jsonschema` stays optional so callers who only need load/save are
  unaffected.
- v4 TypedDicts: `KlickdMediaProfileV1`, `KlickdVerificationGatesV1`,
  `KlickdGateEntry`, `KlickdHumanVetoPolicy`, `KlickdClaimSources`,
  `KlickdMigrationV1` (additive to `KlickdPayload`).
- README block documenting the new surface + the §33.7 verbatim
  round-trip guarantee on v4 additive fields.

What does NOT ship:

- No envelope/version bump, no PyPI publish, no Git tag, no Zenodo DOI
  — Phase B governance reminder respected.
- No SDK alignment of the docs-only R4-P0-2 codes (`KLICKD_E_PASS_MISMATCH`,
  `KLICKD_E_SAVE_LOCAL`, `KLICKD_E_LEGACY_VERSION`, `KLICKD_E_CORRUPT`,
  `KLICKD_E_POLICY_LOCKED`, `KLICKD_E_UNSAFE_QR`); R4-P0-2 §4 explicitly
  defers SDK exposure to a later track.

Tests (63 / 63 pass):

- 5 R4-P0-3 personas validate against strict payload + unified + preview.
- 5 personas round-trip verbatim (single + double round-trip).
- Negative cases: unknown gate level, missing media hash, unknown
  modality, unsupported `payload_schema_version`, encrypted envelope
  missing kdf/cipher/ciphertext.
- Both structured + flat `verification_gates` shapes accepted.
- Preview value `"4.0.0-preview.1"` accepted by strict schema (P0-2
  design — preview-era files round-trip without rewrite).
- v3.x payloads unaffected (no regression).
- Unknown top-level fields validate AND round-trip verbatim.
- `tests/test_v4_preview_roundtrip.py` and `tests/test_roundtrip.py`
  unchanged and still green.

Repo-level checks: `scripts/validate_v4_schemas.py` ✓ ;
`verify_vectors.py` 59/59 ✓ ; JS `verify_vectors.mjs` 29/29 ✓ .

Refs: P0-3 in `docs/roadmap/ROAD-TO-V4-GA.md`, depends on P0-1 + P0-2
(merged in #42).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* ci(python,v4): install klickd[validate] extra so v4 strict tests run

The new tests/test_v4_ga_strict.py suite uses klickd.validate, which is
gated on the optional jsonschema dependency. The CI step now installs
the [validate] extra so the strict-schema tests execute; the test file
also pytest.importorskip()s on jsonschema so a local run without the
extra cleanly skips the validation tests instead of erroring.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Code <claude-code@anthropic.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants