Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
9ef51d1
fix(docker): install git for VCS deps, fix poetry prod install, align…
cryptoxdog Jul 23, 2026
fea9047
docs: add GitHub org-ruleset diagnostic command log
cryptoxdog Jul 23, 2026
012c01f
docs(contracts): align the YAML registry and the prose docs into one …
cryptoxdog Jul 24, 2026
02f6681
chore(template): drop .suite6-config.json from the scaffold
cryptoxdog Jul 24, 2026
dc91397
fix(docker): gate the healthcheck on readiness, not just HTTP 200
cryptoxdog Jul 27, 2026
42c0259
docs(contracts): fold prose docs onto the aligned registry
cryptoxdog Jul 27, 2026
fb5d402
fix(docker): gate the prod healthcheck on readiness, not just a 200
cryptoxdog Jul 27, 2026
fe791e2
feat: dual-chassis SDK migration, research pattern wiring, contract docs
cryptoxdog Jul 28, 2026
4912e76
fix: merge main; LLM key-before-import; resolve DEFERRED/spec_extract…
cryptoxdog Aug 1, 2026
093e7db
fix: merge main; keep 27-contract agent-check wording
cryptoxdog Aug 1, 2026
e174519
fix(ci): remediate shared pipeline signals CI-001/003/004/005
cryptoxdog Aug 1, 2026
575b74e
fix(ci): install contract deps; use l9_meta dry-run (no invalid check…
cryptoxdog Aug 1, 2026
8cbeb1d
Merge remote-tracking branch 'origin/docs/contract-alignment' into fi…
cryptoxdog Aug 1, 2026
e670df3
fix(ci): drop semgrep --error so governance can gate findings
cryptoxdog Aug 1, 2026
04829fc
Merge remote-tracking branch 'origin/fix/ci-pipeline-signals' into fi…
cryptoxdog Aug 1, 2026
b5630f2
fix(tests): SDK gate-only preflight + ingress expectations; LLM key o…
cryptoxdog Aug 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .claude/rules/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ paths:
- "chassis/**/*.py"
- "tools/**/*.py"
---

# CEG Contracts (1–24)

Enforced by `tools/contract_scanner.py` and `tools/verify_contracts.py`.
Expand All @@ -14,7 +15,7 @@ Enforced by `tools/contract_scanner.py` and `tools/verify_contracts.py`.
| 1 | Single Ingress | Only POST /v1/execute and GET /v1/health. Engine NEVER imports FastAPI/Starlette. |
| 2 | Handler Interface | `async def handle_*(tenant: str, payload: dict) -> dict`. handlers.py is the ONLY engine file importing chassis (plus boot.py). |
| 3 | Tenant Isolation | Tenant resolved BY chassis. Every Neo4j query scopes to tenant database. No cross-tenant reads. |
| 4 | Observability Inherited | Engine NEVER configures structlog/Prometheus. Uses `structlog.get_logger(__name__)` only. |
| 4 | Observability Inherited | Engine NEVER configures structlog/Prometheus. Logger getter is `logging.getLogger(__name__)` or `structlog.get_logger(__name__)`. |
| 5 | Infrastructure is Template | Engine NEVER creates Dockerfile, docker-compose, CI pipeline. All in l9-template. |

## Layer 2 — Packet Protocol (6–8)
Expand Down Expand Up @@ -44,7 +45,7 @@ Enforced by `tools/contract_scanner.py` and `tools/verify_contracts.py`.
| # | Name | Rule |
|---|------|------|
| 17 | Test Requirements | Unit for pure functions, integration with testcontainers-neo4j, compliance for prohibited factors, <200ms p95. |
| 18 | L9_META Headers | Every file carries L9_META header. Injected by tools/l9_meta_injector.py. |
| 18 | L9_META Headers | Every tracked file carries an L9_META header (schema v2). Values resolve from `l9-meta.yaml` by path — write with `tools/l9_meta_injector.py apply`, verify with `check`, never hand-edit a header. |

## Layer 6 — Graph Intelligence (19–20)
| # | Name | Rule |
Expand Down
38 changes: 26 additions & 12 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Made By: Igor Beylin
# --- L9_META ---
# l9_schema: 1
# l9_schema: 2
# origin: l9-template
# engine: graph
# layer: [agent-rules]
# tags: [L9_TEMPLATE, agent-rules, cursor]
# owner: platform
# tags: [governance]
# status: active
# --- /L9_META ---
# Made By: Igor Beylin
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# SESSION BOOTSTRAP — EXECUTE THIS BLOCK ON EVERY NEW CHAT WINDOW
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Expand Down Expand Up @@ -68,7 +67,7 @@
# dimensions, GDS jobs, KGE embeddings, community detection.
#
# @docs/L9_Contract_Enforcement_System.md
# How contract_scanner.py + verify_contracts.py enforce the 20 contracts.
# How contract_scanner.py + verify_contracts.py enforce the 24 contracts.
# Read before touching tools/ or .github/workflows/.
#
# ── TIER 4: ACTIVE DOMAIN SPEC (always in context) ──────────────────────────
Expand All @@ -84,7 +83,7 @@
#
# ── TIER 5: CONTRACT DOCS (load only the relevant one before touching a subsystem)
#
# docs/contracts/ directory contains the 20 contract files.
# docs/contracts/ directory contains the 27 contract docs.
# Do NOT bulk-load all of them. Load the specific file for the subsystem
# you are about to modify:
#
Expand All @@ -93,6 +92,7 @@
# @docs/contracts/CYPHER_SAFETY.md
# @docs/contracts/BANNED_PATTERNS.md
# @docs/contracts/PYDANTIC_YAML_MAPPING.md
# @docs/contracts/BIDIRECTIONAL_MATCHING.md
#
# Before touching engine/handlers.py or chassis/:
# @docs/contracts/HANDLER_PAYLOADS.md
Expand All @@ -113,6 +113,8 @@
# Before touching engine/compliance/:
# @docs/contracts/OBSERVABILITY.md
# @docs/contracts/MEMORY_SUBSTRATE_ACCESS.md
# @docs/contracts/PROHIBITED_FACTORS.md
# @docs/contracts/PII_HANDLING.md
#
# Before touching domains/ or domain spec versioning:
# @docs/contracts/DOMAIN_SPEC_VERSIONING.md
Expand All @@ -122,9 +124,21 @@
# Before touching .env.template or env var naming:
# @docs/contracts/ENV_VARS.md
#
# Before touching engine/config/settings.py or gating a behavior change:
# @docs/contracts/FEATURE_FLAG_DISCIPLINE.md
#
# Before touching engine/scoring/ or engine/boot.py:
# @docs/contracts/SCORING_WEIGHT_CEILING.md
#
# Before touching engine/kge/:
# @docs/contracts/KGE_EMBEDDINGS.md
#
# Before adding any new tracked file:
# @docs/contracts/L9_META_HEADERS.md
#
# ── INVARIANT CHECKS (verify silently on load) ───────────────────────────────
#
# 1. GateType enum = exactly 14 values (contract 13)
# 1. GateType enum = exactly 10 values (contract 13)
# 2. ScoringAssembler = exactly 4 active dimensions (contract 13)
# 3. No PR marked BLOCKED in workflow_state.md for the branch being worked on
# 4. Task about to be started does NOT appear in DEFERRED.md
Expand All @@ -136,7 +150,7 @@
# Do not guess its contents. Do not proceed without it.
#
# ============================================================================
# 20 contracts. Violate any → revert and ask.
# 24 contracts. Violate any → revert and ask.
# ============================================================================

# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Expand Down Expand Up @@ -429,7 +443,7 @@
# DEL-002 requests.post/get/etc (in engine/) → contract 8
# MEM-001 INSERT INTO packetstore (in engine/) → contract 7
# MEM-002 INSERT INTO memory_embeddings (in engine/) → contract 7
# STUB-001 raise NotImplementedError (outside tests/) → zero-stub protocol
# STUB-001 raise NotImplementedError (in engine/) → zero-stub protocol
#
# HIGH — merge blocked:
# ERR-001 bare except: → error handling
Expand All @@ -441,8 +455,8 @@
# SHARED-001 class PacketEnvelope (redefining) → contract 7
# SHARED-002 class TenantContext (redefining) → contract 3
# SHARED-003 class ExecuteRequest (redefining) → contract 1
# STUB-002 # TODO comment → zero-stub protocol
# STUB-003 # PLACEHOLDER comment → zero-stub protocol
# STUB-002 # TODO comment (in engine/) → zero-stub protocol
# STUB-003 # PLACEHOLDER/FIXME/XXX comment (in engine/) → zero-stub protocol
# PKT-001 uppercase packet_type value → contract 7
# ENV-001 non-L9_ env var name for infra vars → convention

Expand All @@ -454,7 +468,7 @@
# 1. PRE-COMMIT → ruff, mypy --strict, contract_scanner.py, verify_contracts.py
# 2. CI LINT → same as pre-commit, repo-wide
# 3. CI TESTS → pytest (unit + integration + compliance + performance)
# 4. CI AUDIT → verify_contracts.py (all 20 contract files exist + wired)
# 4. CI AUDIT → verify_contracts.py (all 27 contract docs exist + wired)
# 5. LLM REVIEW → CodeRabbit + Qodo + Claude (contract-aware instructions)
#
# Branch protection: all 5 required status checks. No bypass.
Expand Down
61 changes: 58 additions & 3 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# --- L9_META ---
# l9_schema: 1
# l9_schema: 2
# origin: l9-template
# engine: graph
# layer: [ci]
# tags: [L9_TEMPLATE, ci, audit, harness]
# owner: platform
# tags: [delivery, harness]
# status: active
Comment on lines 1 to 7
# --- /L9_META ---
name: L9 Audit Harness
Expand All @@ -14,6 +13,10 @@
push:
branches: [main]

permissions:
contents: read
pull-requests: write

jobs:
audit:
runs-on: ubuntu-latest
Expand All @@ -35,3 +38,55 @@
with:
name: l9-audit-reports
path: artifacts/

- name: Post harness report to PR
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
const marker = '<!-- l9-audit-harness -->';
const reportPath = 'artifacts/harness_report.md';
const pr = context.payload.pull_request;

let report;
try {
report = fs.readFileSync(reportPath, 'utf8');
} catch (err) {
report = '⚠️ Audit harness did not produce a report at `' + reportPath +
'`. Check the [workflow run](' +
`https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` +
') for details.';
}

const maxLen = 60000;
if (report.length > maxLen) {
report = report.slice(0, maxLen) + '\n\n...(truncated — see workflow run artifacts for the full report)';
}
const body = `${marker}\n${report}`;

const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
per_page: 100
});
const botComment = [...comments].reverse().find(c =>
c.user.type === 'Bot' && c.body.includes(marker)
);

if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body
});
}
25 changes: 20 additions & 5 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# --- L9_META ---
# l9_schema: 1
# l9_schema: 2
# origin: l9-template
# engine: graph
# layer: [ci]
# tags: [L9_TEMPLATE, ci, contracts]
# owner: platform
# tags: [delivery, harness]
# status: active
# --- /L9_META ---
# L9 Contract Enforcement — 20 contracts as hard gates
# L9 Contract Enforcement — 24 invariants / 27 docs as hard gates
# Blocks merge on missing contract files or scanner violations.

name: Contract Enforcement
Expand Down Expand Up @@ -35,6 +34,7 @@
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- run: pip install -r requirements-ci.txt

Check warning on line 37 in .github/workflows/contracts.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Using dependencies without locking resolved versions is security-sensitive.

See more on https://sonarcloud.io/project/issues?id=Quantum-L9_Cognitive.Engine.Graphs&issues=AZ-_Rmn4ETN2Y3sJ-rtF&open=AZ-_Rmn4ETN2Y3sJ-rtF&pullRequest=151

Check warning on line 37 in .github/workflows/contracts.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--only-binary :all:" can lead to the execution of setup scripts. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=Quantum-L9_Cognitive.Engine.Graphs&issues=AZ-_Rmn4ETN2Y3sJ-rtE&open=AZ-_Rmn4ETN2Y3sJ-rtE&pullRequest=151
- run: python tools/verify_contracts.py

contract-scan:
Expand All @@ -45,8 +45,23 @@
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- run: pip install -r requirements-ci.txt

Check warning on line 48 in .github/workflows/contracts.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--only-binary :all:" can lead to the execution of setup scripts. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=Quantum-L9_Cognitive.Engine.Graphs&issues=AZ-_SO85-CkDYWncFL_5&open=AZ-_SO85-CkDYWncFL_5&pullRequest=151

Check warning on line 48 in .github/workflows/contracts.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Using dependencies without locking resolved versions is security-sensitive.

See more on https://sonarcloud.io/project/issues?id=Quantum-L9_Cognitive.Engine.Graphs&issues=AZ-_SO85-CkDYWncFL_6&open=AZ-_SO85-CkDYWncFL_6&pullRequest=151
- run: python tools/contract_scanner.py

meta-headers:
name: Verify L9_META Headers
runs-on: ubuntu-latest
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
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install pyyaml

Check warning on line 61 in .github/workflows/contracts.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Using dependencies without locking resolved versions is security-sensitive.

See more on https://sonarcloud.io/project/issues?id=Quantum-L9_Cognitive.Engine.Graphs&issues=AZ-_Rmn4ETN2Y3sJ-rtH&open=AZ-_Rmn4ETN2Y3sJ-rtH&pullRequest=151

Check warning on line 61 in .github/workflows/contracts.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--only-binary :all:" can lead to the execution of setup scripts. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=Quantum-L9_Cognitive.Engine.Graphs&issues=AZ-_Rmn4ETN2Y3sJ-rtG&open=AZ-_Rmn4ETN2Y3sJ-rtG&pullRequest=151
# Default mode is dry-run verification; there is no `check` subcommand.
- run: python tools/l9_meta_injector.py
Comment on lines +61 to +63

lint:
name: Lint + Type Check
runs-on: ubuntu-latest
Expand All @@ -63,7 +78,7 @@
test:
name: Test Suite
runs-on: ubuntu-latest
needs: [contract-files, contract-scan, lint]
needs: [contract-files, contract-scan, meta-headers, lint]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v7
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/l9-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@ jobs:
set -euo pipefail
pip install --upgrade pip semgrep
mkdir -p "artifacts/raw/semgrep/${L9_MATRIX_ID}"
# No `|| true` (Baseline Ratchet rejects fail-open). Also no
# `--error`: findings must reach normalize/publish so governance
# can decide blocking vs advisory; `--error` exits 1 before that.
semgrep scan \
--config p/python \
--json \
--output "artifacts/raw/semgrep/${L9_MATRIX_ID}/report.json" \
--error --quiet || true
--quiet
env:
L9_MATRIX_ID: ${{ env.L9_MATRIX_ID }}

Expand Down
18 changes: 8 additions & 10 deletions .github/workflows/l9-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,16 @@ jobs:
- name: mypy
run: |
set -euo pipefail
# mkdir required before --install-types on a cold cache, else mypy
# fails with the misleading "no mypy cache directory" error and
# masks any real type errors underneath it (python/mypy#10768).
# Align with make lint / ci.yml / ci-quality.yml: type-check engine/
# only. mypy on SOURCE_DIR=. dual-maps tools/auditors and fails closed
# before any engine diagnostics are useful.
mkdir -p .mypy_cache
MYPY_EXCLUDE_ARGS=()
if [ -n "${MYPY_EXCLUDE}" ]; then
MYPY_EXCLUDE_ARGS=(--exclude "${MYPY_EXCLUDE}")
fi
mypy "${SOURCE_DIR}" \
"${MYPY_EXCLUDE_ARGS[@]}" \
mypy engine/ \
--config-file=pyproject.toml \
--ignore-missing-imports \
--exclude chassis \
--show-error-codes --pretty \
--install-types --non-interactive --ignore-missing-imports
--install-types --non-interactive

test:
name: Test Suite
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/supply-chain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ jobs:
uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0
with:
fail-on-severity: high
# dependency-review-action rejects specifying both allow-licenses and
# deny-licenses. Keep the allow-list (stricter); deny-list is implied.
allow-licenses: ${{ vars.ALLOWED_LICENSES || 'MIT, Apache-2.0, BSD-3-Clause, BSD-2-Clause, ISC' }}
deny-licenses: ${{ vars.DENIED_LICENSES || 'GPL-3.0, AGPL-3.0' }}
comment-summary-in-pr: on-failure

# ────────────────────────────────────────────────────────────────────────
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ secrets.json

# l9-ci-sdk runtime checkout (provisioned by tools/packet_envelope_gate.py)
.l9/runtime/
.venv-py312-mypy/
17 changes: 16 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ repos:
language: system
pass_filenames: false

# L9 contract enforcement (20 contracts)
# L9 contract enforcement (24 invariants, 27 docs)
- repo: local
hooks:
- id: l9-contract-scan
Expand All @@ -95,6 +95,21 @@ repos:
pass_filenames: false
always_run: true

# L9_META headers (Contract C-018) — resolves every tracked file against
# l9-meta.yaml. always_run because a rule edit changes the expected values
# for files that are not themselves staged.
- repo: local
hooks:
- id: l9-meta-check
name: L9_META Header Check
entry: python tools/l9_meta_injector.py check
language: python
# pre-commit builds an isolated venv, so l9-meta.yaml parsing needs
# pyyaml declared here — it is not inherited from the repo environment.
additional_dependencies: [pyyaml]
pass_filenames: false
always_run: true

# Audit harness (architecture + spec coverage + contract wiring)
- repo: local
hooks:
Expand Down
Loading
Loading