refactor: implement governed Delivery program contracts

This commit is contained in:
jarvis-at-skic committed 2026-10-23 06:39:27 +00:00
1 parent c306ea4794
commit 65e546c448
18 files changed
+575 -99

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
"""Exact, reversible skill-identity migration; never rewrite provenance URLs."""
import re
IDENTITIES = {
'development-branching-strategy-aerosim': 'development-branching-strategy-skic-aerosim',
'development-scripts-aerosim': 'development-scripts-skic-aerosim',
'devsecops-ci-cd-gitea-aerosim': 'devsecops-ci-cd-gitea-skic-aerosim',
'documentation-docusaurus-aerosim': 'documentation-docusaurus-skic-aerosim',
'development-gitops-argo-cd-gondor-v1': 'development-gitops-argo-cd-home-gondor-v1',
'home-v1-discord': 'discord',
'home-v1--truenas': 'truenas',
}
def translate(text, mapping):
# Bare discord/truenas are common words: only migrate explicit skill identity
# delimiters (inline code, quoted names, and related_skills list entries).
pattern = r'(?P<left>`|[\"\'])(?P<name>' + '|'.join(map(re.escape, mapping)) + r')(?=[`\"\'\],])'
text = re.sub(pattern, lambda m: m['left'] + mapping[m['name']], text)
return re.sub(r'(?m)^( related_skills: \[)(.*)(\])$',
lambda m: m[1] + ', '.join(mapping.get(v, v) for v in m[2].split(', ')) + m[3], text)
def canonicalize(text):
return translate(text, IDENTITIES)
def original_identity(text):
return translate(text, {new: old for old, new in IDENTITIES.items()})
+77
View File
@@ -0,0 +1,77 @@
[
{
"path": "references/task-delivery-gates.md",
"pattern": "^5\\. After local checks pass,.*$",
"hashes": [
"e4e6ae6f894fdb0b5dc1779b7037c39eb476ee80620f93a253c4a68ea4adabd1"
]
},
{
"path": "references/task-delivery-gates.md",
"pattern": "^6\\. (?:The active executor|Hermes main session) reviews.*$",
"hashes": [
"63acb91e7391daac3af378032e4842ef7da6d03ff1f1939016180f9fffb5f86c"
]
},
{
"path": "references/task-delivery-gates.md",
"pattern": "^2\\. Immediately before merge,.*$",
"hashes": [
"fb6968a7bea4662e945ca914c53988cc1d9d72b02681384f7041a89ad347c229"
]
},
{
"path": "references/task-delivery-gates.md",
"pattern": "^3\\. If conflict resolution,.*$",
"hashes": [
"6052be5ba307b088499acdc0abcecbea36719695f423e6e9b888027d85867e89"
]
},
{
"path": "references/task-delivery-gates.md",
"pattern": "^\\*\\*Exit gate:\\*\\* All required PR CI.*$",
"hashes": [
"ff18fe3b523dae671eb14f513e1f90700eeea9c8a93bf85686f67b8f9635e7f3"
]
},
{
"path": "references/task-delivery-gates.md",
"pattern": "^\\*\\*Exit gate:\\*\\* Every required post-merge.*$",
"hashes": [
"9338b15f03aa46139240842a0c72c92fd3af2d91e1af4ee82c55fe859361d196"
]
},
{
"path": "references/task-delivery-gates.md",
"pattern": "^### Stage [1-6].*$",
"hashes": [
"50a5e09da6aca1488d9d375c22740b39c0168837bde39bb390352186f7982d6d",
"fc758ac75b342cceb555b927710c0aba38ca31fd6bdbca4eb7ed054f814c2f38",
"f68e0313b622ef7666bccd0c6bd9551153e01e2b8f6cc68978a4dda72924c45a",
"156eb690576a1a812c3fb7d32ee32fb98c174c81143830a336ca4ec54dd27745",
"4a76eda13fa68c5f28b458d5d1ad400211c4daad5418b3f3319c36b84ade03b2",
"960be6948de8a23e4591cfa099c9cf30e47f2b1b72f8702f05c6d7dd1713bfd7"
]
},
{
"path": "references/status-and-reporting.md",
"pattern": "(?s)## Scope Status Vocabulary.*",
"hashes": [
"0aa256d5852c664c0d18b3888990d6c31e73a4e50e894324e1d11cb72a970b93"
]
},
{
"path": "references/failure-and-documentation.md",
"pattern": "(?s)When a build or CI failure is observed:.*?(?=5\\. )",
"hashes": [
"d7850a4ca34226dd9b45badc1623012e87a2557f3cced4b63807939be00a72f5"
]
},
{
"path": "references/failure-and-documentation.md",
"pattern": "(?s)7\\. run local validation;.*?(?=## Documentation Ownership)",
"hashes": [
"13e74d3dd90a757a7a7d0ef7f0a4448cb6a7764b7c63ce8699b40f197fbac6fa"
]
}
]
+97
View File
@@ -0,0 +1,97 @@
{
"owners": {
"preflight": {
"owner": "development-scripts",
"reference": "references/runtime-preflight.md",
"source_url": "https://gitea.lego-cloud.eu/global-skills/development-scripts",
"inspected_head": "0e36552938da94c0539e39b35256b8effe34c25d",
"sha256": "07306382b8afe5c2d2e83e2955a04a1523d008e7e39cead7c7a1797bb6640462",
"state": "merged source and installed reference byte-identical; authenticated immutable full-package readback verified",
"evidence_text": "# Exact-context toolchain preflight\n\nUse before repository commands in a Node/pnpm repository, or any command that may invoke Node or pnpm. This is a reusable execution procedure, not a project directory convention or permission to run tests. The caller supplies the authorized repository, revision, worker context, required environment names and permitted operation. Task-directory containment and stop-on-failed-preflight remain caller responsibilities.\n\n## Required inputs\n\nLoad `development-monorepo-pnpm` and its `references/workspace-and-tooling.md` tooling reference for version selection and committed toolchain/workspace conventions. Resolve required Node and pnpm versions from the repository's **committed toolchain contract**, not ambient executables. Inspect the selected revision's package-manager pin, Node declaration and applicable locked environment/image metadata. Do not invent a universal version or workspace layout. If declarations conflict, are absent, or leave the required exact version unresolved, stop and reconcile the contract with its owner before running the requested command. A version range alone is not an exact observed-version pin.\n\n## Procedure\n\nTreat every foreground shell, detached worktree, background process, main-session review command and CI job as a separate execution context. A successful check elsewhere is not transferable evidence. Perform inspection/preflight in the intended context before the requested repository operation; inspection commands themselves are necessary to establish the context.\n\n1. Resolve the required versions from the committed toolchain contract at the expected source revision. Record the paths/revision used, not secret content.\n2. Inside that exact shell/process/container run `command -v node`, `node --version`, `command -v pnpm`, and `pnpm --version`, using `terminal` or the equivalent job step. Require every command to succeed; compare observed versions to the resolved required versions (normalize only Node's leading `v`). An executable found in a different shell is not sufficient. Record executable paths and observed/required versions.\n3. Verify required non-secret environment variable names are present, including disposable-test database markers when applicable, **without reading or printing their values**. For Bash, a presence-only `[[ -v VARIABLE_NAME ]]` check is suitable after validating a supplied name against `[A-Za-z_][A-Za-z0-9_]*`. Do not dump `env`, expand indirect values, enable tracing, or read credentials. Presence alone does not prove resource isolation or authorize database use; that remains the caller's separate gate.\n4. Verify the actual working directory and repository root; compare source HEAD and linked branch/PR identity with caller-supplied expected identity. Inspect repository state and confirm it is clean or intentionally staged, with every intentional change accounted for. Detached HEAD is allowed only when it matches the authorized revision/worktree. Never reset/stash unrelated changes to make a check green. Do not assume a project-specific application layout.\n5. Start the original command only after every applicable check passes. Keep activation, verification and execution in the same context. Recheck if PATH, activation, working directory, revision, image or required environment changes. A background worker must do its own preflight within its launch command, not consume a foreground success flag.\n\n## Failure and repair\n\nNever assume a background process inherits `PATH`, shell activation, Devbox state, Corepack activation, database variables or other exports from a foreground terminal. Missing `pnpm` is an execution-context/toolchain failure, **never an application-code or test failure**. Missing Node, wrong versions, wrong working directory/revision and absent required names also block execution; they do not constitute product RED.\n\nRepair the exact context by providing the required toolchain path or approved activation. Do not silently install a latest toolchain, rewrite pins, or execute Devbox unless the parent workflow permits it. Then **repeat the complete preflight** there and rerun the original command before making a claim about repository code. Preserve failure and rerun evidence separately.\n\n## Verification and scope\n\nRecord expected/observed versions, executable paths, repository root/revision, branch/PR link, approved state, presence-only results, context identity and command outcome. Do not include secrets or environment values. Local narrow validation never replaces all-app CI or exact-head remote job evidence. Toolchain success is not a claim of CI, publication, deployment or runtime acceptance.\n\nRun the owner contract regression with `terminal(command=\"python3 scripts/test_preflight_contract.py\", workdir=\"<skill-repository>\")`. This checks maintained guidance, not a live consumer toolchain; the five steps above must still be exercised for each real conLine truncated
},
"base_images": {
"owner": "devsecops-ci-cd-gitea",
"reference": "references/base-images.md",
"source_url": "https://gitea.lego-cloud.eu/global-skills/devsecops-ci-cd-gitea",
"inspected_head": "669e28eadfe79ac7cb3c10ccdea318dd5296d481",
"sha256": "1fb0e24ec5789b195be9ae35fbb9529fa1cab56112dae5baf9455284ca490e53",
"state": "merged source and installed reference byte-identical; authenticated immutable full-package readback verified",
"evidence_text": "# Reusable CI base-image contract\n\nUse when stable runtimes or OS tools would otherwise be downloaded repeatedly in application jobs. This owner defines reusable construction, validation, publication and consumption mechanics; it does not choose a project's image repository, branch, application layout or runtime-smoke authority. Supply those bindings from the project Delivery/CI overlay. Runtime verification is a separate acceptance layer delegated to the project's authorized runtime-test owner, not permission granted by this reference.\n\nRead [pipeline-workflow.md](pipeline-workflow.md) for trust boundaries, exact checkout and immutable retries, and [harbor-auth.md](harbor-auth.md) for credential handling. These safeguards apply in addition to this contract; base-image work is not an exemption.\n\n## Construction and static contract\n\n1. Keep one folder per image containing a Dockerfile, machine-readable version/platform metadata, usage documentation, a build helper and a static publication contract. Record required upstream reference, platforms, runtime/tool pins, numeric user/group and supported workspace path. Do not prescribe a product's application directories.\n2. Pin the upstream base by digest (`repository@sha256:<64 lowercase hexadecimal characters>`). Check the actual resolved platform against metadata; for a multi-platform index, record index and platform-manifest relationships rather than silently comparing unlike digests.\n3. Assert exact runtime/tool versions, architecture, numeric non-root identity, writable workspace, CA trust, Git, shell and every other required tool. Static/unit checks inspect Dockerfile and metadata; they cannot alone prove live writability, effective UID, trust or executable behavior. The authorized runtime verifier must exercise those assertions on the **published digest** and record results separately. Never describe a static declaration as runtime proof.\n4. Prefer the verified job image over repeated `actions/setup-node` or package-manager bootstrap steps. Keep `pnpm install --frozen-lockfile --ignore-scripts` in the application repository for lockfile parity; do not bake project dependencies or credentials into a generic base image. This does not waive the consumer's committed toolchain contract or exact-context preflight in `development-scripts/references/runtime-preflight.md`.\n\n## Candidate isolation and trusted publication\n\n- Build and perform static/unit validation on pull requests **without registry credentials**. Credential absence must be structural: no publication secret in workflow-global scope, candidate job environment, persistent runner home, Docker config, build args, cache or artifact. Skipping login does not remove an already available credential. Use an approved credential-free base acquisition path; if unavailable, stop rather than leak publication credentials to candidates.\n- Choose exactly one configured default integration branch, as in the pipeline owner (`test` or `main`), and publish only its exact trusted integration commit. PR, fork, branch-readiness and broad tag triggers cannot publish. Separately authorized release workflows must retain equivalent isolation, never broaden the ordinary candidate path.\n- Complete candidate execution before introducing a narrowly scoped Harbor robot secret in the isolated trusted publication job. Pass secrets via standard input only. Keep temporary Docker/Helm credential stores scoped to the job, clean on success and failure, and treat logout failure on persistent runners as failure after cleanup. Never pre-seed push credentials into the reusable job image or execute untrusted candidate hooks after authentication.\n\n## Immutable publication and direct readback\n\n1. Verify checkout identity before building. Tag the image with the full 40-character source revision; never publish `latest`, mutable version aliases or shortened SHAs for governed consumption. Enforce registry immutable-tag rules as well as workflow checks.\n2. Preserve the validated local image ID. Existing tags are reusable only when the remote OCI config digest equals that validated local image ID; different content is a hard failure, not an overwrite. For multiple platforms, verify each required platform's config identity and expected manifest/index membership. Missing or ambiguous remote evidence fails closed.\n3. After publication, read back the Harbor artifact directly: verify reference, source identity, platform and manifest digest. Record source URL/revision, workflow run/attempt/job, immutable tag, manifest digest, config digest/local image ID and canonical millisecond ISO-8601 UTC timestamp. Config digest is for retry content comparison; manifest digest is for consumption. Do not interchange either with source SHA or chart archive checksum.\n4. Require the final aggregate under `always()` to explicitly require every necessary build/publication/readback job's success. A green push step or skipped aggrLine truncated
}
},
"moved_clauses": [
{
"clause": "version resolution, executable/version comparisons",
"owner_key": "preflight",
"section": "Required inputs; Procedure 1\u20132"
},
{
"clause": "presence-only environment and repository identity/state checks",
"owner_key": "preflight",
"section": "Procedure 3\u20134"
},
{
"clause": "same-context activation, inheritance failure classification and complete retry",
"owner_key": "preflight",
"section": "Procedure 5; Failure and repair"
},
{
"clause": "image folder/metadata, digest/tool/platform/user/workspace/trust assertions and lockfile parity",
"owner_key": "base_images",
"section": "Construction and static contract"
},
{
"clause": "credential-free candidates and isolated trusted publication",
"owner_key": "base_images",
"section": "Candidate isolation and trusted publication"
},
{
"clause": "full-source tags, direct Harbor readback, immutable retry and aggregates",
"owner_key": "base_images",
"section": "Immutable publication and direct readback"
},
{
"clause": "digest consumer verification and forward repair mechanics",
"owner_key": "base_images",
"section": "Consumer verification and forward repair"
},
{
"clause": "negative trigger/tag/secret/interpolation/digest/setup regression cases",
"owner_key": "base_images",
"section": "Fail-closed regression matrix"
}
],
"retained_local": [
"every foreground shell",
"detached worktree",
"background process",
"worker",
"Hermes main-session review command",
"CI job",
"Stop on failed preflight",
"selected Task directory",
"selected repository",
"allowed command scope",
"complete repository CI",
"last known-good digest",
"trusted `test` branch",
"UAT",
"exact PR-head SHA"
],
"superseded_golden_rules": [
{
"path": "references/runtime-and-ci.md",
"pattern": "(?s)### Per-project reusable CI base images\\n.*?(?=### Gondor)",
"hashes": [
"0c92e0521c57c357a62c8313c70527547427d98b7647ec8cd1a97c148b5ba4f1"
]
},
{
"path": "references/runtime-and-ci.md",
"pattern": "(?s)Treat every foreground shell.*?(?=### Immutable|### Per-project)",
"hashes": [
"8df9d2e952a6a8c48fd3d0a18357aea21d5ffbb1e06e53c7273c6e50e2545be5"
]
}
]
}
+1 -1
View File
@@ -39,7 +39,7 @@ class LessonsContract(unittest.TestCase):
def test_contract_1(self):
text = (ROOT / 'SKILL.md').read_text()
self.assertIn('<code>-uat', text)
self.assertIn('version: 1.14.2', text)
self.assertIn('version: 1.15.0', text)
def test_stage_five_scope_and_authority(self):
text = (ROOT / "references/task-delivery-gates.md").read_text()
+47
View File
@@ -0,0 +1,47 @@
"""Canonical bindings preserve owners and original checksum sensitivity."""
from pathlib import Path
import hashlib
import re
import subprocess
import unittest
from canonical_identity import IDENTITIES, canonicalize, original_identity
ROOT = Path(__file__).resolve().parents[1]
class CanonicalIdentity(unittest.TestCase):
def test_exact_identity_and_dependency_count(self):
current = (ROOT / 'SKILL.md').read_text()
baseline = subprocess.check_output(['git', 'show', 'HEAD:SKILL.md'], cwd=ROOT, text=True)
def deps(text):
return re.search(r'related_skills: \[(.*?)\]', text)[1].split(', ')
expected = [IDENTITIES.get(v, v) for v in deps(baseline)]
self.assertEqual(deps(current), expected)
self.assertEqual(len(expected), 18 if ROOT.name.endswith('aerosim') else 12)
self.assertEqual(len(set(expected)), len(expected))
self.assertIn('corp-v1-glossary', expected)
self.assertFalse(set(expected) & set(IDENTITIES))
def test_mapping_is_reversible_and_not_a_general_rewrite(self):
self.assertEqual(len(IDENTITIES), len(set(IDENTITIES.values())))
for old, new in IDENTITIES.items():
text = f'Load `{old}`; skill_view(name="{old}"); https://example/{old}; /opt/data/{old}/'
mapped = canonicalize(text)
self.assertIn(f'`{new}`', mapped)
self.assertEqual(original_identity(mapped), text)
text = 'tags: [corp-v1, discord, channel] /opt/data/corp-v1-aerosim-delivery/ gondor-v1-aerosim-dev'
self.assertEqual(original_identity(text), text)
def test_golden_normalization_still_detects_policy_mutation(self):
for old in IDENTITIES:
baseline = f'Load `{old}` before mutation; stop if unavailable.'
canonical = canonicalize(baseline)
digest = lambda t: hashlib.sha256(original_identity(t).encode()).hexdigest()
self.assertEqual(digest(canonical), digest(baseline))
self.assertNotEqual(digest(canonical.replace('stop', 'continue')), digest(baseline))
def test_no_legacy_operational_loads(self):
for path in [ROOT / 'SKILL.md', *ROOT.glob('references/*.md')]:
text = path.read_text()
self.assertEqual(canonicalize(text), text, str(path))
if __name__ == '__main__':
unittest.main()
+2 -2
View File
@@ -12,7 +12,7 @@ REFERENCES = {
"development-branching-strategy": "https://gitea.lego-cloud.eu/home-v1-skills-code-agent/development-branching-strategy",
"development-monorepo-pnpm": "https://gitea.lego-cloud.eu/home-v1-skills-code-agent/development-monorepo-pnpm",
"development-scripts": "https://gitea.lego-cloud.eu/home-v1-skills-code-agent/development-scripts",
"development-gitops-argo-cd-gondor-v1": "https://gitea.lego-cloud.eu/home-v1-skills-code-agent/development-gitops-argo-cd-gondor-v1",
"development-gitops-argo-cd-home-gondor-v1": "https://gitea.lego-cloud.eu/home-v1-skills-code-agent/development-gitops-argo-cd-gondor-v1",
}
@@ -30,5 +30,5 @@ def test_generic_automation_is_owned_by_development_scripts() -> None:
def test_gitops_reference_requires_one_environment_per_repository() -> None:
assert "development-gitops-argo-cd-gondor-v1" in RUNTIME
assert "development-gitops-argo-cd-home-gondor-v1" in RUNTIME
assert "one repository per environment" in RUNTIME
+55
View File
@@ -0,0 +1,55 @@
"""Full-program consolidation: owner routing and retained policy safeguards."""
from pathlib import Path
import unittest
from canonical_identity import original_identity
ROOT=Path(__file__).resolve().parents[1]
def read(p): return (ROOT/p).read_text()
class FullProgram(unittest.TestCase):
def test_exact_owner_loads_replace_duplicate_algorithms(self):
p=read('references/planning-artifact-reconciliation.md')
for s in ['skill_view(name="development-gates")','skill_view(name="development-integrity")','exact Task row','historical','no second Focus-admission','run_number','head.ref']:
self.assertIn(s,p)
self.assertNotIn('Require each matching task to report',p)
self.assertLess(len(p.encode()),5000)
g=read('references/task-delivery-gates.md')
self.assertIn('skill_view(name="development-gates")',g)
self.assertNotIn('first when practical',g)
self.assertNotIn('seven project channels',g)
self.assertIn('A02/A04',g)
for i in range(1,7): self.assertIn(f'GATE_{i:03}_',g)
def test_storage_and_ttd_decision_loads(self):
r=read('references/runtime-and-ci.md')
self.assertIn('references/gondor-retained-application-storage.md',r)
self.assertIn('before storage design or mutation',r.lower())
self.assertNotIn('before fixing when practical',r)
self.assertIn('development-method-ttd',r)
self.assertIn('isolated, unpublished experimental delta',r)
self.assertIn('historical missing RED',r)
self.assertNotIn('5. implement the smallest safe fix;\n6. add/update tests',read('references/failure-and-documentation.md'))
self.assertIn('last known-good digest',r)
self.assertIn('every foreground shell',r)
def test_clause_disposition_covers_program_without_inventing_resolution(self):
p=read('FULL-PROGRAM.md')
for i in range(1,19): self.assertIn(f'| A{i:02} |',p)
for s in ['1563064779772526616','unresolved','installed','publication','A02','A04','A06','A08','A17']:
self.assertIn(s,p)
def test_original_protected_clauses_remain_exact(self):
import re, json, hashlib
for rule in json.loads((Path(__file__).parent/'full-program-preserved.json').read_text()):
matches=re.findall(rule['pattern'],original_identity(read(rule['path'])),re.M)
self.assertEqual([hashlib.sha256(m.encode()).hexdigest() for m in matches],rule['hashes'],rule['path']+' '+rule['pattern'])
def test_project_specific_boundaries(self):
if not (ROOT/'references/single-subagent-task-delivery.md').exists(): return
w=read('references/single-subagent-task-delivery.md')
self.assertNotIn('│ ├── playwright/',w)
self.assertNotIn('│ ├── postgresql/',w)
self.assertIn('belong to UAT',w)
g=read('references/task-delivery-gates.md')
self.assertIn('per Task',g)
self.assertNotIn('or start the next Task before',g)
c=read('references/gitea-actions-policy.md')
for s in ['skill_view(name="devsecops-ci-cd-gitea-skic-aerosim")','references/pipeline-workflow.md','CI / Branch Readiness','CI / Pull Request Validation','CD / Test Artifact Publication','publication','UAT','all applications']:
self.assertIn(s,c)
self.assertNotIn('## 1. Non-default branch',c)
self.assertLess(len(c.encode()),3200)
if __name__=='__main__': unittest.main()
+39
View File
@@ -0,0 +1,39 @@
"""Moved owner mechanics and retained caller authority, independently runnable."""
from pathlib import Path
import hashlib
import json
import unittest
ROOT = Path(__file__).resolve().parents[1]
class OwnerConsolidation(unittest.TestCase):
def test_owner_evidence_and_clause_mapping(self):
manifest=json.loads((Path(__file__).parent/'owner-consolidation-manifest.json').read_text())
self.assertEqual(len(manifest['superseded_golden_rules']),2)
self.assertEqual(len(manifest['moved_clauses']),8)
for owner in manifest['owners'].values():
self.assertEqual(hashlib.sha256(owner['evidence_text'].encode()).hexdigest(),owner['sha256'])
self.assertEqual(len(owner['inspected_head']),40)
for move in manifest['moved_clauses']:
text=manifest['owners'][move['owner_key']]['evidence_text']
for heading in move['section'].split('; '):
self.assertIn('## '+heading.split(' 1')[0].split(' 3')[0].split(' 5')[0],text)
pre=manifest['owners']['preflight']['evidence_text']
for term in ['command -v node','pnpm --version','without reading or printing their values','linked branch/PR identity','repeat the complete preflight','never an application-code or test failure']:
self.assertIn(term,pre)
base=manifest['owners']['base_images']['evidence_text']
for term in ['without registry credentials','full 40-character source revision','shell interpolation','wrong upstream or consumer digests','pnpm install --frozen-lockfile --ignore-scripts','numeric non-root identity','CA trust','last known-good digest']:
self.assertIn(term,base)
def test_exact_decision_loads_and_local_boundaries(self):
text=(ROOT/'references/runtime-and-ci.md').read_text()
manifest=json.loads((Path(__file__).parent/'owner-consolidation-manifest.json').read_text())
for owner in manifest['owners'].values():
self.assertIn('skill_view(name="'+owner['owner']+'", file_path="'+owner['reference']+'")',text)
for clause in manifest['retained_local']:
self.assertIn(clause,text)
for clause in ['before every repository operation','Node/pnpm repository','CORP_V1_','publication/install','immutable owner revision','forward only','replacement image and consuming workflow pass exact-head CI']:
self.assertIn(clause,text)
self.assertNotIn('neither owner currently replaces',text)
self.assertNotIn('1. resolve the repository-required Node',text)
self.assertNotIn('- Keep one folder per image',text)
repo='corp-v1-aerosim/corp-v1-aerosim-base-images' if ROOT.name.endswith('aerosim') else 'corp-v1-<code>/corp-v1-<code>-base-images'
self.assertIn(repo,text)
if __name__=='__main__': unittest.main()
+5 -5
View File
@@ -22,7 +22,7 @@ class SimplificationContract(unittest.TestCase):
def test_decision_point_loads(self):
for name, markers in {
'SKILL.md': ['Before login, load', 'skic-skills/channel-board-skic', 'version: 1.14.2'],
'SKILL.md': ['Before login, load', 'skic-skills/channel-board-skic', 'version: 1.15.0'],
'references/runtime-and-ci.md': ['Before login, load', 'Load `development-method-ttd`', 'Load `development-monorepo-pnpm`'],
'references/status-and-reporting.md': ['Before reporting, load', 'home-v1-skills-code-agent/development-integrity'],
'references/planning-artifact-reconciliation.md': ['corepack enable --install-directory', 'Before reporting, load'],
@@ -40,15 +40,15 @@ class SimplificationContract(unittest.TestCase):
for marker in ['wave-previous:', 'List every Task', 'GATE_003_TASK_IMPLEMENTATION', 'status unverified', 'exact failed command']:
self.assertIn(marker, status)
planning = (ROOT / 'references/planning-artifact-reconciliation.md').read_text()
for marker in ['each matching task', 'run_number', 'semantics', 'If the PR merged or closed', 'no second Focus-admission', 'configured silent response']:
for marker in ['complete successful job inventory including aggregates', 'run_number', 'semantics', 'If the PR merged or closed', 'no second Focus-admission', 'configured silent response']:
self.assertIn(marker, planning)
def test_operational_size_reduction(self):
paths = [ROOT / 'SKILL.md', *ROOT.glob('references/*.md')]
self.assertLess(sum(len(p.read_bytes()) for p in paths), BASELINE_BYTES)
DEPS = ' related_skills: [channel-board-skic, home-v1-discord, documentation-docusaurus, corp-v1-glossary, development-durable-wave-execution, development-gates, development-integrity, development-method-ttd, development-branching-strategy, development-monorepo-pnpm, development-scripts, development-gitops-argo-cd-gondor-v1]'
PROTECTED = {'references/task-delivery-gates.md': '9d803be17cf6254c7ea938e3899d58f25784c294f351d3485a20bdf4be18f597', 'references/repository-entry-and-visibility.md': 'f040d6f57c4ec5faf4527296f7f71a751fab2153809e2dbe20c90cf2d582a77d', 'references/common-pitfalls.md': '41c3b5cc88227b7402f52777f329c3fb9b891954dabee36dfd639f2bf27795a1', 'references/aerosim-lessons-review.md': '03873d038f146e28ea648c95f7c2e32d2648d1b5eaa963fb635980fe6e814514'}
DEPS = ' related_skills: [channel-board-skic, discord, documentation-docusaurus, corp-v1-glossary, development-durable-wave-execution, development-gates, development-integrity, development-method-ttd, development-branching-strategy, development-monorepo-pnpm, development-scripts, development-gitops-argo-cd-home-gondor-v1]'
PROTECTED = {'references/repository-entry-and-visibility.md': 'f040d6f57c4ec5faf4527296f7f71a751fab2153809e2dbe20c90cf2d582a77d', 'references/aerosim-lessons-review.md': '03873d038f146e28ea648c95f7c2e32d2648d1b5eaa963fb635980fe6e814514'}
REFERENCES = {'task-delivery-gates.md', 'common-pitfalls.md', 'failure-and-documentation.md', 'runtime-and-ci.md', 'repository-entry-and-visibility.md', 'aerosim-lessons-review.md', 'planning-artifact-reconciliation.md', 'status-and-reporting.md'}
SECTIONS = {('references/runtime-and-ci.md', '### Execution-context toolchain preflight', None): '87a1bdc8c00bdd9f4ad975703bec81f9c9affd26edcfc939f936a7556e7bfa39', ('references/runtime-and-ci.md', '## Channel-owned workspace', '## Shared Corp'): '48d1e74b737db691ec31ac593400d59abc7d4eed4cd67b2f12f8a428a48034b5', ('references/failure-and-documentation.md', '## Failure-Repair Workflow', '## Documentation Ownership'): 'fb6a08666ffcba086984d5437b2d89ce5c7961c007c50e59e1f07f41ea384db1', ('SKILL.md', '## Authority and Escalation', '## Evidence Requirements'): 'e3c566055d9d04d3ab0286e6e5035a8c30f66a81b17b4d0379e8010dead3fa83'}
SECTIONS = {('references/runtime-and-ci.md', '## Channel-owned workspace', '## Shared Corp'): '48d1e74b737db691ec31ac593400d59abc7d4eed4cd67b2f12f8a428a48034b5', ('SKILL.md', '## Authority and Escalation', '## Evidence Requirements'): 'e3c566055d9d04d3ab0286e6e5035a8c30f66a81b17b4d0379e8010dead3fa83'}
BASELINE_BYTES = 84789
+45
View File
@@ -0,0 +1,45 @@
"""Run every unittest, standalone test function and main-style contract."""
from pathlib import Path
import importlib.util
import inspect
import json
import re
import subprocess
import sys
import unittest
ROOT=Path(__file__).resolve().parents[1]
TESTS=Path(__file__).resolve().parent
sys.path.insert(0, str(TESTS))
suite=unittest.TestSuite()
modules=[]
for path in sorted(TESTS.glob('test_*.py')):
spec=importlib.util.spec_from_file_location('verify_'+path.stem,path)
assert spec is not None and spec.loader is not None
module=importlib.util.module_from_spec(spec)
sys.modules[spec.name]=module
spec.loader.exec_module(module)
modules.append(module)
suite.addTests(unittest.defaultTestLoader.loadTestsFromModule(module))
result=unittest.TextTestRunner(verbosity=1).run(suite)
if not result.wasSuccessful(): sys.exit(1)
standalone=0
for module in modules:
for name,fn in inspect.getmembers(module,inspect.isfunction):
if name.startswith('test_') or name=='main':
fn()
standalone+=1
files=[ROOT/'SKILL.md',*sorted(ROOT.glob('references/*.md'))]
links=0
for path in files:
for link in re.findall(r'\]\(([^)]+)\)',path.read_text()):
if '://' in link or link.startswith(('#','<')): continue
target=link.split('#')[0]
if target:
assert (path.parent/target).exists(),(path,link)
links+=1
subprocess.run(['git','diff','--check'],cwd=ROOT,check=True)
before=sum(len(subprocess.check_output(['git','show','HEAD:'+str(p.relative_to(ROOT))],cwd=ROOT)) for p in files)
after=sum(p.stat().st_size for p in files)
ref_before=before-len(subprocess.check_output(['git','show','HEAD:SKILL.md'],cwd=ROOT))
ref_after=after-(ROOT/'SKILL.md').stat().st_size
print(json.dumps({'package':ROOT.name,'unittest':result.testsRun,'standalone':standalone,'total':result.testsRun+standalone,'local_links':links,'diff_check':'passed','operational_bytes_before':before,'operational_bytes_after':after,'reference_bytes_before':ref_before,'reference_bytes_after':ref_after},indent=2))