4.6 KiB
4.6 KiB
Tasks: Add Report Schema
1. Top-Level Report Structure
- 1.1 Specify the report envelope:
schema_version,tool_version,generated_at(ISO-8601), andscanmetadata (scope globs, files scanned count, excluded dirs). - 1.2 Specify the
shortlistfield (candidate paths the scanner surfaced) and its relationship toentries. - 1.3 Specify the
entriesarray as the per-file results.
2. Per-File Entry Fields
- 2.1 Specify required entry fields:
path,category,signals,op,op_type,is_destructive,is_reversible,safety_tier,token_estimate. - 2.2 Specify the optional
exact_editfield and when it MUST be present (deterministic ops) and absent (generative ops). - 2.3 Freeze the
exact_edit.kindclosed enum:delete-range,move-to-archive,insert-frontmatter(freeze-stamp),replace-text(known-target link fix),dedupe(exact-dup removal). For each kind specify its required sub-fields and inherent(is_destructive, is_reversible)characterization, and that a validator rejects an unknownkindor a kind missing a required sub-field. Cross-check the derivation:delete-range(destructive — info kept nowhere else) →confirm;move-to-archive,insert-frontmatter,replace-text, anddedupe(reversible, non-destructive —dedupe's removed span is preserved atcanonical_ref) →auto. - 2.4 Specify
op_type↔opconsistency validation:op_typeis a property of the chosen op (not a free field, not a subtype lookup);exact_editpresent iffop_type == deterministic, validated deterministically.
3. Category Taxonomy
- 3.1 Fix the stale sub-types:
contradicted,orphaned,superseded,provisional,completed-in-place,duplicated. - 3.2 Fix the bloat sub-types:
distill,split,freeze. - 3.3 Specify
categoryas{ class: stale | bloat, subtype: <enum> }.
4. Op-Type and Safety-Tier Semantics
- 4.1 Specify
op_typeenum (deterministic|generative) and meaning. - 4.2 Specify
safety_tierenum (auto|confirm) and meaning. - 4.3 Specify the
is_destructive/is_reversibleop-characterization inputs the classifier supplies for the derivation. - 4.4 Specify the
safety_tierderivation rule:safety_tier(op_type, is_destructive, is_reversible)— generative ⟹ confirm; destructive or irreversible ⟹ confirm; only deterministic + reversible + objective ⟹ auto. Tier is computed, never model-assigned, and can never emitautofor a generative or destructive op (invariant #7).
5. Token Estimate
- 5.1 Specify per-entry
token_estimateshape:raw_tokensrequired in v1 (deterministic local-tokenizer count, no API call). - 5.2 Mark
injection_frequencyandweighted_tokensas v2-optional / nullable fields; injection-frequency weighting + bottom-up rollup to category and total is the v2 bonus per the PRD build order.
6. Frozen-Contract Guarantee
- 6.1 Freeze and version the schema (
schema_version): specify that any change to a field, enum value, or documented semantic requires updatinginvariants.mdwith explicit human approval. - 6.2 Reference
invariants.mdas the authoritative enforcement mechanism for the freeze (it carries the schema-freeze andsafety_tierderivation invariants). Do NOT author classifier golden examples in this change — the classifier (the AIcheckpass) does not exist yet, so classifier golden examples are deferred to after thecheckchange.
7. Schema-Shape Verification
These are schema-shape fixtures, valid to author now. They are NOT classifier golden examples (deferred to the
checkchange) — an implementer must not conflate the two.
- 7.1 Write a schema-validator script that checks a machine report against
this frozen schema (envelope fields, closed category enum, closed
exact_edit.kindenum with per-kind required sub-fields,op_type↔exact_editbiconditional, andsafety_tierequals the derivation output). - 7.2 Author one valid schema fixture (a well-formed machine report) under
examples/golden/and confirm the validator accepts it. - 7.3 Author one invalid schema fixture (e.g. unknown
exact_edit.kind, or asafety_tierdisagreeing with the derivation) underexamples/golden/and confirm the validator rejects it.
8. Validation
- 8.1 Run
openspec validate add-report-schema --strictand confirm it passes.