afyx-engineering-kit 0.0.0-stage → 0.1.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/.afyx-source-revision +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +377 -2
  4. package/SECURITY.md +74 -0
  5. package/afyx-context/LICENSE +21 -0
  6. package/afyx-context/README.md +155 -0
  7. package/afyx-context/afyx-context.json +30 -0
  8. package/afyx-context/contracts/integration-v1.schema.json +34 -0
  9. package/afyx-context/package-lock.json +53 -0
  10. package/afyx-context/package.json +34 -0
  11. package/afyx-context/scripts/benchmark.mjs +39 -0
  12. package/afyx-context/scripts/build.mjs +15 -0
  13. package/afyx-context/scripts/comparative-benchmark.mjs +342 -0
  14. package/afyx-context/scripts/comparative-worker.mjs +74 -0
  15. package/afyx-context/scripts/graph-integration-e2e.mjs +188 -0
  16. package/afyx-context/scripts/integrated-dogfood.mjs +309 -0
  17. package/afyx-context/src/budget.js +166 -0
  18. package/afyx-context/src/cli.js +110 -0
  19. package/afyx-context/src/coordination.js +343 -0
  20. package/afyx-context/src/engine.js +198 -0
  21. package/afyx-context/src/errors.js +14 -0
  22. package/afyx-context/src/graph-integration-worker.js +70 -0
  23. package/afyx-context/src/graph-integration.js +373 -0
  24. package/afyx-context/src/graph-mcp-bridge.js +103 -0
  25. package/afyx-context/src/index.js +25 -0
  26. package/afyx-context/src/integrations.js +87 -0
  27. package/afyx-context/src/memory.js +255 -0
  28. package/afyx-context/src/storage.js +364 -0
  29. package/afyx-context/test-fixtures/coordination-worker.mjs +52 -0
  30. package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/__init__.py +1 -0
  31. package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/__manifest__.py +4 -0
  32. package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/models/__init__.py +1 -0
  33. package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/models/sale_order.py +5 -0
  34. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/__init__.py +1 -0
  35. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/__manifest__.py +10 -0
  36. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/__init__.py +2 -0
  37. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/sale_order.py +20 -0
  38. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/sale_order_audit.py +11 -0
  39. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/security/ir.model.access.csv +2 -0
  40. package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/views/sale_order_views.xml +14 -0
  41. package/afyx-forge/LICENSE +55 -0
  42. package/afyx-forge/README.md +126 -0
  43. package/afyx-forge/afyx-forge.json +28 -0
  44. package/afyx-forge/bin/afyx-forge +4 -0
  45. package/afyx-forge/bin/afyx-forge.cmd +3 -0
  46. package/afyx-forge/bin/afyx-forge.js +16 -0
  47. package/afyx-forge/contracts/forge-plan-v1.schema.json +172 -0
  48. package/afyx-forge/package.json +26 -0
  49. package/afyx-forge/src/classifier.js +190 -0
  50. package/afyx-forge/src/cli.js +111 -0
  51. package/afyx-forge/src/doctor.js +105 -0
  52. package/afyx-forge/src/guidance.js +120 -0
  53. package/afyx-forge/src/index.js +273 -0
  54. package/afyx-forge/src/planning.js +107 -0
  55. package/afyx-forge/src/policy.js +109 -0
  56. package/afyx-forge/src/workflow-refiner.js +151 -0
  57. package/afyx-graph/afyx-graph.json +20 -0
  58. package/afyx-graph/engine/LICENSE +21 -0
  59. package/afyx-graph/engine/README.md +104 -0
  60. package/afyx-graph/engine/release/RELEASE-MANIFEST.json +21 -0
  61. package/afyx-graph/engine/release/SHA256SUMS +2 -0
  62. package/afyx-graph/engine/release/afyx-graph-linux-x64.tar.gz +0 -0
  63. package/afyx-graph/engine/release/afyx-graph-win32-x64.zip +0 -0
  64. package/afyx-graph/engine/scripts/distribution-contract.mjs +212 -0
  65. package/afyx-graph/engine/scripts/distribution-product.json +33 -0
  66. package/bin/afyx-engineering-kit.mjs +61 -0
  67. package/install.ps1 +1053 -0
  68. package/install.sh +617 -0
  69. package/package.json +66 -4
  70. package/scripts/afyx-capability-orchestrator.mjs +752 -0
  71. package/scripts/afyx-claude-integration.mjs +547 -0
  72. package/scripts/afyx-context-artifact.mjs +105 -0
  73. package/scripts/afyx-credential-broker.mjs +75 -0
  74. package/scripts/afyx-doctor.ps1 +152 -0
  75. package/scripts/afyx-doctor.sh +146 -0
  76. package/scripts/afyx-forge-artifact.mjs +183 -0
  77. package/scripts/afyx-global-routing-policy.md +12 -0
  78. package/scripts/afyx-global-routing.mjs +168 -0
  79. package/scripts/afyx-graph-artifact.mjs +178 -0
  80. package/scripts/afyx-host-adapters.mjs +543 -0
  81. package/scripts/afyx-host-bridge-lifecycle.mjs +174 -0
  82. package/scripts/afyx-host-bridge.mjs +288 -0
  83. package/scripts/afyx-integration-contracts.mjs +825 -0
  84. package/scripts/afyx-mcp-integration.mjs +528 -0
  85. package/scripts/afyx-modular-integration.mjs +361 -0
  86. package/scripts/afyx-modular-runtime.mjs +451 -0
  87. package/scripts/afyx-native-skill-host.mjs +124 -0
  88. package/scripts/afyx-npm-installer.mjs +486 -0
  89. package/scripts/afyx-project.ps1 +205 -0
  90. package/scripts/afyx-project.sh +207 -0
  91. package/scripts/afyx-provider-backup.mjs +1206 -0
  92. package/scripts/afyx-provider-integration.mjs +724 -0
  93. package/scripts/afyx-provider-inventory.mjs +147 -0
  94. package/scripts/afyx-security-auditor.mjs +224 -0
  95. package/scripts/afyx-skill-engineering.mjs +354 -0
  96. package/scripts/afyx-tool-family-routing.mjs +64 -0
  97. package/scripts/afyx-universal-runtime.mjs +530 -0
  98. package/scripts/alpha_acceptance_preflight.py +240 -0
  99. package/scripts/benchmark-graph-memory.mjs +96 -0
  100. package/scripts/benchmark_capability_orchestrator.mjs +64 -0
  101. package/scripts/build-windows-installer.ps1 +259 -0
  102. package/scripts/build_forge_synthetic_image.py +328 -0
  103. package/scripts/check-reference-staleness.py +71 -0
  104. package/scripts/components.json +254 -0
  105. package/scripts/contracts/afyx-capability-request-v1.schema.json +189 -0
  106. package/scripts/contracts/afyx-capability-result-v1.schema.json +32 -0
  107. package/scripts/dogfood_engineering_comparison.mjs +303 -0
  108. package/scripts/engineering-assurance.json +28 -0
  109. package/scripts/install-afyx-context.ps1 +142 -0
  110. package/scripts/install-afyx-context.sh +126 -0
  111. package/scripts/install-afyx-forge.ps1 +265 -0
  112. package/scripts/install-afyx-forge.sh +273 -0
  113. package/scripts/install-afyx-graph.ps1 +571 -0
  114. package/scripts/install-afyx-graph.sh +438 -0
  115. package/scripts/install-codex-usage-tracker.ps1 +172 -0
  116. package/scripts/lib/AfyxComponents.psm1 +399 -0
  117. package/scripts/lib/AfyxSkillLifecycle.psm1 +289 -0
  118. package/scripts/lib/AfyxTerminal.psm1 +838 -0
  119. package/scripts/lib/afyx-components.sh +256 -0
  120. package/scripts/lib/afyx-skill-lifecycle.sh +271 -0
  121. package/scripts/link-global-dev.ps1 +193 -0
  122. package/scripts/link-global-dev.sh +130 -0
  123. package/scripts/phase8-paired-evidence.mjs +195 -0
  124. package/scripts/phase8-representative-workload.mjs +771 -0
  125. package/scripts/phase8-session-recorder.mjs +157 -0
  126. package/scripts/phase8_event_ledger.py +248 -0
  127. package/scripts/phase8_evidence_discovery.py +189 -0
  128. package/scripts/prepare-g6-package.mjs +349 -0
  129. package/scripts/resolve-git-release-artifacts.mjs +321 -0
  130. package/scripts/stage-npm-release.mjs +94 -0
  131. package/scripts/validate-afyx-graph.py +203 -0
  132. package/scripts/validate-components.py +194 -0
  133. package/scripts/validate-engineering-assurance.py +281 -0
  134. package/scripts/verify-graph-archive.mjs +64 -0
  135. package/skills/afyx-context/SKILL.md +26 -0
  136. package/skills/afyx-engineering-expert/README.md +42 -0
  137. package/skills/afyx-engineering-expert/SKILL.md +70 -0
  138. package/skills/afyx-engineering-expert/assets/result-template.md +15 -0
  139. package/skills/afyx-engineering-expert/references/ai-ml-engineer.md +17 -0
  140. package/skills/afyx-engineering-expert/references/business-analyst.md +17 -0
  141. package/skills/afyx-engineering-expert/references/clean-code-engineer.md +26 -0
  142. package/skills/afyx-engineering-expert/references/code-reviewer.md +24 -0
  143. package/skills/afyx-engineering-expert/references/cybersecurity-devsecops.md +17 -0
  144. package/skills/afyx-engineering-expert/references/data-analyst-bi.md +24 -0
  145. package/skills/afyx-engineering-expert/references/data-engineer.md +24 -0
  146. package/skills/afyx-engineering-expert/references/database-administrator.md +17 -0
  147. package/skills/afyx-engineering-expert/references/debugging-specialist.md +24 -0
  148. package/skills/afyx-engineering-expert/references/embedded-iot-engineer.md +24 -0
  149. package/skills/afyx-engineering-expert/references/erp-technical-specialist.md +17 -0
  150. package/skills/afyx-engineering-expert/references/hardware-diagnostics-auditor.md +24 -0
  151. package/skills/afyx-engineering-expert/references/hardware-electronics-engineer.md +24 -0
  152. package/skills/afyx-engineering-expert/references/integration-engineer.md +24 -0
  153. package/skills/afyx-engineering-expert/references/legacy-modernization-engineer.md +24 -0
  154. package/skills/afyx-engineering-expert/references/llmops-prompt-engineer.md +24 -0
  155. package/skills/afyx-engineering-expert/references/network-engineer.md +24 -0
  156. package/skills/afyx-engineering-expert/references/performance-benchmark-engineer.md +24 -0
  157. package/skills/afyx-engineering-expert/references/platform-engineer.md +24 -0
  158. package/skills/afyx-engineering-expert/references/product-manager.md +17 -0
  159. package/skills/afyx-engineering-expert/references/qa-engineer.md +17 -0
  160. package/skills/afyx-engineering-expert/references/site-reliability-engineer.md +17 -0
  161. package/skills/afyx-engineering-expert/references/software-engineer.md +17 -0
  162. package/skills/afyx-engineering-expert/references/solutions-architect.md +17 -0
  163. package/skills/afyx-engineering-expert/references/specialists-index.md +33 -0
  164. package/skills/afyx-engineering-expert/references/subject-matter-expert.md +17 -0
  165. package/skills/afyx-engineering-expert/references/system-analyst.md +17 -0
  166. package/skills/afyx-engineering-expert/references/technical-project-manager.md +24 -0
  167. package/skills/afyx-engineering-expert/references/technical-writer.md +24 -0
  168. package/skills/afyx-engineering-expert/references/ui-ux-designer.md +17 -0
  169. package/skills/afyx-engineering-expert/workflows/ai-data-erp.md +20 -0
  170. package/skills/afyx-engineering-expert/workflows/debugging.md +10 -0
  171. package/skills/afyx-engineering-expert/workflows/discovery-design.md +11 -0
  172. package/skills/afyx-engineering-expert/workflows/implementation.md +12 -0
  173. package/skills/afyx-engineering-expert/workflows/incident-reliability.md +12 -0
  174. package/skills/afyx-engineering-expert/workflows/review-audit.md +13 -0
  175. package/skills/afyx-forge/SKILL.md +43 -0
  176. package/skills/afyx-forge/references/adaptive-policy.md +19 -0
  177. package/skills/efficient-coding/SKILL.md +33 -0
  178. package/skills/efficient-coding/references/investigation.md +27 -0
  179. package/skills/efficient-coding/references/token-efficiency.md +25 -0
  180. package/skills/efficient-coding/references/tool-routing.md +13 -0
  181. package/skills/odoo-engineering/SKILL.md +33 -0
  182. package/skills/odoo-engineering/references/common.md +9 -0
  183. package/skills/odoo-engineering/references/odoo-10.md +32 -0
  184. package/skills/odoo-engineering/references/odoo-11.md +26 -0
  185. package/skills/odoo-engineering/references/odoo-12.md +31 -0
  186. package/skills/odoo-engineering/references/odoo-13.md +27 -0
  187. package/skills/odoo-engineering/references/odoo-14.md +31 -0
  188. package/skills/odoo-engineering/references/odoo-15.md +34 -0
  189. package/skills/odoo-engineering/references/odoo-16.md +37 -0
  190. package/skills/odoo-engineering/references/odoo-17.md +37 -0
  191. package/skills/odoo-engineering/references/odoo-18.md +48 -0
  192. package/skills/odoo-engineering/references/odoo-19.md +43 -0
  193. package/skills/odoo-engineering/references/odoo-20.md +39 -0
  194. package/skills/odoo-engineering/references/reference-schema.md +16 -0
  195. package/skills/odoo-engineering/references/version-detection.md +13 -0
  196. package/tools/codex-usage/CodexUsage.psm1 +496 -0
  197. package/tools/codex-usage/codex-usage-doctor.ps1 +150 -0
  198. package/tools/codex-usage/codex-usage-pricing.json +25 -0
  199. package/tools/codex-usage/codex-usage-stop.ps1 +167 -0
  200. package/tools/codex-usage/codex-usage-watch.ps1 +250 -0
  201. package/tools/codex-usage/vscode-user-task.json +31 -0
  202. package/tools/windows-setup/SetupBootstrapper.cs +258 -0
  203. package/uninstall.ps1 +189 -0
  204. package/uninstall.sh +167 -0
  205. package/update.ps1 +95 -0
  206. package/update.sh +67 -0
  207. package/verify.ps1 +411 -0
  208. package/verify.sh +265 -0
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env node
2
+ // Build an npm candidate from committed source without stamping the checkout.
3
+ import { spawnSync } from 'node:child_process';
4
+ import { createHash } from 'node:crypto';
5
+ import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, statSync, writeFileSync } from 'node:fs';
6
+ import { tmpdir } from 'node:os';
7
+ import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { buildGraphReleaseArtifacts, checkGraphReleaseValid } from './prepare-g6-package.mjs';
10
+
11
+ const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
12
+ const args = process.argv.slice(2);
13
+ const dryRun = args.includes('--dry-run');
14
+ const outputIndex = args.indexOf('--output-dir');
15
+ const outputDir = outputIndex >= 0 && args[outputIndex + 1] ? resolve(args[outputIndex + 1])
16
+ : mkdtempSync(join(tmpdir(), 'afyx-npm-release-'));
17
+ if (outputIndex >= 0 && !args[outputIndex + 1]) throw new Error('--output-dir requires a path');
18
+ if (args.some((arg, index) => arg !== '--dry-run' && arg !== '--output-dir' && index !== outputIndex + 1)) {
19
+ throw new Error('Usage: node scripts/stage-npm-release.mjs [--dry-run] [--output-dir PATH]');
20
+ }
21
+ const inside = relative(root, outputDir);
22
+ if (!inside.startsWith('..') && !isAbsolute(inside)) throw new Error('Release output must be outside the source checkout');
23
+
24
+ function run(command, commandArgs, options = {}) {
25
+ const result = spawnSync(command, commandArgs, { encoding: 'utf8', maxBuffer: 32 * 1024 * 1024,
26
+ timeout: 10 * 60 * 1000, windowsHide: true, ...options });
27
+ if (result.error || result.status !== 0) {
28
+ throw new Error(`${command} failed (${result.status ?? result.error?.code}): ${(result.stderr || result.error?.message || '').trim()}`);
29
+ }
30
+ return result.stdout;
31
+ }
32
+
33
+ function npmCommand() {
34
+ if (process.env.npm_execpath && existsSync(process.env.npm_execpath)) return process.env.npm_execpath;
35
+ const candidate = process.platform === 'win32'
36
+ ? join(dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js')
37
+ : join(dirname(process.execPath), '..', 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js');
38
+ if (!existsSync(candidate)) throw new Error('Installed npm CLI could not be located');
39
+ return candidate;
40
+ }
41
+
42
+ const revision = run('git', ['-C', root, 'rev-parse', 'HEAD']).trim();
43
+ if (!/^[0-9a-f]{40}$/.test(revision)) throw new Error('Invalid committed source revision');
44
+ if (run('git', ['-C', root, 'status', '--porcelain']).trim()) {
45
+ throw new Error('Source checkout has uncommitted files; release candidate requires a clean commit');
46
+ }
47
+ if (!checkGraphReleaseValid(root, revision)) {
48
+ if (process.env.AFYX_BUILD_FROM_SOURCE !== '1') {
49
+ throw new Error(`Graph release artifacts do not match ${revision}; set AFYX_BUILD_FROM_SOURCE=1 for an authorized maintainer build`);
50
+ }
51
+ buildGraphReleaseArtifacts(root, revision);
52
+ }
53
+ if (!checkGraphReleaseValid(root, revision)) throw new Error('Graph release artifacts remain incomplete');
54
+
55
+ mkdirSync(outputDir, { recursive: true });
56
+ const stage = mkdtempSync(join(outputDir, 'source-'));
57
+ const archive = join(stage, 'committed-source.tar');
58
+ run('git', ['-C', root, 'archive', '--format=tar', `--output=${archive}`, revision]);
59
+ run('tar', ['-xf', archive, '-C', stage]);
60
+ writeFileSync(join(stage, '.afyx-source-revision'), `${revision}\n`, 'utf8');
61
+ const release = join('afyx-graph', 'engine', 'release');
62
+ mkdirSync(join(stage, release), { recursive: true });
63
+ for (const name of ['afyx-graph-win32-x64.zip', 'afyx-graph-linux-x64.tar.gz', 'SHA256SUMS', 'RELEASE-MANIFEST.json']) {
64
+ const source = join(root, release, name);
65
+ if (!statSync(source).isFile()) throw new Error(`Missing regular Graph artifact: ${name}`);
66
+ copyFileSync(source, join(stage, release, name));
67
+ }
68
+
69
+ const npmArgs = [npmCommand(), 'pack', '--json', '--pack-destination', outputDir];
70
+ if (dryRun) npmArgs.push('--dry-run');
71
+ const result = JSON.parse(run(process.execPath, npmArgs, { cwd: stage }));
72
+ const pkg = result[0];
73
+ if (!pkg?.filename || !Array.isArray(pkg.files)) throw new Error('npm pack did not return a valid inventory');
74
+ const fileNames = new Set(pkg.files.map((file) => file.path));
75
+ for (const required of ['.afyx-source-revision', 'bin/afyx-engineering-kit.mjs',
76
+ `${release.replaceAll('\\', '/')}/RELEASE-MANIFEST.json`,
77
+ `${release.replaceAll('\\', '/')}/afyx-graph-win32-x64.zip`,
78
+ `${release.replaceAll('\\', '/')}/afyx-graph-linux-x64.tar.gz`]) {
79
+ if (!fileNames.has(required)) throw new Error(`Incomplete npm package: ${required}`);
80
+ }
81
+ const candidate = join(outputDir, pkg.filename);
82
+ if (!dryRun) {
83
+ if (!statSync(candidate).isFile()) throw new Error('npm tarball was not produced');
84
+ const marker = run('tar', ['-xOzf', candidate, 'package/.afyx-source-revision']).trim();
85
+ const manifest = JSON.parse(run('tar', ['-xOzf', candidate,
86
+ 'package/afyx-graph/engine/release/RELEASE-MANIFEST.json']));
87
+ if (marker !== revision || manifest.source_revision !== revision) {
88
+ throw new Error('Packed source marker or Graph manifest does not match committed source');
89
+ }
90
+ }
91
+ if (run('git', ['-C', root, 'status', '--porcelain']).trim()) throw new Error('Packaging mutated the source checkout');
92
+ const digest = dryRun ? null : createHash('sha256').update(readFileSync(candidate)).digest('hex');
93
+ process.stdout.write(JSON.stringify({ revision, version: pkg.version, dryRun, candidate: dryRun ? null : candidate,
94
+ sha256: digest, fileCount: pkg.files.length, stage }) + '\n');
@@ -0,0 +1,203 @@
1
+ #!/usr/bin/env python3
2
+ """Static Afyx Graph identity, metadata and attribution validation.
3
+
4
+ Zero-token and deterministic: reads repository files only. No network, no model
5
+ calls, no build. The canonical product identity is declared once in
6
+ afyx-graph/engine/src/product.ts; this script proves the operational metadata,
7
+ package manifest and CLI entry all agree with it.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ import re
14
+ import tarfile
15
+ import zipfile
16
+ from pathlib import Path
17
+
18
+ ROOT = Path(__file__).resolve().parents[1]
19
+ GRAPH = ROOT / "afyx-graph"
20
+ ENGINE = GRAPH / "engine"
21
+ metadata_path = GRAPH / "afyx-graph.json"
22
+ package_path = ENGINE / "package.json"
23
+ ui_package_path = ENGINE / "ui" / "package.json"
24
+ product_path = ENGINE / "src" / "product.ts"
25
+ root_license_path = ROOT / "LICENSE"
26
+ engine_license_path = ENGINE / "LICENSE"
27
+ obsolete_legal_paths = (
28
+ GRAPH / "LICENSES" / "THIRD_PARTY_ENGINE_MIT.txt",
29
+ GRAPH / "THIRD_PARTY_NOTICES.md",
30
+ )
31
+ bundle_script_path = ENGINE / "scripts" / "build-bundle.sh"
32
+ archive_script_path = ENGINE / "scripts" / "deterministic-archive.mjs"
33
+ distribution_product_path = ENGINE / "scripts" / "distribution-product.json"
34
+ release_dir = ENGINE / "release"
35
+ installer_paths = (ROOT / "scripts" / "install-afyx-graph.ps1", ROOT / "scripts" / "install-afyx-graph.sh")
36
+ installer_legal_requirements = {
37
+ "install-afyx-graph.ps1": "@('bin\\afyx-graph.cmd', 'metadata.json', 'LICENSE')",
38
+ "install-afyx-graph.sh": "bin/afyx-graph metadata.json LICENSE",
39
+ }
40
+
41
+ # The product ships the current Afyx license only. Historical third-party
42
+ # attribution remains available in Git history and the Phase 5 evidence docs.
43
+ COPYRIGHT_LINE = "Copyright (c) 2026 Afyx"
44
+ LICENSE_MARKERS = (
45
+ "MIT License",
46
+ "Permission is hereby granted, free of charge",
47
+ "The above copyright notice and this permission notice shall be included in all",
48
+ 'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND',
49
+ )
50
+ EXPECTED_LEGAL_FILES = [{"source": "LICENSE", "bundlePath": "LICENSE"}]
51
+ OBSOLETE_LEGAL_NAMES = ("THIRD_PARTY_NOTICES.md", "THIRD_PARTY_ENGINE_MIT.txt")
52
+
53
+ REQUIRED_METADATA = {
54
+ "product_name",
55
+ "product_version",
56
+ "package",
57
+ "repository",
58
+ "cli",
59
+ "runtime_path",
60
+ "state_directory",
61
+ "database_filename",
62
+ "mcp_server",
63
+ "supported_platforms",
64
+ "license",
65
+ }
66
+
67
+
68
+ def fail(message: str) -> None:
69
+ raise SystemExit(f"Afyx Graph validation failed: {message}")
70
+
71
+
72
+ def product_constant(source: str, name: str) -> str:
73
+ match = re.search(rf"export const {name}\s*=\s*'([^']*)';", source)
74
+ if not match:
75
+ fail(f"src/product.ts does not declare {name} as a string constant")
76
+ return match.group(1)
77
+
78
+
79
+ metadata = json.loads(metadata_path.read_text(encoding="utf-8"))
80
+ package = json.loads(package_path.read_text(encoding="utf-8"))
81
+ ui_package = json.loads(ui_package_path.read_text(encoding="utf-8"))
82
+ product = product_path.read_text(encoding="utf-8")
83
+
84
+ missing = sorted(REQUIRED_METADATA - metadata.keys())
85
+ if missing:
86
+ fail(f"metadata missing: {', '.join(missing)}")
87
+ extra = sorted(metadata.keys() - REQUIRED_METADATA)
88
+ if extra:
89
+ fail(f"operational metadata must hold exactly the Afyx Graph fields; unexpected: {', '.join(extra)}")
90
+
91
+ if metadata["product_name"] != "Afyx Graph" or package["name"] != "@a5zero7/afyx-graph":
92
+ fail("product/package identity mismatch")
93
+ if metadata["package"] != package["name"]:
94
+ fail("metadata package differs from package.json name")
95
+ if metadata["product_version"] != package["version"]:
96
+ fail("metadata and package versions differ")
97
+ if ui_package["name"] != "@a5zero7/afyx-graph-ui" or ui_package["version"] != package["version"]:
98
+ fail("UI package identity/version mismatch")
99
+
100
+ # CLI: exactly one binary, generated at dist/bin/afyx-graph.js.
101
+ if package.get("bin") != {"afyx-graph": "./dist/bin/afyx-graph.js"}:
102
+ fail(f"package bin must expose only afyx-graph -> ./dist/bin/afyx-graph.js, got {package.get('bin')!r}")
103
+ if not (ENGINE / "src" / "bin" / "afyx-graph.ts").is_file():
104
+ fail("src/bin/afyx-graph.ts (CLI source) is missing")
105
+
106
+ # Canonical identity constants: product.ts is the single source of truth.
107
+ expected = {
108
+ "PRODUCT_NAME": metadata["product_name"],
109
+ "CLI_NAME": metadata["cli"],
110
+ "MCP_SERVER_NAME": metadata["mcp_server"],
111
+ "STATE_DIR_NAME": metadata["state_directory"],
112
+ "DATABASE_FILE_NAME": metadata["database_filename"],
113
+ }
114
+ for name, value in expected.items():
115
+ actual = product_constant(product, name)
116
+ if actual != value:
117
+ fail(f"product.ts {name}={actual!r} but metadata declares {value!r}")
118
+ if product_constant(product, "ENV_PREFIX") != "AFYX_GRAPH_":
119
+ fail("environment prefix must be AFYX_GRAPH_")
120
+ if product_constant(product, "MCP_TOOL_PREFIX") != metadata["mcp_server"] + "_":
121
+ fail("MCP tool prefix must be the MCP server name plus an underscore")
122
+ if metadata["state_directory"] != ".afyx-graph" or metadata["database_filename"] != "afyx-graph.db":
123
+ fail("state directory and database filename must be .afyx-graph / afyx-graph.db")
124
+
125
+ # The repository and engine package use one current Afyx MIT license.
126
+ license_text = root_license_path.read_text(encoding="utf-8")
127
+ if COPYRIGHT_LINE not in license_text:
128
+ fail(f"current copyright line {COPYRIGHT_LINE!r} is missing from root LICENSE")
129
+ for marker in LICENSE_MARKERS:
130
+ if marker not in license_text:
131
+ fail(f"MIT license text is incomplete: missing {marker!r}")
132
+ if license_text.splitlines() != engine_license_path.read_text(encoding="utf-8").splitlines():
133
+ fail("engine/LICENSE and root LICENSE must be identical")
134
+ for obsolete_path in obsolete_legal_paths:
135
+ if obsolete_path.exists():
136
+ fail(f"obsolete historical legal payload must not exist: {obsolete_path.relative_to(ROOT).as_posix()}")
137
+
138
+ # Every bundle must ship exactly the current Afyx license. The artifact plan is
139
+ # the source of truth and the shell must consume its legal-file staging command.
140
+ bundle_script = bundle_script_path.read_text(encoding="utf-8")
141
+ distribution_product = json.loads(distribution_product_path.read_text(encoding="utf-8"))
142
+ if distribution_product.get("releaseChannel") != "technical-alpha":
143
+ fail("distribution-product.json must identify the Technical Alpha release channel")
144
+ runtime = distribution_product.get("runtime", {})
145
+ if runtime != {
146
+ "name": "Node.js",
147
+ "ownership": "external_platform",
148
+ "executable": "node",
149
+ "minimumVersion": "22.5.0",
150
+ }:
151
+ fail(f"distribution runtime contract is invalid: {runtime!r}")
152
+ if package.get("engines", {}).get("node") != f">={runtime['minimumVersion']}":
153
+ fail("package engine floor differs from the distribution runtime contract")
154
+ for forbidden in ("nodejs.org/dist", "npm ci --omit=dev", '"$STAGE/node"', '"$STAGE/node.exe"'):
155
+ if forbidden in bundle_script:
156
+ fail(f"build-bundle.sh still owns a bundled runtime/dependency tree: {forbidden}")
157
+ if distribution_product.get("legalFiles") != EXPECTED_LEGAL_FILES:
158
+ fail("distribution-product.json must ship exactly root LICENSE as the current product license")
159
+ for installer in installer_paths:
160
+ installer_text = installer.read_text(encoding="utf-8")
161
+ if installer_legal_requirements[installer.name] not in installer_text:
162
+ fail(f"{installer.name} does not require LICENSE in a staged bundle")
163
+ for obsolete_name in OBSOLETE_LEGAL_NAMES:
164
+ if obsolete_name in installer_text:
165
+ fail(f"{installer.name} still references obsolete legal payload {obsolete_name}")
166
+ if "legal-files" not in bundle_script:
167
+ fail("build-bundle.sh does not consume the artifact plan's legal files")
168
+ if "npm run build:clean" not in bundle_script:
169
+ fail("build-bundle.sh must not reuse a stale dist directory")
170
+ if "deterministic-archive.mjs" not in bundle_script or not archive_script_path.is_file():
171
+ fail("build-bundle.sh does not use the deterministic archive writer")
172
+
173
+ # Any locally built bundle must contain the current license and no obsolete
174
+ # historical-only legal payload.
175
+ if release_dir.is_dir():
176
+ for archive in sorted(release_dir.glob("afyx-graph-*")):
177
+ if archive.suffix == ".zip":
178
+ with zipfile.ZipFile(archive) as bundle:
179
+ names = bundle.namelist()
180
+ elif archive.name.endswith(".tar.gz"):
181
+ with tarfile.open(archive) as bundle:
182
+ names = bundle.getnames()
183
+ else:
184
+ continue
185
+ normalized_names = [name.replace("\\", "/") for name in names]
186
+ root_licenses = [
187
+ name
188
+ for name in normalized_names
189
+ if len([part for part in name.split("/") if part not in ("", ".")]) == 2
190
+ and name.rstrip("/").endswith("/LICENSE")
191
+ ]
192
+ if len(root_licenses) != 1:
193
+ fail(f"{archive.name} does not contain root-level LICENSE")
194
+ for normalized in normalized_names:
195
+ basename = normalized.rstrip("/").rsplit("/", 1)[-1]
196
+ legal_candidate = (
197
+ basename.upper() in {"LICENSE", "NOTICE", "COPYING", "ATTRIBUTION"}
198
+ or "THIRD_PARTY" in basename.upper()
199
+ )
200
+ if legal_candidate and normalized not in root_licenses:
201
+ fail(f"{archive.name} contains obsolete or unexplained legal payload {normalized}")
202
+
203
+ print("Afyx Graph identity, metadata and legal payload: PASS")
@@ -0,0 +1,194 @@
1
+ #!/usr/bin/env python3
2
+ """Static validation of the Afyx component contract (scripts/components.json).
3
+
4
+ Zero-token and deterministic. Proves the single component truth is well formed,
5
+ readable by both the PowerShell module and the Bash library (one "key": "value"
6
+ per line), and consistent with the files the kit actually ships.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import json
12
+ import re
13
+ from pathlib import Path
14
+
15
+ ROOT = Path(__file__).resolve().parents[1]
16
+ CONTRACT = ROOT / "scripts" / "components.json"
17
+
18
+ TYPES = {"skill", "runtime", "toolset", "detected-cli"}
19
+ TIERS = {"core", "optional", "external"}
20
+ OWNERSHIP = {"afyx", "upstream", "external"}
21
+ OWNERSHIP_CLASSES = {"AFYX", "EXTERNAL", "USER"}
22
+ PRESETS = {"minimal", "recommended", "full", "custom"}
23
+ PLATFORMS = {"all", "windows"}
24
+ INSTALL_ROOTS = {"skills_root", "afyx_graph_root", "afyx_context_root", "afyx_forge_root", "codex_tools", ""}
25
+ REQUIRED_KEYS = {"id", "name", "type", "tier", "ownership", "ownership_class", "presets", "platforms", "install_root", "install_path"}
26
+ EXPECTED_IDS = ["efficient-coding", "odoo-engineering", "afyx-engineering-expert", "afyx-graph", "afyx-context", "afyx-forge", "codex-usage-tracking"]
27
+ LINE_RE = re.compile(r'^\s*"[a-z_]+":\s*"[^"\\]*",?\s*$')
28
+
29
+
30
+ def fail(message: str) -> None:
31
+ raise SystemExit(f"Component contract validation failed: {message}")
32
+
33
+
34
+ text = CONTRACT.read_text(encoding="utf-8")
35
+ document = json.loads(text)
36
+ if document.get("schema_version") != 1:
37
+ fail("schema_version must be 1")
38
+ if document.get("control_plane_version") != 1:
39
+ fail("control_plane_version must be 1")
40
+ if document.get("provider_adapter_contract") != "ProviderAdapter/v1":
41
+ fail("provider_adapter_contract must be ProviderAdapter/v1")
42
+ if document.get("provider_adapter_operations") != "inspect;plan;apply;verify;uninstall":
43
+ fail("provider_adapter_operations must declare the stable v1 lifecycle")
44
+ expected_contracts = {
45
+ "provider_capability_contract": "ProviderCapability/v1",
46
+ "provider_negotiation_contract": "ProviderCapabilityNegotiation/v1",
47
+ "engineering_task_contract": "AfyxEngineeringTask/v1",
48
+ "engineering_result_contract": "AfyxEngineeringResult/v1",
49
+ }
50
+ for key, expected in expected_contracts.items():
51
+ if document.get(key) != expected:
52
+ fail(f"{key} must be {expected}")
53
+ if set(document.get("supported_presets", "").split(";")) != PRESETS:
54
+ fail("supported_presets must contain minimal, recommended, full and custom")
55
+ providers = document.get("providers", [])
56
+ provider_ids = [provider.get("provider") for provider in providers]
57
+ if provider_ids != ["codex", "antigravity", "claude"] or document.get("default_provider") != "codex":
58
+ fail("provider registry must declare Codex first/default, Antigravity second, and Claude third")
59
+ if len(set(provider_ids)) != len(provider_ids):
60
+ fail("duplicate provider id")
61
+ for provider in providers:
62
+ if provider.get("ownership_class") not in OWNERSHIP_CLASSES:
63
+ fail(f"provider {provider.get('provider')}: invalid ownership_class")
64
+ if provider.get("configuration_policy") not in {"merge-afyx-owned-entries-only", "observe-only"}:
65
+ fail(f"provider {provider.get('provider')}: unsafe configuration_policy")
66
+ if providers[0].get("primary") != "true":
67
+ fail("Codex must be the primary v1 provider")
68
+ if any(provider.get("primary") == "true" for provider in providers[1:]):
69
+ fail("only Codex may be the primary provider")
70
+ components = document["components"]
71
+
72
+ # The Bash reader parses one scalar "key": "value" per line inside each object.
73
+ inside = False
74
+ for number, line in enumerate(text.splitlines(), start=1):
75
+ stripped = line.strip()
76
+ if stripped == "{" and number > 1 and inside is False and line.startswith(" "):
77
+ inside = True
78
+ continue
79
+ if inside and stripped in ("}", "},"):
80
+ inside = False
81
+ continue
82
+ if inside and not LINE_RE.match(line):
83
+ fail(f"line {number} is not a single scalar \"key\": \"value\" pair: {line.strip()!r}")
84
+
85
+ ids = [component["id"] for component in components]
86
+ if ids != EXPECTED_IDS:
87
+ fail(f"component ids must be exactly {EXPECTED_IDS}, got {ids}")
88
+ if len(set(ids)) != len(ids):
89
+ fail("duplicate component id")
90
+
91
+ for component in components:
92
+ cid = component["id"]
93
+ missing = REQUIRED_KEYS - component.keys()
94
+ if missing:
95
+ fail(f"{cid}: missing keys {sorted(missing)}")
96
+ for key, value in component.items():
97
+ if not isinstance(value, str):
98
+ fail(f"{cid}.{key} must be a string")
99
+ if component["type"] not in TYPES:
100
+ fail(f"{cid}: unknown type {component['type']}")
101
+ if component["tier"] not in TIERS:
102
+ fail(f"{cid}: unknown tier {component['tier']}")
103
+ if component["ownership"] not in OWNERSHIP:
104
+ fail(f"{cid}: unknown ownership {component['ownership']}")
105
+ if component["ownership_class"] not in OWNERSHIP_CLASSES - {"USER"}:
106
+ fail(f"{cid}: invalid declared ownership_class")
107
+ declared_presets = {item for item in component["presets"].split(";") if item}
108
+ if not declared_presets <= PRESETS - {"custom"}:
109
+ fail(f"{cid}: invalid preset membership")
110
+ if component["platforms"] not in PLATFORMS:
111
+ fail(f"{cid}: unknown platforms {component['platforms']}")
112
+ if component["install_root"] not in INSTALL_ROOTS:
113
+ fail(f"{cid}: unknown install_root {component['install_root']}")
114
+ if component["tier"] == "core" and component["ownership"] == "external":
115
+ fail(f"{cid}: a core component cannot be externally owned")
116
+
117
+ by_id = {component["id"]: component for component in components}
118
+ expected_presets = {
119
+ "minimal": {"efficient-coding", "odoo-engineering"},
120
+ "recommended": {"efficient-coding", "odoo-engineering", "afyx-engineering-expert"},
121
+ "full": {"efficient-coding", "odoo-engineering", "afyx-engineering-expert", "afyx-graph", "afyx-context", "afyx-forge", "codex-usage-tracking"},
122
+ }
123
+ for preset, expected in expected_presets.items():
124
+ actual = {component["id"] for component in components if preset in component["presets"].split(";")}
125
+ if actual != expected:
126
+ fail(f"{preset}: component membership mismatch")
127
+
128
+ # Bundled skills must ship exactly what the contract requires.
129
+ for cid in ("efficient-coding", "odoo-engineering", "afyx-engineering-expert"):
130
+ component = by_id[cid]
131
+ skill_dir = ROOT / "skills" / component["install_path"]
132
+ for relative in component["required_files"].split(";"):
133
+ if not (skill_dir / relative).is_file():
134
+ fail(f"{cid}: required file {relative} is missing from the bundled skill")
135
+ manifest = (skill_dir / "SKILL.md").read_text(encoding="utf-8")
136
+ if not re.search(r"(?m)^name:\s*" + re.escape(cid) + r"\s*$", manifest):
137
+ fail(f"{cid}: SKILL.md name does not match the component id")
138
+ if component["version_required"] == "true" and not re.search(r'(?ms)^metadata:\s*\n\s+version:\s*["\'][^"\']+["\']', manifest):
139
+ fail(f"{cid}: SKILL.md metadata.version is required by the contract")
140
+ if cid == "afyx-engineering-expert":
141
+ if any(key.startswith("legacy_") for key in component):
142
+ fail("afyx-engineering-expert: new skill must not claim legacy adoption evidence")
143
+ continue
144
+ if component.get("legacy_version") != "1.1.0" or component.get("legacy_distribution_revision") != "b0b4d88eb7c42627598de71d6b0bf26317b9a694":
145
+ fail(f"{cid}: legacy adoption evidence must identify the verified 1.1.0 baseline")
146
+ if not re.fullmatch(r"[0-9a-f]{64}", component.get("legacy_content_digest", "")) or not re.fullmatch(r"[0-9a-f]{64}", component.get("legacy_content_digest_bash", "")):
147
+ fail(f"{cid}: legacy adoption digests must be exact SHA-256 values")
148
+
149
+ # The graph component must agree with the operational metadata.
150
+ graph = by_id["afyx-graph"]
151
+ metadata = json.loads((ROOT / "afyx-graph" / "afyx-graph.json").read_text(encoding="utf-8"))
152
+ if graph["marker_value"] != metadata["product_name"]:
153
+ fail("afyx-graph marker_value differs from metadata product_name")
154
+ if graph["marker_field"] not in metadata:
155
+ fail("afyx-graph marker_field is not a metadata field")
156
+ version_field = graph["version_source"].split("#", 1)[1]
157
+ if version_field not in metadata:
158
+ fail("afyx-graph version_source is not a metadata field")
159
+ if metadata["cli"] not in graph["required_files_unix"] or f"{metadata['cli']}.cmd" not in graph["required_files_windows"]:
160
+ fail("afyx-graph launcher files must match the metadata CLI name")
161
+
162
+ # ACE is first-party in the explicitly selected Full preset. Graph consumers
163
+ # remain OFF unless separately authorized.
164
+ context = by_id["afyx-context"]
165
+ context_metadata = json.loads((ROOT / "afyx-context" / "afyx-context.json").read_text(encoding="utf-8"))
166
+ if context["ownership_class"] != "AFYX" or context["install_root"] != "afyx_context_root" or context["presets"] != "full":
167
+ fail("afyx-context must be an AFYX-owned Full-preset runtime")
168
+ if context_metadata["kit_management"]["lifecycle_integration"] != "managed-optional":
169
+ fail("afyx-context lifecycle metadata must declare managed-optional")
170
+ if context_metadata["kit_management"]["default_presets"] != ["full"] or context_metadata["optional_consumers"]["graph"]["default_enabled"]:
171
+ fail("afyx-context Full-preset metadata and Graph OFF must remain aligned")
172
+ if context["marker_value"] != context_metadata["product_name"] or context["marker_field"] not in context_metadata:
173
+ fail("afyx-context component metadata does not match its product identity")
174
+
175
+ # Afyx Forge Core is first-party in the explicitly selected Full preset,
176
+ # bounded to assistive guidance while A8 remains evaluation-gated.
177
+ forge = by_id["afyx-forge"]
178
+ forge_metadata = json.loads((ROOT / "afyx-forge" / "afyx-forge.json").read_text(encoding="utf-8"))
179
+ if forge["ownership_class"] != "AFYX" or forge["install_root"] != "afyx_forge_root" or forge["presets"] != "full":
180
+ fail("afyx-forge must be an AFYX-owned Full-preset runtime")
181
+ if forge["marker_value"] != forge_metadata["product_name"] or forge["marker_field"] not in forge_metadata:
182
+ fail("afyx-forge component metadata does not match its product identity")
183
+ if forge_metadata.get("runtime_mode") != "ASSISTIVE_GUIDANCE_ONLY" or forge_metadata.get("evaluation_gate", {}).get("autonomous_code_execution") is not False:
184
+ fail("afyx-forge metadata must enforce ASSISTIVE_GUIDANCE_ONLY without autonomous execution")
185
+
186
+ # The usage tracker contract must list files the kit actually ships.
187
+ usage = by_id["codex-usage-tracking"]
188
+ if usage.get("providers") != "codex":
189
+ fail("codex-usage-tracking must remain Codex-only")
190
+ for relative in usage["required_files"].split(";"):
191
+ if not (ROOT / "tools" / "codex-usage" / relative).is_file():
192
+ fail(f"codex-usage-tracking: {relative} is not shipped in tools/codex-usage")
193
+
194
+ print(f"Afyx component contract: PASS ({len(components)} components)")