diff --git a/docs/architecture/08-crosscutting-concepts.md b/docs/architecture/08-crosscutting-concepts.md index d30addea..968e561b 100644 --- a/docs/architecture/08-crosscutting-concepts.md +++ b/docs/architecture/08-crosscutting-concepts.md @@ -139,13 +139,13 @@ elements, and deprecate one by naming its replacement. | Element | What is frozen | Source | |---------|----------------|--------| -| Template paths | The file path of every shipped template | ADR-051 | -| Template IDs | The `id` of every manifest entry | ADR-051 | -| Section IDs | Every `[ID:]`, in the file that holds it, and the headings its section holds. A section does not move to another file, and a minor adds an ID only on new content, never in front of lines a shipped section holds. SYS-24 checks it against the newest 3.x tag | ADR-051 | +| Template paths | The file path of every shipped template. SYS-29 checks it against the newest 3.x tag | ADR-051 | +| Template IDs | The `id` of every manifest entry. SYS-29 checks it against the newest 3.x tag | ADR-051 | +| Section IDs | Every `[ID:]`, in the file that holds it, and the headings its section holds. A section does not move to another file, and a minor adds an ID only on new content, never in front of lines a shipped section holds. SYS-29 checks that each stays in its file, and SYS-24 that no new ID splits a section, against the newest 3.x tag | ADR-051 | | Manifest schema | The fields the header comment of `templates/manifest.yaml` lists, and their meaning; a minor adds only optional fields | ADR-051 | -| Core-tier membership | The IDs under `core:`; a new template is reached by declaring it, never by joining the core | ADR-051 | +| Core-tier membership | The IDs under `core:`; a new template is reached by declaring it, never by joining the core. SYS-29 checks it | ADR-051 | | Check exit codes | 0 passes, 1 fails, 3 does not apply | ADR-051 | -| Task kinds | The kinds under the manifest's `tasks:`, which a load directive names | ADR-058 | +| Task kinds | The kinds under the manifest's `tasks:`, which a load directive names. SYS-29 checks them | ADR-058 | | Hooks | A shipped hook ID, its direct exit codes, its `not applicable` line and its violation codes | ADR-055 | | Hook arguments | The name and default of each argument a consumer writes into its config, such as `--path`, `--forbid` and `--base`; a minor adds only arguments whose default keeps the hook's behaviour | ADR-051, applied to hooks | | Fork entry points | The fork-owned module names (8.6), and the names upstream reads from them, `bind`, `CHECKS`, `TEMPLATE_DIRS`, `CORE_DIRS` and `QUALITY_GATES_EXEMPT_LAYERS` from `fork_checks.py`; `CHECKS` and `SKIP_BUDGET` from `fork_dispositions.py`; `SPEC_CHAIN_EXAMPLES` and `CHAIN_EXAMPLES_DOC` from `fork_examples.py`. The disposition words `tests/conformance` defines for a fork to import | ADR-051, applied to forks | diff --git a/docs/architecture/10-quality-requirements.md b/docs/architecture/10-quality-requirements.md index 1f25d257..7e893fdc 100644 --- a/docs/architecture/10-quality-requirements.md +++ b/docs/architecture/10-quality-requirements.md @@ -54,7 +54,7 @@ goal is a gap, not a pass. | Functional suitability | Functional appropriateness | Representative tasks complete correctly | The efficacy benchmark, which runs in `solid-ai-dev/solid-ai-benchmark` | Measured each benchmark round | QG-01-02 | | Functional suitability | Functional appropriateness | Selected policy fits the project and task | Each root's resolved chain; the adoption boundary in `core/agents.md` | Not measured | - | | Performance efficiency | Time behaviour, resource utilization | Context, time, retries and adoption effort relative to outcomes | Chain size per stack category; benchmark tokens, turns, time and cost; latency | Cost measured each benchmark round; latency and adoption effort not measured | QG-02-02 | -| Flexibility | Replaceability | Changes and overrides have explainable effects and manageable migration | The 3.x frozen surface (chapter 8.7); `tools/check_release.py`; SYS-22; SYS-24, for section splitting only | Not measured, since 3.0.0 is the first frozen release | QG-03-02, FR-09-01 | +| Flexibility | Replaceability | Changes and overrides have explainable effects and manageable migration | The 3.x frozen surface (chapter 8.7); `tools/check_release.py`; SYS-22; SYS-24, for section splitting; SYS-29, for removed or renamed IDs and paths | Not measured, since 3.0.0 is the first frozen release | QG-03-02, FR-09-01 | | Flexibility | Adaptability | The shared rules survive a change of stack or agent | None yet | Not measured | - | | Maintainability | Modifiability | Fewer recurring defects and less policy-induced work | `tools/score_templates.py` and its ratchet; the intake dispositions in `CONTRIBUTING.md`; the share of `changelog:none` pull requests in each release proposal | Measured on every pull request by the ratchet; the share reported from 3.1.0 | QG-04-02, QG-04-03 | diff --git a/docs/requirements.md b/docs/requirements.md index bc527737..07cb2b8f 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -92,7 +92,7 @@ Status: skeleton. Each cluster holds a few requirements until its fill | ID | Requirement | Source | Checked by | |----|-------------|--------|------------| -| FR-09-01 | The system shall not remove, rename or change the meaning of a frozen element in a 3.x release, except for a security fix. | Chapter 8.7, ADR-051 | SYS-24, partial, for section splitting only | +| FR-09-01 | The system shall not remove, rename or change the meaning of a frozen element in a 3.x release, except for a security fix. | Chapter 8.7, ADR-051 | SYS-24, for section splitting; SYS-29, for template IDs and paths, section IDs, the core tier and task kinds | | FR-09-02 | The system shall keep a deprecated template resolving until the next major, naming a live replacement. | Chapter 8.8 | SYS-22, partial, for a live replacement | | FR-09-03 | The system shall change nothing in an existing context file when a project moves its pin. | Chapter 6.5 | - | | FR-09-04 | The system shall write each release's changelog entries from the labels of the pull requests merged since the previous tag. | Chapter 6.6 | changelog-label gate, `cut_changelog.py --self-test`, partial: the tag range is untested | diff --git a/docs/tests/index.md b/docs/tests/index.md index b4b4c386..fc95790c 100644 --- a/docs/tests/index.md +++ b/docs/tests/index.md @@ -50,6 +50,7 @@ restated in each. | `SAIT-SMK-SYS-25-001A` | SMK | P1 | A load directive names a listed task, in its heading's tags | | `SAIT-SMK-SYS-26-001A` | SMK | P1 | The emitter places each section by its load, the same every run | | `SAIT-SMK-SYS-27-001A` | SMK | P1 | An emitted file names no template file | +| `SAIT-SMK-SYS-29-001A` | SMK | P1 | No frozen ID or path leaves the tree inside the major | | `SAIT-SMK-TPL-04-001A` | SMK | P1 | All EXTEND and OVERRIDE directives reference existing IDs | | `SAIT-INT-TPL-01-001A` | INT | P0 | DEPENDS ON chain assembles a complete rule set | | `SAIT-INT-TPL-02-001A` | INT | P1 | EXTEND adds rules without removing base rules | diff --git a/docs/tests/specs/SAIT-SMK-SYS-29-001A.md b/docs/tests/specs/SAIT-SMK-SYS-29-001A.md new file mode 100644 index 00000000..f097da04 --- /dev/null +++ b/docs/tests/specs/SAIT-SMK-SYS-29-001A.md @@ -0,0 +1,93 @@ +--- +id: SAIT-SMK-SYS-29-001A +title: No frozen ID or path leaves the tree inside the major +product: sait +type: smoke +area: SYS +priority: p1 +status: ready +environment: [local, ci] +automatable: yes +created: 2026-11-16 +author: Branimir Georgiev +product-version: "3.x" +tags: [templates, compatibility, fork, frozen-surface] +--- + +## Short description + +> **Given** the newest 3.x release tag reachable from HEAD +> **When** the manifest and every template are compared with their state +> at that tag +> **Then** every template ID, template path, section ID, core-tier member +> and task kind present there is still present, because a fork extending +> a renamed ID fails only after it merges + +## Results + +| Result | Condition | +|--------|-----------| +| PASSED | Every planted case yields exactly its owed findings, and no frozen element present at the baseline is missing from the tree | +| FAILED | A template ID, a template's path, a section ID in its file, the core tier or a task kind differs from the baseline | +| FAILED | A planted case or the planted repository yields findings or a refusal other than those it owes | +| FAILED | The clone is shallow, or no tag at all is reachable from HEAD | +| FAILED | No planted case was run | +| SKIPPED | — | +| BLOCKED | — | +| ERROR | — | + +## Steps + +### Prerequisites + +- Repository cloned with its full history and tags +- Python 3 and git + +### Setup + +— (operates on the working tree and the newest `v3.*` tag reachable from +HEAD, the baseline SYS-24 reads) + +### Execution + +1. Compare each later side in `FROZEN_CASES` with the planted frozen + manifest and texts, and compare the findings with those the case owes +2. Build a throwaway repository whose base commit, tagged `v3.0.0`, holds + the planted manifest and texts, and whose HEAD renames a section ID; + run the comparison the real run uses +3. Take the baseline: the newest tag matching `v3..` that + HEAD contains. With none, nothing is frozen yet +4. Read the manifest and each entry's file at the baseline and in the + working tree, and leave out the baseline's fixture entries +5. Report each entry ID missing, each entry whose file changed, each + `[ID:]` missing from the file that held it, a changed `core:` list and + each task kind missing + +### Assertions + +1. Assert no change, an added section, template and task kind, a + deprecated template and a renamed fixture yield no finding -- the + controls that what chapter 8.7 allows passes +2. Assert a renamed section ID, a section moved to another file, a + renamed template ID, a renamed template file, a template joining the + core and a removed task kind each yield one finding naming it +3. Assert, through git, that a section ID renamed behind a `v3.0.0` tag is + found +4. Assert no real element is missing from the tree +5. Assert the planted case count is non-zero, per ADR-034 + +### Negative controls + +1. **The defect that motivated the check.** Renaming a section ID that + only a fork extends passed upstream smoke and fork sync; the fork failed + only after merging. Renaming `base-git` in `core/git.md` now fails here +2. **A deprecation.** An entry marked `deprecated` keeps its ID and file, + so it passes; a check that read deprecation as removal would block + what chapter 8.8 prescribes + +## Related + +- The spec, chapter 8.7, "Frozen surface" +- The spec, chapter 8.8, "Deprecation" +- ADR-051 -- IDs and paths are frozen inside a major +- SYS-24, which checks that a new ID splits no frozen section diff --git a/tests/smoke/registry.py b/tests/smoke/registry.py index d0e3cc86..b1a46454 100644 --- a/tests/smoke/registry.py +++ b/tests/smoke/registry.py @@ -38,6 +38,7 @@ check_sys_25, check_sys_26, check_sys_27, + check_sys_29, ) from .templates import ( check_tpl_01, @@ -290,4 +291,10 @@ class Check(TypedDict): "title": "An emitted file names no template file", "fn": check_sys_27, }, + { + "id": "SYS-29", + "spec": "SAIT-SMK-SYS-29-001A", + "title": "No frozen ID or path leaves the tree inside the major", + "fn": check_sys_29, + }, ] diff --git a/tests/smoke/system.py b/tests/smoke/system.py index e7313b1e..5176ca50 100644 --- a/tests/smoke/system.py +++ b/tests/smoke/system.py @@ -2521,3 +2521,295 @@ def check_sys_27() -> CheckResult: for mode in ("skills", "inline"): seen.count(f"files emitted, {mode}", emitted[mode]) return seen.failures() + failures, seen.notes() + + +# --------------------------------------------------------------------------- +# SYS-29 -- no frozen ID or path leaves the tree inside the major +# --------------------------------------------------------------------------- + +# Chapter 8.7 freezes, from the first release of a major to the next major, +# the id and file of every manifest entry, every `[ID:]` in the file that +# holds it, the core tier and the task kinds. A rename reads as a removal +# plus an addition, so every element present at the baseline must still be +# present; what a minor adds is free. A deprecated entry keeps its id and +# file, so it passes. A fork extending a renamed ID fails only after it +# merges, so upstream checks the removal itself. The baseline is the one +# SYS-24 reads, and the fixture is exempt for the same reason. + +FrozenSide = tuple[Manifest, Mapping[str, str]] + + +def frozen_ids(was: FrozenSide, now: FrozenSide) -> list[str]: + """Each frozen element present in `was` and missing from `now`. + + A side is (manifest, {file: text}). Fixture entries of `was` are left + out, and so are their files. + """ + (was_manifest, was_texts), (now_manifest, now_texts) = was, now + was_entries = { + e["id"]: e + for key in entry_sections(was_manifest) + for e in was_manifest[key] + if not is_fixture(e) + } + now_entries = { + e["id"]: e for key in entry_sections(now_manifest) for e in now_manifest[key] + } + found: list[str] = [] + for tid, entry in was_entries.items(): + if tid not in now_entries: + found.append(f"template ID {tid} is gone from the manifest") + continue + if now_entries[tid]["file"] != entry["file"]: + found.append( + f"template {tid} moved from {entry['file']} " + f"to {now_entries[tid]['file']}" + ) + continue + rel = entry["file"] + held = {sid for sid, _ in iter_id_declarations(now_texts.get(rel, ""))} + for sid, _ in iter_id_declarations(was_texts.get(rel, "")): + if sid not in held: + found.append(f"section ID {sid} is gone from {rel}") + + was_core = list(was_manifest.get("core") or []) + now_core = list(now_manifest.get("core") or []) + if now_core != was_core: + found.append(f"the core tier changed from {was_core} to {now_core}") + kept = task_kinds(now_manifest) + for kind in task_kinds(was_manifest): + if kind not in kept: + found.append(f"task kind {kind} is gone from the manifest") + return found + + +FROZEN_MANIFEST = """core: [base-a] + +tasks: + review: Review a change + +base: + - id: base-a + file: templates/core/a.md + description: A + - id: base-b + file: templates/core/b.md + description: B + +stacks: + - id: stack-fixture + file: templates/stack/fixture.md + description: Fixture + fixture: true +""" + +FROZEN_TEXTS = { + "templates/core/a.md": "# A\n\n[ID: base-a]\n\n## Two\n\n[ID: base-a-two]\n", + "templates/core/b.md": "# B\n\n[ID: base-b]\n", + "templates/stack/fixture.md": "# F\n\n[ID: stack-fixture]\n", +} + + +def _later(manifest: str = FROZEN_MANIFEST, **texts: str) -> FrozenSide: + """FROZEN_MANIFEST and FROZEN_TEXTS with the given files replaced; a + keyword names the file by its stem, such as `a` for core/a.md.""" + merged = dict(FROZEN_TEXTS) + for stem, text in texts.items(): + rel = next(r for r in merged if r.endswith(f"/{stem}.md")) + merged[rel] = text + return parse_manifest(manifest), merged + + +# Each case is a later side and the findings it owes against the frozen +# one. The additions, the deprecation and the fixture rename are the +# controls: a check that flagged them would fail what chapter 8.7 allows. +FROZEN_CASES: list[tuple[str, FrozenSide, list[str]]] = [ + ("nothing changed", _later(), []), + ( + "a section, a template and a task kind added", + _later( + FROZEN_MANIFEST.replace( + " review: Review a change\n", + " review: Review a change\n plan: Plan a change\n", + ).replace( + "stacks:", + " - id: base-c\n file: templates/core/c.md\n" + " description: C\n\nstacks:", + ), + a=FROZEN_TEXTS["templates/core/a.md"] + "\n## New\n\n[ID: base-a-new]\n", + ), + [], + ), + ( + "a template deprecated", + _later( + FROZEN_MANIFEST.replace( + " description: B\n", + " description: B\n deprecated: base-a\n", + ) + ), + [], + ), + ( + "the fixture's IDs renamed", + _later( + FROZEN_MANIFEST.replace("stack-fixture", "stack-probe"), + fixture="# F\n\n[ID: stack-probe]\n", + ), + [], + ), + ( + "a section ID renamed", + _later(a=FROZEN_TEXTS["templates/core/a.md"].replace("a-two", "a-2")), + ["section ID base-a-two is gone from templates/core/a.md"], + ), + ( + "a section moved to another template", + _later( + a="# A\n\n[ID: base-a]\n", + b=FROZEN_TEXTS["templates/core/b.md"] + "\n## Two\n\n[ID: base-a-two]\n", + ), + ["section ID base-a-two is gone from templates/core/a.md"], + ), + ( + "a template ID renamed", + _later(FROZEN_MANIFEST.replace("id: base-b", "id: base-bee")), + ["template ID base-b is gone from the manifest"], + ), + ( + "a template file renamed", + _later(FROZEN_MANIFEST.replace("core/b.md", "core/bee.md")), + ["template base-b moved from templates/core/b.md to templates/core/bee.md"], + ), + ( + "a template joining the core tier", + _later(FROZEN_MANIFEST.replace("core: [base-a]", "core: [base-a, base-b]")), + ["the core tier changed from ['base-a'] to ['base-a', 'base-b']"], + ), + ( + "a task kind removed", + _later(FROZEN_MANIFEST.replace(" review: Review a change\n", "")), + ["task kind review is gone from the manifest"], + ), +] + + +def frozen_side(repo: str, ref: str | None) -> FrozenSide: + """The manifest and the texts of its entries' files at `ref` in `repo`, + or in its working tree when `ref` is None. A file missing on that side + reads as empty, so its IDs read as gone.""" + rel = "templates/manifest.yaml" + + def text(path: str) -> str: + if ref is None: + full = os.path.join(repo, path) + if not os.path.isfile(full): + return "" + with io.open(full, encoding="utf-8") as handle: + return handle.read() + if _git(repo, "cat-file", "-e", f"{ref}:{path}").returncode != 0: + return "" + shown = _git(repo, "show", f"{ref}:{path}") + if shown.returncode != 0: + raise RuntimeError(f"git show {ref}:{path} failed: {shown.stderr.strip()}") + return shown.stdout + + manifest = parse_manifest(text(rel)) + files = {e["file"] for key in entry_sections(manifest) for e in manifest[key]} + return manifest, {f: text(f) for f in files} + + +def frozen_findings( + repo: str, +) -> tuple[list[str], str | None, str | None, FrozenSide | None]: + """Compare the working tree of `repo` with its frozen baseline. + + Returns (findings, basis, refusal, baseline side), as SYS-24's + comparison does; the side is None when nothing is frozen yet. + """ + tag, refused = frozen_baseline(repo) + if refused: + return [], None, refused, None + if tag is None: + basis = f" baseline: no v{FROZEN_MAJOR}.x release is reachable" + return [], basis, None, None + was = frozen_side(repo, tag) + found = frozen_ids(was, frozen_side(repo, None)) + return found, f" baseline: the release tag {tag}", None, was + + +def _planted_rename() -> list[str]: + """Rename a section ID behind a planted v3 tag; return a failure line + unless the comparison through git finds exactly that rename.""" + owed = ["section ID base-a-two is gone from templates/core/a.md"] + with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as repo: + for args in ( + ("init", "-q"), + ("config", "core.autocrlf", "false"), + ("config", "user.name", "smoke"), + ("config", "user.email", "smoke@localhost"), + ): + _git(repo, *args) + later = dict(FROZEN_TEXTS) + later["templates/core/a.md"] = later["templates/core/a.md"].replace( + "a-two", "a-2" + ) + manifest = {"templates/manifest.yaml": FROZEN_MANIFEST} + for texts, message in ((FROZEN_TEXTS, "base"), (later, "rename")): + for rel, body in {**manifest, **texts}.items(): + path = os.path.join(repo, rel) + os.makedirs(os.path.dirname(path), exist_ok=True) + with io.open(path, "w", encoding="utf-8", newline="\n") as f: + f.write(body) + _git(repo, "add", "-A") + done = _git(repo, "commit", "-q", "-m", message) + if done.returncode != 0: + raise RuntimeError( + f"planted commit {message!r} failed: {done.stderr.strip()}" + ) + if message == "base": + _git(repo, "tag", f"v{FROZEN_MAJOR}.0.0") + found, _, refused, _ = frozen_findings(repo) + if refused or found != owed: + return [ + f" planted repository: found {found}, refused {refused!r}, owed {owed}" + ] + return [] + + +def check_sys_29() -> CheckResult: + seen = Inspected() + failures: list[str] = [] + + seen.count("planted cases", FROZEN_CASES) + frozen = parse_manifest(FROZEN_MANIFEST), FROZEN_TEXTS + for label, later, want in FROZEN_CASES: + got = frozen_ids(frozen, later) + if got != want: + failures.append(f" planted, {label}: found {got}, owed {want}") + failures += _planted_rename() + + found, basis, refused, was = frozen_findings(ROOT) + if refused is not None: + failures.append(f" {refused}") + return seen.failures() + failures, seen.notes() + + # Zero until the first release of the major is tagged, as in SYS-24. + manifest, texts = was or ({}, {}) + entries = [ + e + for key in entry_sections(manifest) + for e in manifest[key] + if not is_fixture(e) + ] + seen.count("frozen template IDs", len(entries), floor=0) + declared = sum( + len(list(iter_id_declarations(texts.get(e["file"], "")))) for e in entries + ) + seen.count("frozen section IDs", declared, floor=0) + for finding in found: + failures.append( + f" {finding}: a 3.x release keeps every frozen element and " + f"deprecates one by naming its replacement" + ) + return seen.failures() + failures, seen.notes() + [str(basis)]