Skip to content

docs(contracts): align the YAML registry and the prose docs into one registry - #146

Open
cryptoxdog wants to merge 2 commits into
mainfrom
docs/contract-alignment
Open

docs(contracts): align the YAML registry and the prose docs into one registry#146
cryptoxdog wants to merge 2 commits into
mainfrom
docs/contract-alignment

Conversation

@cryptoxdog

Copy link
Copy Markdown
Collaborator

Summary

contracts/ (24 machine-readable YAMLs) and docs/contracts/ (20 prose docs) were two halves of one registry that had drifted apart. This makes them a single registry split by concern — YAML owns identity and wiring, Markdown owns prose — and adds a blocking drift gate so they cannot diverge silently again.

What was broken:

  • verification.test pointed at test files, so a contract could lose its test class and still look verified.
  • No YAML named the doc describing it, so there was no machine-checkable link between the two folders.
  • Seven contracts (C-10, 11, 15, 18, 20, 21, 22) had no prose doc at all.
  • Contracts 21–24 had no test class.
  • Several docs referenced modules that do not exist here: l9.core, l9.memory, chassis.metrics.

Changes

Area Change
contracts/*.yaml verification.test is now a pytest node ID; every contract carries a docs: pointer; scanner_rules populated and corrected
docs/contracts/ 7 new docs; 10 partial docs expanded to cover their contract
tests/contracts/test_contract_registry.py New — blocking drift gate
tests/contracts/test_contracts.py TestContract2124 added; all 24 contracts now have a test class
tools/verify_contracts.py Reads docs: from YAML on top of its literal floor list; also checks AGENTS.md for wiring
tools/contract_scanner.py STUB-001/002/003 registered for the zero-stub protocol, scoped to engine/
tools/contract_report.py Splits node IDs on :: when checking test existence

Two contradictions resolved against the code

Both were cases where the docs asserted something the code does not do. Resolved in favor of the code:

  • Gate count is 10, not 14. GateType in engine/config/schema.py has 10 members. Agent files claiming 14 were updated.
  • Both logging.getLogger and structlog.get_logger satisfy CONTRACT-04. The enforced invariant is that the engine never configures logging, not which getter it calls. engine/ uses stdlib in ~80 modules and structlog in a handful; OBSERVABILITY.md had prescribed structlog exclusively. There is also no structlog.configure() anywhere in chassis/ — noted in the doc as a chassis gap, not something to fix from engine/.

The STUB-001 scope was also narrowed to engine/: abstract base classes in chassis/ raise NotImplementedError as their defining contract, which is intended use, not a stub.

Test plan

  • pytest tests/ — 1749 passed, 35 skipped, 56 xfailed, 0 failures
  • ruff check . and ruff format --check . — clean
  • tools/verify_contracts.py — 27 docs present and wired
  • tools/contract_scanner.py — no violations
  • tools/contract_report.py — 24/24 contracts have a resolvable test class

Deliberately out of scope

Makefile and docs/contracts/README.md had unrelated uncommitted work in the same hunks, so they were left out to keep this reviewable. Two follow-ups remain:

  • Wire tools/contract_report.py into make agent-check.
  • Update the doc count in docs/contracts/README.md (still says 20; there are now 27).

…registry

The 24 machine-readable contracts in contracts/ and the 20 prose docs in
docs/contracts/ had drifted: YAML pointed at test files rather than test
classes, no YAML named the doc that described it, seven contracts had no
prose at all, and several docs referenced modules (l9.core, l9.memory,
chassis.metrics) that do not exist in this repo.

Splits ownership by concern -- YAML owns identity and wiring, Markdown owns
prose -- and adds tests/contracts/test_contract_registry.py as a blocking
drift gate so the two cannot diverge again silently.

- contracts/*.yaml: verification.test is now a pytest node ID; every contract
  names its docs; scanner_rules populated and corrected
- 7 new docs (C-10, 11, 15, 18, 20, 21, 22) plus 10 partial docs expanded
- TestContract21-24 added; all 24 contracts now have a test class
- verify_contracts.py reads docs: from YAML on top of its literal floor list,
  and now also checks AGENTS.md for wiring
- STUB-001/002/003 registered for the zero-stub protocol, scoped to engine/
  (chassis ABCs legitimately raise NotImplementedError)
- resolved two contradictions against the code: gate count is 10, not 14;
  both logging.getLogger and structlog.get_logger satisfy CONTRACT-04, since
  the enforced invariant is that the engine never configures logging
- contract_report.py now splits node IDs on '::' when checking test existence

1749 passed, 0 failures. ruff and mypy clean.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown

Too Many Reviewable Files Changed
Changed: 66 files
Limit: 50 files
Action Required: Split into multiple focused PRs

PR Too Large
Reviewable lines changed: 1782
Limit: 1000 lines
Action Required: Break into smaller, atomic PRs

📋 Best Practices for Large Changes

  1. Refactoring + Features: Separate into 2 PRs
  2. Multiple Features: One PR per feature
  3. Database + Code: Separate migration from logic
  4. Generated Code: Exclude it from reviewable-size accounting

🚫 This PR is blocked until reviewable size limits are met.

steps:
# fetch-depth is irrelevant here, but the checkout must be a real git repo:
# discovery enumerates via `git ls-files -z`, not a filesystem walk.
- uses: actions/checkout@v6
# fetch-depth is irrelevant here, but the checkout must be a real git repo:
# discovery enumerates via `git ls-files -z`, not a filesystem walk.
- uses: actions/checkout@v6
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install pyyaml
- run: python tools/l9_meta_injector.py check
steps:
# fetch-depth is irrelevant here, but the checkout must be a real git repo:
# discovery enumerates via `git ls-files -z`, not a filesystem walk.
- uses: actions/checkout@v6
# fetch-depth is irrelevant here, but the checkout must be a real git repo:
# discovery enumerates via `git ls-files -z`, not a filesystem walk.
- uses: actions/checkout@v6
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install pyyaml
- run: python tools/l9_meta_injector.py check
@cryptoxdog

Copy link
Copy Markdown
Collaborator Author

Does this belong in https://github.com/Quantum-L9/Cursor-Governance?

Adds the CONTRACT-24 resilience section, the contract-suite run commands,
and the chassis_app.py path corrections that the registry alignment left
unapplied in the prose docs.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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