@nimiplatform/nimi-coding 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +348 -0
- package/adapters/README.md +25 -0
- package/adapters/claude/README.md +89 -0
- package/adapters/claude/profile.yaml +70 -0
- package/adapters/codex/README.md +53 -0
- package/adapters/codex/profile.yaml +78 -0
- package/adapters/oh-my-codex/README.md +185 -0
- package/adapters/oh-my-codex/profile.yaml +46 -0
- package/bin/nimicoding.mjs +6 -0
- package/cli/commands/admit-high-risk-decision.mjs +108 -0
- package/cli/commands/audit-sweep.mjs +341 -0
- package/cli/commands/blueprint-audit.mjs +91 -0
- package/cli/commands/clear.mjs +168 -0
- package/cli/commands/closeout.mjs +183 -0
- package/cli/commands/decide-high-risk-execution.mjs +124 -0
- package/cli/commands/doctor.mjs +53 -0
- package/cli/commands/generate-spec-derived-docs.mjs +131 -0
- package/cli/commands/handoff.mjs +123 -0
- package/cli/commands/ingest-high-risk-execution.mjs +95 -0
- package/cli/commands/review-high-risk-execution.mjs +95 -0
- package/cli/commands/start.mjs +717 -0
- package/cli/commands/topic-formatters.mjs +382 -0
- package/cli/commands/topic-goal.mjs +33 -0
- package/cli/commands/topic-options-shared.mjs +27 -0
- package/cli/commands/topic-options-workflow.mjs +767 -0
- package/cli/commands/topic-options.mjs +626 -0
- package/cli/commands/topic-runner.mjs +169 -0
- package/cli/commands/topic.mjs +795 -0
- package/cli/commands/validate-acceptance.mjs +5 -0
- package/cli/commands/validate-ai-governance.mjs +214 -0
- package/cli/commands/validate-execution-packet.mjs +5 -0
- package/cli/commands/validate-orchestration-state.mjs +5 -0
- package/cli/commands/validate-prompt.mjs +5 -0
- package/cli/commands/validate-spec-audit.mjs +27 -0
- package/cli/commands/validate-spec-governance.mjs +124 -0
- package/cli/commands/validate-spec-tree.mjs +27 -0
- package/cli/commands/validate-worker-output.mjs +5 -0
- package/cli/constants.mjs +489 -0
- package/cli/help.mjs +134 -0
- package/cli/index.mjs +103 -0
- package/cli/lib/adapter-profiles.mjs +403 -0
- package/cli/lib/audit-execution.mjs +52 -0
- package/cli/lib/audit-sweep-runtime/admissions.mjs +381 -0
- package/cli/lib/audit-sweep-runtime/audit-validity.mjs +333 -0
- package/cli/lib/audit-sweep-runtime/chunks.mjs +697 -0
- package/cli/lib/audit-sweep-runtime/closeout.mjs +144 -0
- package/cli/lib/audit-sweep-runtime/codex-auditor-evidence.mjs +639 -0
- package/cli/lib/audit-sweep-runtime/codex-auditor.mjs +515 -0
- package/cli/lib/audit-sweep-runtime/common.mjs +329 -0
- package/cli/lib/audit-sweep-runtime/coverage-quality.mjs +172 -0
- package/cli/lib/audit-sweep-runtime/evidence-assignment.mjs +152 -0
- package/cli/lib/audit-sweep-runtime/format.mjs +57 -0
- package/cli/lib/audit-sweep-runtime/ingest.mjs +486 -0
- package/cli/lib/audit-sweep-runtime/inventory-spec-chunks.mjs +198 -0
- package/cli/lib/audit-sweep-runtime/inventory.mjs +728 -0
- package/cli/lib/audit-sweep-runtime/ledger.mjs +315 -0
- package/cli/lib/audit-sweep-runtime/p0p1-profile.mjs +101 -0
- package/cli/lib/audit-sweep-runtime/remediation.mjs +349 -0
- package/cli/lib/audit-sweep-runtime/rerun.mjs +129 -0
- package/cli/lib/audit-sweep-runtime/risk-budget.mjs +300 -0
- package/cli/lib/audit-sweep-runtime/status.mjs +62 -0
- package/cli/lib/audit-sweep-runtime/validators-ledger.mjs +215 -0
- package/cli/lib/audit-sweep-runtime/validators.mjs +758 -0
- package/cli/lib/audit-sweep.mjs +18 -0
- package/cli/lib/authority-convergence.mjs +309 -0
- package/cli/lib/blueprint-audit.mjs +370 -0
- package/cli/lib/bootstrap.mjs +228 -0
- package/cli/lib/closeout.mjs +623 -0
- package/cli/lib/codex-sdk-runner.mjs +76 -0
- package/cli/lib/contracts.mjs +180 -0
- package/cli/lib/doctor.mjs +18 -0
- package/cli/lib/entrypoints.mjs +274 -0
- package/cli/lib/external-execution.mjs +101 -0
- package/cli/lib/fs-helpers.mjs +33 -0
- package/cli/lib/handoff.mjs +785 -0
- package/cli/lib/high-risk-admission.mjs +442 -0
- package/cli/lib/high-risk-decision.mjs +324 -0
- package/cli/lib/high-risk-ingest.mjs +317 -0
- package/cli/lib/high-risk-review.mjs +263 -0
- package/cli/lib/internal/contracts-loaders.mjs +132 -0
- package/cli/lib/internal/contracts-parse-high-risk.mjs +131 -0
- package/cli/lib/internal/contracts-parse.mjs +457 -0
- package/cli/lib/internal/contracts-validators.mjs +398 -0
- package/cli/lib/internal/doctor-bootstrap-surface.mjs +359 -0
- package/cli/lib/internal/doctor-delegated-surface.mjs +256 -0
- package/cli/lib/internal/doctor-finalize.mjs +385 -0
- package/cli/lib/internal/doctor-format.mjs +286 -0
- package/cli/lib/internal/doctor-inspectors.mjs +294 -0
- package/cli/lib/internal/doctor-state.mjs +205 -0
- package/cli/lib/internal/governance/ai/ai-context-budget-core.mjs +315 -0
- package/cli/lib/internal/governance/ai/ai-structure-budget-core.mjs +358 -0
- package/cli/lib/internal/governance/ai/check-agents-freshness.mjs +155 -0
- package/cli/lib/internal/governance/ai/check-high-risk-doc-metadata-core.mjs +173 -0
- package/cli/lib/internal/governance/config.mjs +150 -0
- package/cli/lib/internal/governance/runner.mjs +35 -0
- package/cli/lib/internal/governance/shared/read-yaml-with-fragments.mjs +49 -0
- package/cli/lib/internal/validators-artifacts.mjs +515 -0
- package/cli/lib/internal/validators-shared.mjs +28 -0
- package/cli/lib/internal/validators-spec-helpers.mjs +186 -0
- package/cli/lib/internal/validators-spec.mjs +410 -0
- package/cli/lib/shared.mjs +83 -0
- package/cli/lib/topic-draft-packets.mjs +48 -0
- package/cli/lib/topic-goal.mjs +361 -0
- package/cli/lib/topic-runner.mjs +772 -0
- package/cli/lib/topic.mjs +93 -0
- package/cli/lib/ui.mjs +178 -0
- package/cli/lib/validators.mjs +78 -0
- package/cli/lib/value-helpers.mjs +24 -0
- package/cli/lib/yaml-helpers.mjs +133 -0
- package/cli/nimicoding.mjs +1 -0
- package/cli/seeds/bootstrap.mjs +47 -0
- package/config/audit-execution-artifacts.yaml +20 -0
- package/config/bootstrap.yaml +6 -0
- package/config/external-execution-artifacts.yaml +16 -0
- package/config/host-adapter.yaml +30 -0
- package/config/host-profile.yaml +29 -0
- package/config/installer-evidence.yaml +31 -0
- package/config/skill-installer.yaml +23 -0
- package/config/skill-manifest.yaml +46 -0
- package/config/skills.yaml +30 -0
- package/config/spec-generation-inputs.yaml +25 -0
- package/contracts/acceptance.schema.yaml +16 -0
- package/contracts/admission-checklist.schema.yaml +15 -0
- package/contracts/audit-chunk.schema.yaml +110 -0
- package/contracts/audit-closeout.schema.yaml +51 -0
- package/contracts/audit-finding.schema.yaml +61 -0
- package/contracts/audit-ledger.schema.yaml +138 -0
- package/contracts/audit-plan.schema.yaml +123 -0
- package/contracts/audit-remediation-map.schema.yaml +51 -0
- package/contracts/audit-rerun.schema.yaml +31 -0
- package/contracts/audit-sweep-result.yaml +49 -0
- package/contracts/authority-convergence-audit.schema.yaml +19 -0
- package/contracts/closeout.schema.yaml +25 -0
- package/contracts/decision-review.schema.yaml +16 -0
- package/contracts/doc-spec-audit-result.yaml +19 -0
- package/contracts/execution-packet.schema.yaml +49 -0
- package/contracts/external-host-compatibility.yaml +22 -0
- package/contracts/forbidden-shortcuts.catalog.yaml +23 -0
- package/contracts/high-risk-admission.schema.yaml +23 -0
- package/contracts/high-risk-execution-result.yaml +20 -0
- package/contracts/orchestration-state.schema.yaml +41 -0
- package/contracts/overflow-continuation.schema.yaml +12 -0
- package/contracts/packet.schema.yaml +30 -0
- package/contracts/pending-note.schema.yaml +17 -0
- package/contracts/prompt.schema.yaml +12 -0
- package/contracts/remediation.schema.yaml +16 -0
- package/contracts/result.schema.yaml +24 -0
- package/contracts/spec-generation-audit.schema.yaml +31 -0
- package/contracts/spec-generation-inputs.schema.yaml +39 -0
- package/contracts/spec-reconstruction-result.yaml +37 -0
- package/contracts/topic-goal.schema.yaml +78 -0
- package/contracts/topic-run-ledger.schema.yaml +72 -0
- package/contracts/topic-step-decision.schema.yaml +45 -0
- package/contracts/topic.schema.yaml +65 -0
- package/contracts/true-close.schema.yaml +15 -0
- package/contracts/wave.schema.yaml +29 -0
- package/contracts/worker-output.schema.yaml +15 -0
- package/methodology/audit-sweep-p0p1-recall.yaml +45 -0
- package/methodology/authority-convergence-policy.yaml +42 -0
- package/methodology/core.yaml +25 -0
- package/methodology/four-closure-policy.yaml +28 -0
- package/methodology/overflow-continuation-policy.yaml +14 -0
- package/methodology/role-separation-policy.yaml +28 -0
- package/methodology/skill-exchange-projection.yaml +114 -0
- package/methodology/skill-handoff.yaml +34 -0
- package/methodology/skill-installer-result.yaml +27 -0
- package/methodology/skill-installer-summary-projection.yaml +181 -0
- package/methodology/skill-runtime.yaml +23 -0
- package/methodology/spec-reconstruction.yaml +63 -0
- package/methodology/spec-target-truth-profile.yaml +53 -0
- package/methodology/topic-lifecycle-report.yaml +144 -0
- package/methodology/topic-lifecycle.yaml +37 -0
- package/methodology/topic-naming-ontology.yaml +21 -0
- package/methodology/topic-ontology.yaml +38 -0
- package/methodology/topic-validation-policy.yaml +9 -0
- package/methodology/wave-dag-policy.yaml +14 -0
- package/package.json +50 -0
- package/spec/_meta/command-gating-matrix.yaml +110 -0
- package/spec/_meta/generate-drift-migration-checklist.yaml +155 -0
- package/spec/_meta/governance-routing-cutover-checklist.yaml +35 -0
- package/spec/_meta/phase2-impacted-surface-matrix.yaml +44 -0
- package/spec/_meta/spec-authority-cutover-readiness.yaml +104 -0
- package/spec/_meta/spec-tree-model.yaml +72 -0
- package/spec/bootstrap-state.yaml +99 -0
- package/spec/product-scope.yaml +56 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { realpath } from "node:fs/promises";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
AGENTS_BEGIN,
|
|
7
|
+
AUDIT_SWEEP_RESULT_CONTRACT_REF,
|
|
8
|
+
CLAUDE_BEGIN,
|
|
9
|
+
EXTERNAL_HOST_COMPATIBILITY_CONTRACT_REF,
|
|
10
|
+
HIGH_RISK_ADMISSION_CONTRACT_REF,
|
|
11
|
+
STANDALONE_COMPLETION_STATUS,
|
|
12
|
+
} from "../../constants.mjs";
|
|
13
|
+
import {
|
|
14
|
+
loadAdmittedAdapterProfiles,
|
|
15
|
+
selectAdapterProfile,
|
|
16
|
+
} from "../adapter-profiles.mjs";
|
|
17
|
+
import {
|
|
18
|
+
loadAuditSweepContract,
|
|
19
|
+
loadDocSpecAuditContract,
|
|
20
|
+
loadExternalHostCompatibilityContract,
|
|
21
|
+
loadHighRiskAdmissionContract,
|
|
22
|
+
loadHighRiskExecutionContract,
|
|
23
|
+
loadHighRiskSchemaContracts,
|
|
24
|
+
loadSpecReconstructionContract,
|
|
25
|
+
validateHighRiskAdmissionsSpec,
|
|
26
|
+
} from "../contracts.mjs";
|
|
27
|
+
import { loadAuditExecutionArtifactsConfig } from "../audit-execution.mjs";
|
|
28
|
+
import { loadExternalExecutionArtifactsConfig } from "../external-execution.mjs";
|
|
29
|
+
import { pathExists, readTextIfFile } from "../fs-helpers.mjs";
|
|
30
|
+
import { parseYamlText } from "../yaml-helpers.mjs";
|
|
31
|
+
import { buildCheck } from "./doctor-state.mjs";
|
|
32
|
+
import {
|
|
33
|
+
buildHostCompatibilityReport,
|
|
34
|
+
inspectLocalDocSpecAuditArtifact,
|
|
35
|
+
inspectPackageBoundaryTruth,
|
|
36
|
+
} from "./doctor-inspectors.mjs";
|
|
37
|
+
|
|
38
|
+
const PACKAGE_REPO_ROOT = fileURLToPath(new URL("../../..", import.meta.url));
|
|
39
|
+
|
|
40
|
+
export async function finalizeDoctorState(projectRoot, bootstrapSurface, delegatedSurface) {
|
|
41
|
+
const checks = [...bootstrapSurface.checks, ...delegatedSurface.checks];
|
|
42
|
+
|
|
43
|
+
const specContract = await loadSpecReconstructionContract(projectRoot);
|
|
44
|
+
const auditContract = await loadDocSpecAuditContract(projectRoot);
|
|
45
|
+
const auditSweepContract = await loadAuditSweepContract(projectRoot);
|
|
46
|
+
const externalHostCompatibilityContract = await loadExternalHostCompatibilityContract(projectRoot);
|
|
47
|
+
const highRiskExecutionContract = await loadHighRiskExecutionContract(projectRoot);
|
|
48
|
+
const highRiskAdmissionContract = await loadHighRiskAdmissionContract(projectRoot);
|
|
49
|
+
const auditExecutionArtifacts = await loadAuditExecutionArtifactsConfig(projectRoot);
|
|
50
|
+
const externalExecutionArtifacts = await loadExternalExecutionArtifactsConfig(projectRoot);
|
|
51
|
+
const highRiskSchemaContracts = await loadHighRiskSchemaContracts(projectRoot);
|
|
52
|
+
checks.push(
|
|
53
|
+
buildCheck(
|
|
54
|
+
"spec_reconstruction_result_contract",
|
|
55
|
+
specContract.ok,
|
|
56
|
+
specContract.ok
|
|
57
|
+
? "spec-reconstruction result contract is present and structurally valid"
|
|
58
|
+
: "spec-reconstruction result contract is missing or malformed",
|
|
59
|
+
),
|
|
60
|
+
);
|
|
61
|
+
checks.push(
|
|
62
|
+
buildCheck(
|
|
63
|
+
"doc_spec_audit_result_contract",
|
|
64
|
+
auditContract.ok,
|
|
65
|
+
auditContract.ok
|
|
66
|
+
? "doc-spec-audit result contract is present and structurally valid"
|
|
67
|
+
: "doc-spec-audit result contract is missing or malformed",
|
|
68
|
+
),
|
|
69
|
+
);
|
|
70
|
+
checks.push(
|
|
71
|
+
buildCheck(
|
|
72
|
+
"audit_sweep_result_contract",
|
|
73
|
+
auditSweepContract.ok,
|
|
74
|
+
auditSweepContract.ok
|
|
75
|
+
? "audit-sweep result contract is present and structurally valid"
|
|
76
|
+
: `${AUDIT_SWEEP_RESULT_CONTRACT_REF} is missing or malformed`,
|
|
77
|
+
),
|
|
78
|
+
);
|
|
79
|
+
checks.push(
|
|
80
|
+
buildCheck(
|
|
81
|
+
"external_host_compatibility_contract",
|
|
82
|
+
externalHostCompatibilityContract.ok,
|
|
83
|
+
externalHostCompatibilityContract.ok
|
|
84
|
+
? "Packaged external host compatibility contract is present and aligned"
|
|
85
|
+
: `${EXTERNAL_HOST_COMPATIBILITY_CONTRACT_REF} is missing or malformed`,
|
|
86
|
+
),
|
|
87
|
+
);
|
|
88
|
+
checks.push(
|
|
89
|
+
buildCheck(
|
|
90
|
+
"high_risk_execution_result_contract",
|
|
91
|
+
highRiskExecutionContract.ok,
|
|
92
|
+
highRiskExecutionContract.ok
|
|
93
|
+
? "high-risk-execution result contract is present and structurally valid"
|
|
94
|
+
: "high-risk-execution result contract is missing or malformed",
|
|
95
|
+
),
|
|
96
|
+
);
|
|
97
|
+
checks.push(
|
|
98
|
+
buildCheck(
|
|
99
|
+
"high_risk_admission_contract",
|
|
100
|
+
highRiskAdmissionContract.ok,
|
|
101
|
+
highRiskAdmissionContract.ok
|
|
102
|
+
? "Packaged high-risk admission schema contract is present and aligned"
|
|
103
|
+
: `${HIGH_RISK_ADMISSION_CONTRACT_REF} is missing or malformed`,
|
|
104
|
+
),
|
|
105
|
+
);
|
|
106
|
+
checks.push(
|
|
107
|
+
buildCheck(
|
|
108
|
+
"audit_execution_artifacts_contract",
|
|
109
|
+
auditExecutionArtifacts.ok,
|
|
110
|
+
auditExecutionArtifacts.ok
|
|
111
|
+
? "audit execution artifact landing-path contract is present and structurally valid"
|
|
112
|
+
: "audit execution artifact landing-path contract is missing or malformed",
|
|
113
|
+
),
|
|
114
|
+
);
|
|
115
|
+
checks.push(
|
|
116
|
+
buildCheck(
|
|
117
|
+
"external_execution_artifacts_contract",
|
|
118
|
+
externalExecutionArtifacts.ok,
|
|
119
|
+
externalExecutionArtifacts.ok
|
|
120
|
+
? "external execution artifact landing-path contract is present and structurally valid"
|
|
121
|
+
: "external execution artifact landing-path contract is missing or malformed",
|
|
122
|
+
),
|
|
123
|
+
);
|
|
124
|
+
checks.push(
|
|
125
|
+
buildCheck(
|
|
126
|
+
"high_risk_schema_contracts",
|
|
127
|
+
highRiskSchemaContracts.every((entry) => entry.ok),
|
|
128
|
+
highRiskSchemaContracts.every((entry) => entry.ok)
|
|
129
|
+
? "High-risk execution schema seeds are present and structurally valid"
|
|
130
|
+
: `High-risk execution schema seeds are missing or malformed: ${highRiskSchemaContracts.filter((entry) => !entry.ok).map((entry) => entry.path).join(", ")}`,
|
|
131
|
+
),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
let highRiskAdmissionsTruthValid = true;
|
|
135
|
+
const admissionsTruthRef = ".nimi/spec/high-risk-admissions.yaml";
|
|
136
|
+
const admissionsInfo = await pathExists(path.join(projectRoot, admissionsTruthRef));
|
|
137
|
+
if (admissionsInfo && admissionsInfo.isFile()) {
|
|
138
|
+
const admissionsTruthText = await readTextIfFile(path.join(projectRoot, admissionsTruthRef));
|
|
139
|
+
const admissionsTruthParsed = admissionsTruthText ? parseYamlText(admissionsTruthText) : null;
|
|
140
|
+
const admissionsTruthValidation = highRiskAdmissionContract.ok
|
|
141
|
+
? validateHighRiskAdmissionsSpec(admissionsTruthParsed, highRiskAdmissionContract)
|
|
142
|
+
: {
|
|
143
|
+
ok: false,
|
|
144
|
+
reason: `${HIGH_RISK_ADMISSION_CONTRACT_REF} is missing or malformed`,
|
|
145
|
+
};
|
|
146
|
+
highRiskAdmissionsTruthValid = admissionsTruthValidation.ok;
|
|
147
|
+
checks.push(
|
|
148
|
+
buildCheck(
|
|
149
|
+
"high_risk_admissions_truth",
|
|
150
|
+
admissionsTruthValidation.ok,
|
|
151
|
+
admissionsTruthValidation.ok
|
|
152
|
+
? "Canonical high-risk admissions truth satisfies the packaged admission schema contract"
|
|
153
|
+
: `Canonical high-risk admissions truth drifted: ${admissionsTruthValidation.reason}`,
|
|
154
|
+
),
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const adapterProfiles = await loadAdmittedAdapterProfiles(delegatedSurface.admittedAdapterIds);
|
|
159
|
+
adapterProfiles.selected = selectAdapterProfile(adapterProfiles, delegatedSurface.selectedAdapterId);
|
|
160
|
+
const adapterProfilesValid = adapterProfiles.invalid.length === 0;
|
|
161
|
+
checks.push(
|
|
162
|
+
buildCheck(
|
|
163
|
+
"adapter_profile_overlays",
|
|
164
|
+
adapterProfilesValid,
|
|
165
|
+
adapterProfilesValid
|
|
166
|
+
? adapterProfiles.admitted.length === 0
|
|
167
|
+
? "No package-owned adapter profile overlays are currently admitted"
|
|
168
|
+
: `Package-owned adapter profile overlays are present and valid: ${adapterProfiles.admitted.map((profile) => profile.id).join(", ")}`
|
|
169
|
+
: `Package-owned adapter profile overlays are missing or malformed: ${adapterProfiles.invalid.map((profile) => `${profile.id} -> ${profile.reason}`).join(", ")}`,
|
|
170
|
+
),
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const lifecycleAligned = (
|
|
174
|
+
bootstrapSurface.bootstrapStateContract.treeState === "bootstrap_only"
|
|
175
|
+
&& bootstrapSurface.canonicalTree.ready === false
|
|
176
|
+
) || (
|
|
177
|
+
bootstrapSurface.bootstrapStateContract.treeState === "spec_tree_seeded"
|
|
178
|
+
&& bootstrapSurface.canonicalTree.ready === false
|
|
179
|
+
) || (
|
|
180
|
+
bootstrapSurface.bootstrapStateContract.treeState === "canonical_tree_in_progress"
|
|
181
|
+
&& bootstrapSurface.canonicalTree.ready === false
|
|
182
|
+
) || (
|
|
183
|
+
bootstrapSurface.bootstrapStateContract.treeState === "canonical_tree_ready"
|
|
184
|
+
&& bootstrapSurface.canonicalTree.requiredFilesValid === true
|
|
185
|
+
);
|
|
186
|
+
checks.push(
|
|
187
|
+
buildCheck(
|
|
188
|
+
"bootstrap_lifecycle_alignment",
|
|
189
|
+
lifecycleAligned,
|
|
190
|
+
lifecycleAligned
|
|
191
|
+
? `bootstrap-state lifecycle ${bootstrapSurface.bootstrapStateContract.treeState ?? "unknown"} is aligned with the current canonical tree readiness`
|
|
192
|
+
: bootstrapSurface.bootstrapStateContract.treeState === "canonical_tree_ready"
|
|
193
|
+
? "bootstrap-state declares canonical_tree_ready but required canonical files are still missing"
|
|
194
|
+
: "bootstrap-state lifecycle drifted away from the current canonical tree readiness",
|
|
195
|
+
),
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const auditArtifact = await inspectLocalDocSpecAuditArtifact(projectRoot, auditContract);
|
|
199
|
+
checks.push({
|
|
200
|
+
id: "doc_spec_audit_artifact",
|
|
201
|
+
ok: !auditArtifact.present || auditArtifact.ok,
|
|
202
|
+
severity: !auditArtifact.present ? "info" : auditArtifact.ok ? "ok" : "warn",
|
|
203
|
+
detail: auditArtifact.reason,
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const auditArtifactConsistent = !auditArtifact.present
|
|
207
|
+
|| auditArtifact.outcome !== "completed"
|
|
208
|
+
|| bootstrapSurface.canonicalTree.requiredFilesValid;
|
|
209
|
+
checks.push(
|
|
210
|
+
buildCheck(
|
|
211
|
+
"doc_spec_audit_state_alignment",
|
|
212
|
+
auditArtifactConsistent,
|
|
213
|
+
auditArtifactConsistent
|
|
214
|
+
? "Local doc_spec_audit artifact is consistent with the current reconstruction state"
|
|
215
|
+
: "Completed local doc_spec_audit artifact requires the canonical tree to remain ready",
|
|
216
|
+
),
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
const entrypointStatuses = [];
|
|
220
|
+
for (const [relativePath, beginToken] of [
|
|
221
|
+
["AGENTS.md", AGENTS_BEGIN],
|
|
222
|
+
["CLAUDE.md", CLAUDE_BEGIN],
|
|
223
|
+
]) {
|
|
224
|
+
const entryText = await readTextIfFile(path.join(projectRoot, relativePath));
|
|
225
|
+
if (entryText && entryText.includes(beginToken)) {
|
|
226
|
+
entrypointStatuses.push(relativePath);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
checks.push({
|
|
230
|
+
id: "entrypoint_integration",
|
|
231
|
+
ok: true,
|
|
232
|
+
severity: "info",
|
|
233
|
+
detail: entrypointStatuses.length === 0
|
|
234
|
+
? "No managed AI entrypoint blocks detected; this is optional"
|
|
235
|
+
: `Managed AI entrypoint blocks detected in: ${entrypointStatuses.join(", ")}`,
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
let packageBoundaryTruthOk = true;
|
|
239
|
+
let packageSelfAuditActive = false;
|
|
240
|
+
try {
|
|
241
|
+
packageSelfAuditActive = (await realpath(projectRoot)) === (await realpath(PACKAGE_REPO_ROOT));
|
|
242
|
+
} catch {
|
|
243
|
+
packageSelfAuditActive = false;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (packageSelfAuditActive) {
|
|
247
|
+
const boundariesText = await readTextIfFile(path.join(projectRoot, ".nimi", "spec", "boundaries.yaml"));
|
|
248
|
+
const changePolicyText = await readTextIfFile(path.join(projectRoot, ".nimi", "spec", "change-policy.yaml"));
|
|
249
|
+
const packageBoundaryTruth = inspectPackageBoundaryTruth(boundariesText, changePolicyText);
|
|
250
|
+
packageBoundaryTruthOk = packageBoundaryTruth.ok;
|
|
251
|
+
checks.push(
|
|
252
|
+
buildCheck(
|
|
253
|
+
"package_boundary_truth",
|
|
254
|
+
packageBoundaryTruth.ok,
|
|
255
|
+
packageBoundaryTruth.ok
|
|
256
|
+
? "Repo-local boundaries and change-policy keep runtime surfaces explicitly deferred under the boundary-complete standalone posture"
|
|
257
|
+
: "Repo-local boundaries or change-policy drifted away from the declared boundary-complete standalone posture",
|
|
258
|
+
),
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const hasErrors = checks.some((check) => check.severity === "error");
|
|
263
|
+
const reconstructionRequired = bootstrapSurface.bootstrapStateContract.reconstructionRequired === true;
|
|
264
|
+
|
|
265
|
+
const handoffReadiness = {
|
|
266
|
+
ok: delegatedSurface.handoffContextOk
|
|
267
|
+
&& delegatedSurface.referenceChecks.every(Boolean)
|
|
268
|
+
&& delegatedSurface.contractRuntimeOwnersAligned
|
|
269
|
+
&& delegatedSurface.delegatedModeAligned
|
|
270
|
+
&& delegatedSurface.selfHostedAligned
|
|
271
|
+
&& bootstrapSurface.completionTruth.ok
|
|
272
|
+
&& delegatedSurface.resultContractAlignment
|
|
273
|
+
&& delegatedSurface.adapterSelectionValid
|
|
274
|
+
&& adapterProfilesValid
|
|
275
|
+
&& delegatedSurface.adapterBoundaryAligned
|
|
276
|
+
&& specContract.ok
|
|
277
|
+
&& auditContract.ok
|
|
278
|
+
&& externalHostCompatibilityContract.ok
|
|
279
|
+
&& highRiskExecutionContract.ok
|
|
280
|
+
&& highRiskAdmissionContract.ok
|
|
281
|
+
&& highRiskAdmissionsTruthValid
|
|
282
|
+
&& externalExecutionArtifacts.ok
|
|
283
|
+
&& packageBoundaryTruthOk
|
|
284
|
+
&& bootstrapSurface.specTreeModel.ok
|
|
285
|
+
&& bootstrapSurface.specGenerationInputsContract.ok
|
|
286
|
+
&& bootstrapSurface.specGenerationAuditContract.ok
|
|
287
|
+
&& bootstrapSurface.specGenerationInputs.ok
|
|
288
|
+
&& (!bootstrapSurface.canonicalTree.requiredFilesValid || bootstrapSurface.specGenerationAudit.ok)
|
|
289
|
+
&& bootstrapSurface.commandGatingMatrix.ok
|
|
290
|
+
&& bootstrapSurface.blueprintReferenceAligned
|
|
291
|
+
&& lifecycleAligned,
|
|
292
|
+
requiredContextOrder: delegatedSurface.handoffRequiredContext,
|
|
293
|
+
missingContextEntries: delegatedSurface.missingHandoffContextEntries,
|
|
294
|
+
missingPaths: delegatedSurface.missingHandoffPaths,
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const nextSteps = [];
|
|
298
|
+
if (hasErrors) {
|
|
299
|
+
nextSteps.push("Repair the failing bootstrap checks, then rerun `nimicoding doctor`.");
|
|
300
|
+
} else if (!bootstrapSurface.canonicalTree.requiredFilesValid) {
|
|
301
|
+
nextSteps.push("Use an external AI host to reconstruct the declared canonical tree under `.nimi/spec`.");
|
|
302
|
+
}
|
|
303
|
+
if (bootstrapSurface.canonicalTree.requiredFilesValid && bootstrapSurface.benchmarkAuditReadiness.ready) {
|
|
304
|
+
nextSteps.push("Run `nimicoding blueprint-audit --write-local` after canonical tree generation when a benchmark blueprint is declared.");
|
|
305
|
+
}
|
|
306
|
+
if (bootstrapSurface.canonicalTree.requiredFilesValid && !bootstrapSurface.specGenerationAudit.ok) {
|
|
307
|
+
nextSteps.push("Run `nimicoding validate-spec-audit` after generating `.nimi/spec/_meta/spec-generation-audit.yaml` for the canonical tree.");
|
|
308
|
+
}
|
|
309
|
+
if (!auditArtifact.present && bootstrapSurface.canonicalTree.requiredFilesValid) {
|
|
310
|
+
nextSteps.push("Run `nimicoding handoff --skill doc_spec_audit` and close out the result locally when the audit is complete.");
|
|
311
|
+
}
|
|
312
|
+
if (!delegatedSurface.runtimeInstalled) {
|
|
313
|
+
nextSteps.push("Keep runtime ownership delegated; do not assume local skill installation or self-hosting.");
|
|
314
|
+
}
|
|
315
|
+
if (!delegatedSurface.adapterSelected && !hasErrors) {
|
|
316
|
+
nextSteps.push("If you want a constrained external execution host, select one in `.nimi/config/host-adapter.yaml`.");
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const executionContracts = {
|
|
320
|
+
total: highRiskSchemaContracts.length,
|
|
321
|
+
valid: highRiskSchemaContracts.filter((entry) => entry.ok).length,
|
|
322
|
+
invalid: highRiskSchemaContracts
|
|
323
|
+
.filter((entry) => !entry.ok)
|
|
324
|
+
.map((entry) => entry.path),
|
|
325
|
+
contracts: highRiskSchemaContracts.map((entry) => ({
|
|
326
|
+
path: entry.path,
|
|
327
|
+
ok: entry.ok,
|
|
328
|
+
})),
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
const completionStatus = !bootstrapSurface.completionTruth.ok || !packageBoundaryTruthOk
|
|
332
|
+
? STANDALONE_COMPLETION_STATUS.DRIFTED
|
|
333
|
+
: !hasErrors
|
|
334
|
+
? STANDALONE_COMPLETION_STATUS.COMPLETE
|
|
335
|
+
: STANDALONE_COMPLETION_STATUS.INCOMPLETE;
|
|
336
|
+
|
|
337
|
+
const hostCompatibility = buildHostCompatibilityReport(
|
|
338
|
+
externalHostCompatibilityContract,
|
|
339
|
+
adapterProfiles,
|
|
340
|
+
delegatedSurface.selectedAdapterId,
|
|
341
|
+
);
|
|
342
|
+
|
|
343
|
+
return {
|
|
344
|
+
projectRoot,
|
|
345
|
+
ok: !hasErrors,
|
|
346
|
+
bootstrapPresent: true,
|
|
347
|
+
reconstructionRequired,
|
|
348
|
+
runtimeInstalled: delegatedSurface.runtimeInstalled,
|
|
349
|
+
bootstrapContract: {
|
|
350
|
+
status: bootstrapSurface.bootstrapCompatibility.status,
|
|
351
|
+
id: bootstrapSurface.bootstrapCompatibility.contractId,
|
|
352
|
+
version: bootstrapSurface.bootstrapCompatibility.contractVersion,
|
|
353
|
+
},
|
|
354
|
+
lifecycleState: {
|
|
355
|
+
mode: bootstrapSurface.bootstrapStateContract.mode,
|
|
356
|
+
treeState: bootstrapSurface.bootstrapStateContract.treeState,
|
|
357
|
+
authorityMode: bootstrapSurface.bootstrapStateContract.authorityMode,
|
|
358
|
+
blueprintMode: bootstrapSurface.bootstrapStateContract.blueprintMode,
|
|
359
|
+
reconstructionRequired: bootstrapSurface.bootstrapStateContract.reconstructionRequired,
|
|
360
|
+
readyForAiReconstruction: bootstrapSurface.bootstrapStateContract.readyForAiReconstruction,
|
|
361
|
+
cutoverReadiness: bootstrapSurface.bootstrapStateContract.cutoverReadiness,
|
|
362
|
+
activeAuthorityRoot: bootstrapSurface.bootstrapStateContract.activeAuthorityRoot,
|
|
363
|
+
},
|
|
364
|
+
specTreeModel: bootstrapSurface.specTreeModel,
|
|
365
|
+
specGenerationInputs: bootstrapSurface.specGenerationInputs,
|
|
366
|
+
canonicalTree: bootstrapSurface.canonicalTree,
|
|
367
|
+
specGenerationAudit: bootstrapSurface.specGenerationAudit,
|
|
368
|
+
commandGating: bootstrapSurface.commandGatingMatrix,
|
|
369
|
+
blueprintReference: bootstrapSurface.blueprintReference,
|
|
370
|
+
benchmarkAuditReadiness: bootstrapSurface.benchmarkAuditReadiness,
|
|
371
|
+
completionProfile: bootstrapSurface.completionTruth.completionProfile,
|
|
372
|
+
completionStatus,
|
|
373
|
+
completedSurfaces: bootstrapSurface.completionTruth.completedSurfaces,
|
|
374
|
+
deferredExecutionSurfaces: bootstrapSurface.completionTruth.deferredExecutionSurfaces,
|
|
375
|
+
promotedParityGapSummary: bootstrapSurface.completionTruth.promotedParityGapSummary,
|
|
376
|
+
hostCompatibility,
|
|
377
|
+
delegatedContracts: delegatedSurface.delegatedContracts,
|
|
378
|
+
adapterProfiles,
|
|
379
|
+
handoffReadiness,
|
|
380
|
+
checks,
|
|
381
|
+
auditArtifact,
|
|
382
|
+
executionContracts,
|
|
383
|
+
nextSteps,
|
|
384
|
+
};
|
|
385
|
+
}
|