@nimiplatform/nimi-coding 0.2.8 → 0.3.1

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 (206) hide show
  1. package/CHANGELOG.md +10 -90
  2. package/CONTRIBUTING.md +5 -34
  3. package/README.md +47 -350
  4. package/README.zh-CN.md +33 -287
  5. package/cli/commands/start.mjs +48 -688
  6. package/cli/commands/validate-spec-audit.mjs +1 -5
  7. package/cli/commands/validate-spec-governance.mjs +20 -0
  8. package/cli/constants.mjs +9 -417
  9. package/cli/help.mjs +28 -145
  10. package/cli/index.mjs +5 -33
  11. package/cli/lib/blueprint-audit.mjs +5 -12
  12. package/cli/lib/bootstrap.mjs +0 -9
  13. package/cli/lib/contracts.mjs +0 -163
  14. package/cli/lib/doctor.mjs +155 -10
  15. package/cli/lib/entrypoints.mjs +63 -167
  16. package/cli/lib/internal/contracts-loaders.mjs +0 -85
  17. package/cli/lib/internal/contracts-parse.mjs +84 -520
  18. package/cli/lib/internal/governance/ai/check-agents-freshness.mjs +13 -8
  19. package/cli/lib/internal/surface-taxonomy-validators.mjs +316 -66
  20. package/cli/lib/internal/validators-shared.mjs +0 -16
  21. package/cli/lib/internal/validators-spec-helpers.mjs +7 -140
  22. package/cli/lib/internal/validators-spec.mjs +103 -342
  23. package/cli/lib/shared.mjs +1 -42
  24. package/cli/lib/validators.mjs +0 -48
  25. package/cli/seeds/seed-policy.yaml +0 -3
  26. package/config/bootstrap.yaml +4 -4
  27. package/config/spec-generation-inputs.yaml +6 -12
  28. package/contracts/domain-admission.schema.yaml +3 -3
  29. package/contracts/migration-inventory.schema.yaml +12 -75
  30. package/contracts/negative-fixtures.yaml +19 -99
  31. package/contracts/placement-contract.schema.yaml +49 -78
  32. package/contracts/projection-edge.schema.yaml +37 -121
  33. package/contracts/shared-enums.yaml +4 -8
  34. package/contracts/spec-generation-inputs.schema.yaml +15 -112
  35. package/contracts/spec-layout.schema.yaml +32 -0
  36. package/contracts/surface-taxonomy.schema.yaml +43 -94
  37. package/contracts/table-family.schema.yaml +1 -1
  38. package/contracts/tracked-output-admission.schema.yaml +13 -66
  39. package/methodology/core.yaml +33 -25
  40. package/methodology/four-closure-policy.yaml +18 -26
  41. package/methodology/role-separation-policy.yaml +21 -27
  42. package/methodology/spec-reconstruction.yaml +17 -34
  43. package/package.json +2 -4
  44. package/spec/_meta/spec-tree-model.yaml +5 -101
  45. package/spec/product-scope.yaml +25 -57
  46. package/adapters/README.md +0 -25
  47. package/adapters/claude/README.md +0 -89
  48. package/adapters/claude/profile.yaml +0 -70
  49. package/adapters/codex/README.md +0 -53
  50. package/adapters/codex/profile.yaml +0 -78
  51. package/adapters/oh-my-codex/README.md +0 -184
  52. package/adapters/oh-my-codex/profile.yaml +0 -46
  53. package/cli/commands/admit-high-risk-decision.mjs +0 -108
  54. package/cli/commands/audit-sweep.mjs +0 -364
  55. package/cli/commands/closeout.mjs +0 -186
  56. package/cli/commands/decide-high-risk-execution.mjs +0 -124
  57. package/cli/commands/handoff.mjs +0 -123
  58. package/cli/commands/ingest-high-risk-execution.mjs +0 -95
  59. package/cli/commands/review-high-risk-execution.mjs +0 -95
  60. package/cli/commands/sweep-design.mjs +0 -295
  61. package/cli/commands/sweep.mjs +0 -22
  62. package/cli/commands/topic-formatters.mjs +0 -382
  63. package/cli/commands/topic-goal.mjs +0 -33
  64. package/cli/commands/topic-options-shared.mjs +0 -27
  65. package/cli/commands/topic-options-workflow.mjs +0 -767
  66. package/cli/commands/topic-options.mjs +0 -626
  67. package/cli/commands/topic-runner.mjs +0 -169
  68. package/cli/commands/topic.mjs +0 -795
  69. package/cli/commands/validate-acceptance.mjs +0 -5
  70. package/cli/commands/validate-execution-packet.mjs +0 -5
  71. package/cli/commands/validate-orchestration-state.mjs +0 -5
  72. package/cli/commands/validate-prompt.mjs +0 -5
  73. package/cli/commands/validate-worker-output.mjs +0 -5
  74. package/cli/lib/adapter-profiles.mjs +0 -403
  75. package/cli/lib/audit-execution.mjs +0 -52
  76. package/cli/lib/audit-sweep-runtime/admissions.mjs +0 -508
  77. package/cli/lib/audit-sweep-runtime/audit-validity.mjs +0 -356
  78. package/cli/lib/audit-sweep-runtime/chunks.mjs +0 -697
  79. package/cli/lib/audit-sweep-runtime/claude-auditor.mjs +0 -658
  80. package/cli/lib/audit-sweep-runtime/closeout.mjs +0 -144
  81. package/cli/lib/audit-sweep-runtime/codex-auditor-evidence.mjs +0 -654
  82. package/cli/lib/audit-sweep-runtime/codex-auditor.mjs +0 -527
  83. package/cli/lib/audit-sweep-runtime/common.mjs +0 -341
  84. package/cli/lib/audit-sweep-runtime/coverage-quality.mjs +0 -172
  85. package/cli/lib/audit-sweep-runtime/evidence-assignment.mjs +0 -155
  86. package/cli/lib/audit-sweep-runtime/format.mjs +0 -57
  87. package/cli/lib/audit-sweep-runtime/ingest.mjs +0 -486
  88. package/cli/lib/audit-sweep-runtime/inventory-spec-chunks.mjs +0 -425
  89. package/cli/lib/audit-sweep-runtime/inventory.mjs +0 -798
  90. package/cli/lib/audit-sweep-runtime/ledger.mjs +0 -315
  91. package/cli/lib/audit-sweep-runtime/p0p1-profile.mjs +0 -101
  92. package/cli/lib/audit-sweep-runtime/remediation.mjs +0 -349
  93. package/cli/lib/audit-sweep-runtime/rerun.mjs +0 -129
  94. package/cli/lib/audit-sweep-runtime/risk-budget.mjs +0 -300
  95. package/cli/lib/audit-sweep-runtime/status.mjs +0 -62
  96. package/cli/lib/audit-sweep-runtime/validators-ledger.mjs +0 -215
  97. package/cli/lib/audit-sweep-runtime/validators.mjs +0 -797
  98. package/cli/lib/audit-sweep.mjs +0 -19
  99. package/cli/lib/authority-convergence.mjs +0 -720
  100. package/cli/lib/closeout.mjs +0 -732
  101. package/cli/lib/codex-sdk-runner.mjs +0 -76
  102. package/cli/lib/external-execution.mjs +0 -101
  103. package/cli/lib/handoff.mjs +0 -812
  104. package/cli/lib/high-risk-admission.mjs +0 -512
  105. package/cli/lib/high-risk-decision.mjs +0 -353
  106. package/cli/lib/high-risk-ingest.mjs +0 -321
  107. package/cli/lib/high-risk-review.mjs +0 -267
  108. package/cli/lib/internal/contracts-parse-high-risk.mjs +0 -131
  109. package/cli/lib/internal/contracts-validators.mjs +0 -399
  110. package/cli/lib/internal/doctor-bootstrap-surface.mjs +0 -406
  111. package/cli/lib/internal/doctor-delegated-surface.mjs +0 -256
  112. package/cli/lib/internal/doctor-finalize.mjs +0 -383
  113. package/cli/lib/internal/doctor-format.mjs +0 -286
  114. package/cli/lib/internal/doctor-inspectors.mjs +0 -327
  115. package/cli/lib/internal/doctor-state.mjs +0 -205
  116. package/cli/lib/internal/validators-artifacts.mjs +0 -515
  117. package/cli/lib/sweep-design-runtime/common.mjs +0 -246
  118. package/cli/lib/sweep-design-runtime/engine.mjs +0 -733
  119. package/cli/lib/sweep-design-runtime/fix-topic.mjs +0 -414
  120. package/cli/lib/sweep-design-runtime/lifecycle.mjs +0 -54
  121. package/cli/lib/sweep-design-runtime/results.mjs +0 -324
  122. package/cli/lib/sweep-design.mjs +0 -8
  123. package/cli/lib/topic-artifacts.mjs +0 -186
  124. package/cli/lib/topic-authority-coverage.mjs +0 -73
  125. package/cli/lib/topic-closeout.mjs +0 -560
  126. package/cli/lib/topic-common.mjs +0 -404
  127. package/cli/lib/topic-decisions.mjs +0 -332
  128. package/cli/lib/topic-draft-packets.mjs +0 -167
  129. package/cli/lib/topic-execution.mjs +0 -533
  130. package/cli/lib/topic-goal.mjs +0 -440
  131. package/cli/lib/topic-ledger.mjs +0 -281
  132. package/cli/lib/topic-lifecycle-artifacts.mjs +0 -173
  133. package/cli/lib/topic-root-validation.mjs +0 -288
  134. package/cli/lib/topic-runner-commands.mjs +0 -174
  135. package/cli/lib/topic-runner-deferral.mjs +0 -532
  136. package/cli/lib/topic-runner-stale-gates.mjs +0 -114
  137. package/cli/lib/topic-runner-validation.mjs +0 -138
  138. package/cli/lib/topic-runner.mjs +0 -727
  139. package/cli/lib/topic-scaffold.mjs +0 -252
  140. package/cli/lib/topic-waves.mjs +0 -403
  141. package/cli/lib/topic.mjs +0 -81
  142. package/config/audit-execution-artifacts.yaml +0 -20
  143. package/config/external-execution-artifacts.yaml +0 -16
  144. package/config/host-adapter.yaml +0 -30
  145. package/config/host-profile.yaml +0 -29
  146. package/config/installer-evidence.yaml +0 -31
  147. package/config/skill-installer.yaml +0 -23
  148. package/config/skill-manifest.yaml +0 -48
  149. package/config/skills.yaml +0 -30
  150. package/contracts/acceptance.schema.yaml +0 -16
  151. package/contracts/admission-checklist.schema.yaml +0 -15
  152. package/contracts/audit-chunk.schema.yaml +0 -123
  153. package/contracts/audit-closeout.schema.yaml +0 -51
  154. package/contracts/audit-finding.schema.yaml +0 -61
  155. package/contracts/audit-ledger.schema.yaml +0 -138
  156. package/contracts/audit-plan.schema.yaml +0 -138
  157. package/contracts/audit-remediation-map.schema.yaml +0 -52
  158. package/contracts/audit-rerun.schema.yaml +0 -31
  159. package/contracts/audit-sweep-result.yaml +0 -53
  160. package/contracts/authority-convergence-audit.schema.yaml +0 -19
  161. package/contracts/closeout.schema.yaml +0 -25
  162. package/contracts/decision-review.schema.yaml +0 -16
  163. package/contracts/doc-spec-audit-result.yaml +0 -19
  164. package/contracts/execution-packet.schema.yaml +0 -49
  165. package/contracts/external-host-compatibility.yaml +0 -22
  166. package/contracts/forbidden-shortcuts.catalog.yaml +0 -23
  167. package/contracts/high-risk-admission.schema.yaml +0 -23
  168. package/contracts/high-risk-execution-result.yaml +0 -20
  169. package/contracts/orchestration-state.schema.yaml +0 -41
  170. package/contracts/overflow-continuation.schema.yaml +0 -12
  171. package/contracts/packet.schema.yaml +0 -30
  172. package/contracts/pending-note.schema.yaml +0 -17
  173. package/contracts/prompt.schema.yaml +0 -12
  174. package/contracts/remediation.schema.yaml +0 -16
  175. package/contracts/result.schema.yaml +0 -24
  176. package/contracts/spec-reconstruction-result.yaml +0 -41
  177. package/contracts/sweep-design-result.yaml +0 -349
  178. package/contracts/topic-goal.schema.yaml +0 -87
  179. package/contracts/topic-run-ledger.schema.yaml +0 -72
  180. package/contracts/topic-step-decision.schema.yaml +0 -45
  181. package/contracts/topic.schema.yaml +0 -65
  182. package/contracts/true-close.schema.yaml +0 -15
  183. package/contracts/wave.schema.yaml +0 -29
  184. package/contracts/worker-output.schema.yaml +0 -15
  185. package/contracts/workflow-consumer.schema.yaml +0 -110
  186. package/methodology/audit-sweep-p0p1-recall.yaml +0 -45
  187. package/methodology/authority-convergence-policy.yaml +0 -42
  188. package/methodology/overflow-continuation-policy.yaml +0 -14
  189. package/methodology/skill-exchange-projection.yaml +0 -114
  190. package/methodology/skill-handoff.yaml +0 -34
  191. package/methodology/skill-installer-result.yaml +0 -27
  192. package/methodology/skill-installer-summary-projection.yaml +0 -181
  193. package/methodology/skill-runtime.yaml +0 -23
  194. package/methodology/spec-target-truth-profile.yaml +0 -46
  195. package/methodology/topic-lifecycle-report.yaml +0 -144
  196. package/methodology/topic-lifecycle.yaml +0 -37
  197. package/methodology/topic-naming-ontology.yaml +0 -21
  198. package/methodology/topic-ontology.yaml +0 -38
  199. package/methodology/topic-validation-policy.yaml +0 -9
  200. package/methodology/wave-dag-policy.yaml +0 -14
  201. package/spec/_meta/command-gating-matrix.yaml +0 -143
  202. package/spec/_meta/generate-drift-migration-checklist.yaml +0 -137
  203. package/spec/_meta/governance-routing-cutover-checklist.yaml +0 -35
  204. package/spec/_meta/phase2-impacted-surface-matrix.yaml +0 -44
  205. package/spec/_meta/spec-authority-cutover-readiness.yaml +0 -102
  206. package/spec/bootstrap-state.yaml +0 -99
@@ -1,5 +0,0 @@
1
- import { runValidatorCommand, validateAcceptance } from "../lib/validators.mjs";
2
-
3
- export function runValidateAcceptance(args) {
4
- return runValidatorCommand(args, "validate-acceptance", validateAcceptance);
5
- }
@@ -1,5 +0,0 @@
1
- import { runValidatorCommand, validateExecutionPacket } from "../lib/validators.mjs";
2
-
3
- export function runValidateExecutionPacket(args) {
4
- return runValidatorCommand(args, "validate-execution-packet", validateExecutionPacket);
5
- }
@@ -1,5 +0,0 @@
1
- import { runValidatorCommand, validateOrchestrationState } from "../lib/validators.mjs";
2
-
3
- export function runValidateOrchestrationState(args) {
4
- return runValidatorCommand(args, "validate-orchestration-state", validateOrchestrationState);
5
- }
@@ -1,5 +0,0 @@
1
- import { runValidatorCommand, validatePrompt } from "../lib/validators.mjs";
2
-
3
- export function runValidatePrompt(args) {
4
- return runValidatorCommand(args, "validate-prompt", validatePrompt);
5
- }
@@ -1,5 +0,0 @@
1
- import { runValidatorCommand, validateWorkerOutput } from "../lib/validators.mjs";
2
-
3
- export function runValidateWorkerOutput(args) {
4
- return runValidatorCommand(args, "validate-worker-output", validateWorkerOutput);
5
- }
@@ -1,403 +0,0 @@
1
- import { readFile } from "node:fs/promises";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
-
5
- import { ADAPTER_PACKAGE_PROFILE_REFS } from "../constants.mjs";
6
- import { arraysEqual, isPlainObject, toStringArray } from "./value-helpers.mjs";
7
- import { parseYamlText } from "./yaml-helpers.mjs";
8
-
9
- const PACKAGE_ROOT = fileURLToPath(new URL("../..", import.meta.url));
10
-
11
- const ADAPTER_PROFILE_EXPECTATIONS = {
12
- codex: {
13
- hostClass: "native_codex_sdk_host",
14
- upstreamSeedProfile: "external_ai_host",
15
- semanticOwner: [
16
- ".nimi/methodology",
17
- ".nimi/spec",
18
- ".nimi/contracts",
19
- ".nimi/config",
20
- ],
21
- operationalOwner: [
22
- ".codex",
23
- ".nimi/local",
24
- ".nimi/cache",
25
- ],
26
- admittedSkillSurfaces: [
27
- "spec_reconstruction",
28
- "doc_spec_audit",
29
- "audit_sweep",
30
- "high_risk_execution",
31
- "topic_loop_execution",
32
- "authority_convergence_audit",
33
- ],
34
- promptBootstrapSurface: [
35
- "nimicoding handoff --skill spec_reconstruction --prompt",
36
- "nimicoding handoff --skill doc_spec_audit --prompt",
37
- "nimicoding handoff --skill audit_sweep --prompt",
38
- "nimicoding handoff --skill high_risk_execution --prompt",
39
- ],
40
- promptFutureSurface: [
41
- "Codex.startThread().run",
42
- "Codex.resumeThread().run",
43
- ],
44
- promptFutureSurfaceStatus: "active_via_codex_sdk",
45
- outputHandoff: {
46
- workerOutputTarget: ".nimi/local/outputs/** candidate artifact",
47
- evidenceTarget: ".nimi/local/evidence/** candidate artifact",
48
- closeoutTarget: "local-only closeout payload unless later admitted",
49
- },
50
- nativeReviewBoundary: {
51
- approvalReview: {
52
- scope: "lower_layer_permission_review",
53
- semanticEffect: "none",
54
- evidenceTarget: ".nimi/local/evidence/** candidate artifact",
55
- },
56
- githubAutoReview: {
57
- scope: "lower_layer_pr_review_findings",
58
- semanticEffect: "evidence_only",
59
- evidenceTarget: ".nimi/local/evidence/** candidate artifact",
60
- },
61
- forbiddenSemanticSubstitutions: [
62
- "wave_admission",
63
- "packet_freeze",
64
- "result_verdict",
65
- "wave_closeout",
66
- "topic_closeout",
67
- "true_close",
68
- ],
69
- },
70
- hardConstraints: [
71
- "codex_sdk_must_not_become_semantic_owner",
72
- "codex_sdk_must_not_write_canonical_.nimi/spec_truth_directly_without_validator_admission",
73
- "codex_sdk_must_not_define_acceptance_disposition_or_finding_judgment",
74
- "codex_thread_state_must_remain_operational_only",
75
- "codex_sdk_runs_must_be_recorded_in_topic_run_ledger",
76
- "codex_native_approval_review_must_remain_permission_review_only",
77
- "codex_github_auto_review_must_remain_evidence_only",
78
- "codex_review_must_not_substitute_nimicoding_semantic_commands",
79
- "unresolved_authority_or_missing_context_must_fail_closed",
80
- "codex_subagent_authority_convergence_output_must_remain_candidate_evidence",
81
- ],
82
- },
83
- claude: {
84
- hostClass: "inline_coding_host",
85
- upstreamSeedProfile: "external_ai_host",
86
- semanticOwner: [
87
- ".nimi/methodology",
88
- ".nimi/spec",
89
- ".nimi/contracts",
90
- ".nimi/config",
91
- ],
92
- operationalOwner: [
93
- ".claude",
94
- ".nimi/local",
95
- ".nimi/cache",
96
- ],
97
- admittedSkillSurfaces: [
98
- "spec_reconstruction",
99
- "doc_spec_audit",
100
- "audit_sweep",
101
- "high_risk_execution",
102
- "inline_review",
103
- "authority_convergence_audit",
104
- ],
105
- promptBootstrapSurface: [
106
- "nimicoding handoff --skill spec_reconstruction --prompt",
107
- "nimicoding handoff --skill doc_spec_audit --prompt",
108
- "nimicoding handoff --skill audit_sweep --prompt",
109
- "nimicoding handoff --skill high_risk_execution --prompt",
110
- ],
111
- promptFutureSurface: [],
112
- promptFutureSurfaceStatus: "active_via_hooks",
113
- outputHandoff: {
114
- workerOutputTarget: ".nimi/local/outputs/** candidate artifact",
115
- evidenceTarget: ".nimi/local/evidence/** candidate artifact",
116
- closeoutTarget: "local-only closeout payload unless later admitted",
117
- },
118
- hardConstraints: [
119
- "claude_must_not_become_semantic_owner",
120
- "claude_must_not_write_canonical_.nimi/spec_truth_directly_without_validator_admission",
121
- "claude_must_not_define_acceptance_disposition_or_finding_judgment",
122
- "claude_operational_state_must_remain_operational_only",
123
- "claude_hooks_must_not_replace_agents_md_authority",
124
- "unresolved_authority_or_missing_context_must_fail_closed",
125
- "claude_subagent_authority_convergence_output_must_remain_candidate_evidence",
126
- ],
127
- },
128
- oh_my_codex: {
129
- hostClass: "external_execution_host",
130
- upstreamSeedProfile: "external_ai_host",
131
- semanticOwner: [
132
- ".nimi/methodology",
133
- ".nimi/spec",
134
- ".nimi/contracts",
135
- ".nimi/config",
136
- ],
137
- operationalOwner: [
138
- ".omx",
139
- ".nimi/local",
140
- ".nimi/cache",
141
- ],
142
- admittedSkillSurfaces: [
143
- "spec_reconstruction",
144
- "doc_spec_audit",
145
- "audit_sweep",
146
- "high_risk_execution",
147
- ],
148
- promptBootstrapSurface: [
149
- "nimicoding handoff --skill spec_reconstruction --prompt",
150
- "nimicoding handoff --skill doc_spec_audit --prompt",
151
- "nimicoding handoff --skill audit_sweep --prompt",
152
- "nimicoding handoff --skill high_risk_execution --prompt",
153
- ],
154
- promptFutureSurface: [
155
- "nimicoding run-next-prompt",
156
- ],
157
- promptFutureSurfaceStatus: "future_only_not_packaged",
158
- outputHandoff: {
159
- workerOutputTarget: ".nimi/local/outputs/** candidate artifact",
160
- evidenceTarget: ".nimi/local/evidence/** candidate artifact",
161
- closeoutTarget: "local-only closeout payload unless later admitted",
162
- },
163
- hardConstraints: [
164
- "omx_must_not_become_semantic_owner",
165
- "omx_must_not_write_canonical_.nimi/spec_truth_directly_without_validator_admission",
166
- "omx_must_not_define_acceptance_disposition_or_finding_judgment",
167
- "omx_runtime_state_must_remain_operational_only",
168
- "unresolved_authority_or_missing_context_must_fail_closed",
169
- ],
170
- },
171
- };
172
-
173
- function buildInvalidProfile(adapterId, profileRef, reason) {
174
- return {
175
- ok: false,
176
- id: adapterId,
177
- profileRef,
178
- absolutePath: profileRef ? path.join(PACKAGE_ROOT, profileRef) : null,
179
- reason,
180
- version: null,
181
- hostClass: null,
182
- upstreamSeedProfile: null,
183
- purpose: null,
184
- semanticOwner: [],
185
- operationalOwner: [],
186
- admittedSkillSurfaces: [],
187
- promptHandoff: {
188
- bootstrapSurface: [],
189
- futureSurface: [],
190
- futureSurfaceStatus: null,
191
- },
192
- outputHandoff: {
193
- workerOutputTarget: null,
194
- evidenceTarget: null,
195
- closeoutTarget: null,
196
- },
197
- nativeReviewBoundary: null,
198
- hardConstraints: [],
199
- currentGaps: [],
200
- };
201
- }
202
-
203
- function normalizeAdapterProfile(adapterId, profileRef, parsed) {
204
- const profile = parsed?.adapter_profile;
205
- if (!isPlainObject(profile)) {
206
- return buildInvalidProfile(adapterId, profileRef, "adapter profile YAML is missing adapter_profile");
207
- }
208
-
209
- return {
210
- ok: true,
211
- id: typeof profile.id === "string" ? profile.id : null,
212
- profileRef,
213
- absolutePath: path.join(PACKAGE_ROOT, profileRef),
214
- reason: null,
215
- version: parsed?.version ?? null,
216
- hostClass: typeof profile.host_class === "string" ? profile.host_class : null,
217
- upstreamSeedProfile: typeof profile.upstream_seed_profile === "string" ? profile.upstream_seed_profile : null,
218
- purpose: typeof profile.purpose === "string" ? profile.purpose.trim() : null,
219
- semanticOwner: toStringArray(profile.semantic_owner),
220
- operationalOwner: toStringArray(profile.operational_owner),
221
- admittedSkillSurfaces: toStringArray(profile.admitted_skill_surfaces),
222
- promptHandoff: {
223
- bootstrapSurface: toStringArray(profile.prompt_handoff?.bootstrap_surface),
224
- futureSurface: toStringArray(profile.prompt_handoff?.future_surface?.commands),
225
- futureSurfaceStatus: typeof profile.prompt_handoff?.future_surface?.status === "string"
226
- ? profile.prompt_handoff.future_surface.status
227
- : null,
228
- },
229
- outputHandoff: {
230
- workerOutputTarget: typeof profile.output_handoff?.worker_output_target === "string"
231
- ? profile.output_handoff.worker_output_target
232
- : null,
233
- evidenceTarget: typeof profile.output_handoff?.evidence_target === "string"
234
- ? profile.output_handoff.evidence_target
235
- : null,
236
- closeoutTarget: typeof profile.output_handoff?.closeout_target === "string"
237
- ? profile.output_handoff.closeout_target
238
- : null,
239
- },
240
- nativeReviewBoundary: isPlainObject(profile.native_review_boundary)
241
- ? {
242
- approvalReview: {
243
- scope: typeof profile.native_review_boundary.approval_review?.scope === "string"
244
- ? profile.native_review_boundary.approval_review.scope
245
- : null,
246
- semanticEffect: typeof profile.native_review_boundary.approval_review?.semantic_effect === "string"
247
- ? profile.native_review_boundary.approval_review.semantic_effect
248
- : null,
249
- evidenceTarget: typeof profile.native_review_boundary.approval_review?.evidence_target === "string"
250
- ? profile.native_review_boundary.approval_review.evidence_target
251
- : null,
252
- },
253
- githubAutoReview: {
254
- scope: typeof profile.native_review_boundary.github_auto_review?.scope === "string"
255
- ? profile.native_review_boundary.github_auto_review.scope
256
- : null,
257
- semanticEffect: typeof profile.native_review_boundary.github_auto_review?.semantic_effect === "string"
258
- ? profile.native_review_boundary.github_auto_review.semantic_effect
259
- : null,
260
- evidenceTarget: typeof profile.native_review_boundary.github_auto_review?.evidence_target === "string"
261
- ? profile.native_review_boundary.github_auto_review.evidence_target
262
- : null,
263
- },
264
- forbiddenSemanticSubstitutions: toStringArray(
265
- profile.native_review_boundary.forbidden_semantic_substitutions,
266
- ),
267
- }
268
- : null,
269
- hardConstraints: toStringArray(profile.hard_constraints),
270
- currentGaps: toStringArray(profile.current_gaps),
271
- };
272
- }
273
-
274
- function validateAdapterProfile(profile) {
275
- const expectation = ADAPTER_PROFILE_EXPECTATIONS[profile.id];
276
- if (!expectation) {
277
- return {
278
- ok: false,
279
- reason: `no package-owned adapter profile expectation is declared for ${profile.id}`,
280
- };
281
- }
282
-
283
- const hardConstraintsOk = expectation.hardConstraints.every((entry) => profile.hardConstraints.includes(entry));
284
- const outputHandoffOk = profile.outputHandoff.workerOutputTarget === expectation.outputHandoff.workerOutputTarget
285
- && profile.outputHandoff.evidenceTarget === expectation.outputHandoff.evidenceTarget
286
- && profile.outputHandoff.closeoutTarget === expectation.outputHandoff.closeoutTarget;
287
- const nativeReviewOk = !expectation.nativeReviewBoundary
288
- || (
289
- profile.nativeReviewBoundary?.approvalReview?.scope === expectation.nativeReviewBoundary.approvalReview.scope
290
- && profile.nativeReviewBoundary.approvalReview.semanticEffect === expectation.nativeReviewBoundary.approvalReview.semanticEffect
291
- && profile.nativeReviewBoundary.approvalReview.evidenceTarget === expectation.nativeReviewBoundary.approvalReview.evidenceTarget
292
- && profile.nativeReviewBoundary.githubAutoReview?.scope === expectation.nativeReviewBoundary.githubAutoReview.scope
293
- && profile.nativeReviewBoundary.githubAutoReview.semanticEffect === expectation.nativeReviewBoundary.githubAutoReview.semanticEffect
294
- && profile.nativeReviewBoundary.githubAutoReview.evidenceTarget === expectation.nativeReviewBoundary.githubAutoReview.evidenceTarget
295
- && arraysEqual(
296
- profile.nativeReviewBoundary.forbiddenSemanticSubstitutions,
297
- expectation.nativeReviewBoundary.forbiddenSemanticSubstitutions,
298
- )
299
- );
300
-
301
- const ok = profile.version === 1
302
- && profile.id in ADAPTER_PACKAGE_PROFILE_REFS
303
- && profile.hostClass === expectation.hostClass
304
- && profile.upstreamSeedProfile === expectation.upstreamSeedProfile
305
- && Boolean(profile.purpose)
306
- && arraysEqual(profile.semanticOwner, expectation.semanticOwner)
307
- && arraysEqual(profile.operationalOwner, expectation.operationalOwner)
308
- && arraysEqual(profile.admittedSkillSurfaces, expectation.admittedSkillSurfaces)
309
- && arraysEqual(profile.promptHandoff.bootstrapSurface, expectation.promptBootstrapSurface)
310
- && arraysEqual(profile.promptHandoff.futureSurface, expectation.promptFutureSurface)
311
- && profile.promptHandoff.futureSurfaceStatus === expectation.promptFutureSurfaceStatus
312
- && outputHandoffOk
313
- && nativeReviewOk
314
- && hardConstraintsOk;
315
-
316
- return {
317
- ok,
318
- reason: ok
319
- ? null
320
- : `${profile.profileRef} drifted away from the declared package-owned adapter overlay contract`,
321
- };
322
- }
323
-
324
- function serializeProfile(profile) {
325
- return {
326
- id: profile.id,
327
- profileRef: profile.profileRef,
328
- hostClass: profile.hostClass,
329
- upstreamSeedProfile: profile.upstreamSeedProfile,
330
- purpose: profile.purpose,
331
- semanticOwner: profile.semanticOwner,
332
- operationalOwner: profile.operationalOwner,
333
- admittedSkillSurfaces: profile.admittedSkillSurfaces,
334
- promptHandoff: profile.promptHandoff,
335
- outputHandoff: profile.outputHandoff,
336
- nativeReviewBoundary: profile.nativeReviewBoundary,
337
- hardConstraints: profile.hardConstraints,
338
- currentGaps: profile.currentGaps,
339
- ok: profile.ok,
340
- reason: profile.reason,
341
- };
342
- }
343
-
344
- export async function loadAdapterProfile(adapterId) {
345
- const profileRef = ADAPTER_PACKAGE_PROFILE_REFS[adapterId] ?? null;
346
- if (!profileRef) {
347
- return buildInvalidProfile(adapterId, null, `no package-owned adapter profile is declared for ${adapterId}`);
348
- }
349
-
350
- let rawText;
351
- try {
352
- rawText = await readFile(path.join(PACKAGE_ROOT, profileRef), "utf8");
353
- } catch {
354
- return buildInvalidProfile(adapterId, profileRef, `cannot read package-owned adapter profile ${profileRef}`);
355
- }
356
-
357
- const parsed = parseYamlText(rawText);
358
- if (!parsed) {
359
- return buildInvalidProfile(adapterId, profileRef, `package-owned adapter profile ${profileRef} is invalid YAML`);
360
- }
361
-
362
- const normalized = normalizeAdapterProfile(adapterId, profileRef, parsed);
363
- if (!normalized.ok) {
364
- return normalized;
365
- }
366
-
367
- if (normalized.id !== adapterId) {
368
- return buildInvalidProfile(adapterId, profileRef, `${profileRef} declares adapter id ${normalized.id ?? "unknown"} instead of ${adapterId}`);
369
- }
370
-
371
- const validation = validateAdapterProfile(normalized);
372
- if (!validation.ok) {
373
- return {
374
- ...normalized,
375
- ok: false,
376
- reason: validation.reason,
377
- };
378
- }
379
-
380
- return normalized;
381
- }
382
-
383
- export async function loadAdmittedAdapterProfiles(adapterIds) {
384
- const profiles = [];
385
-
386
- for (const adapterId of adapterIds) {
387
- profiles.push(await loadAdapterProfile(adapterId));
388
- }
389
-
390
- return {
391
- admitted: profiles.map((profile) => serializeProfile(profile)),
392
- invalid: profiles.filter((profile) => !profile.ok).map((profile) => serializeProfile(profile)),
393
- selected: null,
394
- };
395
- }
396
-
397
- export function selectAdapterProfile(adapterProfiles, selectedAdapterId) {
398
- if (!selectedAdapterId || selectedAdapterId === "none") {
399
- return null;
400
- }
401
-
402
- return adapterProfiles.admitted.find((profile) => profile.id === selectedAdapterId) ?? null;
403
- }
@@ -1,52 +0,0 @@
1
- import path from "node:path";
2
-
3
- import {
4
- AUDIT_EXECUTION_ARTIFACTS_CONFIG_REF,
5
- AUDIT_SWEEP_ARTIFACT_HARD_CONSTRAINTS,
6
- AUDIT_SWEEP_ARTIFACT_ROOTS,
7
- AUDIT_SWEEP_RESULT_CONTRACT_REF,
8
- HOST_ADAPTER_CONFIG_REF,
9
- } from "../constants.mjs";
10
- import { readTextIfFile } from "./fs-helpers.mjs";
11
- import { arraysEqual, isPlainObject, toStringArray } from "./value-helpers.mjs";
12
- import { parseYamlText } from "./yaml-helpers.mjs";
13
-
14
- function parseAuditExecutionArtifactsConfig(text) {
15
- const parsed = parseYamlText(text);
16
- const root = parsed?.audit_execution_artifacts;
17
- const artifactRoots = isPlainObject(root?.artifact_roots) ? root.artifact_roots : null;
18
- const hardConstraints = toStringArray(root?.hard_constraints);
19
-
20
- const artifactRootsOk = Boolean(artifactRoots)
21
- && Object.entries(AUDIT_SWEEP_ARTIFACT_ROOTS).every(
22
- ([field, expectedPath]) => String(artifactRoots[field] ?? "") === expectedPath,
23
- )
24
- && Object.keys(artifactRoots).length === Object.keys(AUDIT_SWEEP_ARTIFACT_ROOTS).length;
25
-
26
- return {
27
- ok: String(root?.skill_id ?? "") === "audit_sweep"
28
- && String(root?.host_adapter_ref ?? "") === HOST_ADAPTER_CONFIG_REF
29
- && String(root?.result_contract_ref ?? "") === AUDIT_SWEEP_RESULT_CONTRACT_REF
30
- && String(root?.locality ?? "") === "local_only"
31
- && artifactRootsOk
32
- && arraysEqual(hardConstraints, AUDIT_SWEEP_ARTIFACT_HARD_CONSTRAINTS),
33
- artifactRoots: artifactRootsOk
34
- ? Object.fromEntries(
35
- Object.entries(AUDIT_SWEEP_ARTIFACT_ROOTS).map(([field]) => [field, artifactRoots[field]]),
36
- )
37
- : null,
38
- hardConstraints,
39
- };
40
- }
41
-
42
- export async function loadAuditExecutionArtifactsConfig(projectRoot) {
43
- const text = await readTextIfFile(
44
- path.join(projectRoot, AUDIT_EXECUTION_ARTIFACTS_CONFIG_REF),
45
- );
46
-
47
- return {
48
- path: AUDIT_EXECUTION_ARTIFACTS_CONFIG_REF,
49
- text,
50
- ...parseAuditExecutionArtifactsConfig(text),
51
- };
52
- }