arkgate 4.8.23 → 4.8.25
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/CHANGELOG.md +153 -0
- package/README.md +7 -5
- package/bin/ark-check-runtime.mjs +41 -91
- package/bin/ark-dashboard.mjs +56 -53
- package/bin/ark-layer-match.mjs +707 -121
- package/bin/ark-mcp-runtime.mjs +448 -169
- package/bin/ark-mcp.mjs +68 -4
- package/bin/ark-shared.mjs +42 -22
- package/bin/ark.mjs +65 -97
- package/bin/lib/adapter-contract-types.mjs +5 -0
- package/bin/lib/adapter-contract.mjs +15 -0
- package/bin/lib/adoption-stance.mjs +2 -2
- package/bin/lib/adr-path.mjs +3 -3
- package/bin/lib/agent-gates.mjs +0 -61
- package/bin/lib/agent-homes.mjs +12 -21
- package/bin/lib/agent-projection-command.mjs +9 -5
- package/bin/lib/ambient-state.mjs +9 -30
- package/bin/lib/analysis-engine.mjs +15 -11
- package/bin/lib/architecture-scan.mjs +61 -15
- package/bin/lib/ark-order-doctor.mjs +4 -29
- package/bin/lib/ark-order-facts.mjs +319 -17
- package/bin/lib/ark-order-sensors.mjs +28 -101
- package/bin/lib/ark-order-types.mjs +3 -2
- package/bin/lib/ark-run-doctor.mjs +17 -28
- package/bin/lib/ark-run-facts.mjs +461 -48
- package/bin/lib/ark-run-sensors.mjs +6 -4
- package/bin/lib/arkgate-pins.mjs +91 -0
- package/bin/lib/arkrule-file-hints.mjs +2 -47
- package/bin/lib/arkrules-contract.mjs +124 -133
- package/bin/lib/arkrules-sensors.mjs +55 -252
- package/bin/lib/check-args.mjs +85 -1
- package/bin/lib/ci-and-commands.mjs +24 -78
- package/bin/lib/ci-merge-boundary.mjs +1 -1
- package/bin/lib/class-source-scan.mjs +479 -0
- package/bin/lib/clone-detection.mjs +474 -0
- package/bin/lib/codex-home.mjs +5 -3
- package/bin/lib/config-contract-slices.mjs +739 -0
- package/bin/lib/config-contract.mjs +42 -607
- package/bin/lib/config-extras.mjs +16 -22
- package/bin/lib/config-warnings.mjs +32 -0
- package/bin/lib/contract-smells.mjs +33 -15
- package/bin/lib/core-ratchet.mjs +0 -2
- package/bin/lib/dashboard-cli.mjs +62 -0
- package/bin/lib/deep-module-coach.mjs +2 -4
- package/bin/lib/deploy-path.mjs +13 -38
- package/bin/lib/design-delta.mjs +1 -1
- package/bin/lib/design-smells.mjs +2 -2
- package/bin/lib/diagnostic-catalog.mjs +23 -9
- package/bin/lib/doctor-advisories.mjs +78 -8
- package/bin/lib/doctor-green-cite.mjs +1 -1
- package/bin/lib/doctor-human.mjs +1 -1
- package/bin/lib/doctor-next-actions.mjs +19 -4
- package/bin/lib/doctor-plan.mjs +9 -13
- package/bin/lib/duplication-io.mjs +572 -0
- package/bin/lib/effective-contract-load.mjs +282 -83
- package/bin/lib/enforcement-profiles.mjs +40 -4
- package/bin/lib/entry-points-io.mjs +424 -0
- package/bin/lib/extra-merge-teeth.mjs +36 -0
- package/bin/lib/field-install.mjs +38 -14
- package/bin/lib/first-run-help.mjs +10 -5
- package/bin/lib/flat-parent-importers.mjs +139 -0
- package/bin/lib/flat-parent-pilot.mjs +40 -100
- package/bin/lib/gate-files.mjs +58 -90
- package/bin/lib/git-change-scope.mjs +109 -0
- package/bin/lib/github-enforcement.mjs +166 -29
- package/bin/lib/golden-pattern.mjs +1 -1
- package/bin/lib/hook-templates.mjs +17 -15
- package/bin/lib/host-support-matrix.mjs +3 -1
- package/bin/lib/html-report-advisories.mjs +4 -0
- package/bin/lib/html-report-depth.mjs +2 -2
- package/bin/lib/html-report.mjs +2 -2
- package/bin/lib/import-graph-projection.mjs +112 -0
- package/bin/lib/import-resolve.mjs +13 -1
- package/bin/lib/improvement-compass-doctor.mjs +1 -24
- package/bin/lib/install-migrate.mjs +50 -73
- package/bin/lib/invariant-coverage-io.mjs +4 -3
- package/bin/lib/invariant-coverage.mjs +85 -11
- package/bin/lib/invariant-probe-cli.mjs +347 -0
- package/bin/lib/invariant-probe-io.mjs +165 -0
- package/bin/lib/invariant-probe-runner.mjs +268 -0
- package/bin/lib/invariant-probe-sites.mjs +174 -0
- package/bin/lib/invariant-probe-workspace.mjs +183 -0
- package/bin/lib/invariant-probe.mjs +461 -0
- package/bin/lib/invariant-tests-path.mjs +16 -22
- package/bin/lib/literal-path-drift.mjs +4 -2
- package/bin/lib/managed-upgrade.mjs +2 -8
- package/bin/lib/mcp-adoption.mjs +13 -6
- package/bin/lib/mcp-hook-payload.mjs +403 -63
- package/bin/lib/orphan-modules-io.mjs +458 -0
- package/bin/lib/orphan-modules.mjs +251 -0
- package/bin/lib/outside-importers.mjs +197 -0
- package/bin/lib/package-manager.mjs +60 -2
- package/bin/lib/parse-health.mjs +1 -1
- package/bin/lib/passthrough-commands.mjs +83 -0
- package/bin/lib/persistence-write-hint.mjs +106 -0
- package/bin/lib/pin-dependent-gates.mjs +117 -0
- package/bin/lib/policy-delta-io.mjs +219 -14
- package/bin/lib/post-green-path.mjs +1 -1
- package/bin/lib/prepare-change.mjs +115 -7
- package/bin/lib/prepare-write.mjs +2 -2
- package/bin/lib/presets.mjs +59 -73
- package/bin/lib/product-copy.mjs +1 -6
- package/bin/lib/project-root.mjs +31 -62
- package/bin/lib/remediation.mjs +23 -4
- package/bin/lib/resolved-candidate-facts.mjs +405 -117
- package/bin/lib/rules-inventory.mjs +22 -3
- package/bin/lib/rules-under-contract.mjs +247 -9
- package/bin/lib/scan-files.mjs +36 -4
- package/bin/lib/schema-validation.mjs +130 -0
- package/bin/lib/sensor-promote-cli.mjs +2 -11
- package/bin/lib/sensor-promote-io.mjs +33 -22
- package/bin/lib/sensor-promotion.mjs +1 -1
- package/bin/lib/skill-catalog-apply.mjs +1 -1
- package/bin/lib/skill-install.mjs +42 -38
- package/bin/lib/snippet-analysis.mjs +140 -6
- package/bin/lib/source-policy.mjs +34 -0
- package/bin/lib/start-install-recovery.mjs +72 -2
- package/bin/lib/start-preview.mjs +31 -1
- package/bin/lib/states-transitions-presence.mjs +3 -3
- package/bin/lib/status-command.mjs +35 -22
- package/bin/lib/status-manifest.mjs +50 -30
- package/bin/lib/status-transition-catalog.mjs +0 -6
- package/bin/lib/suggestions.mjs +3 -3
- package/bin/lib/team-parliament-io.mjs +76 -88
- package/bin/lib/team-parliament.mjs +21 -10
- package/bin/lib/upgrade-behavior-changes.mjs +2 -2
- package/bin/lib/upgrade-command.mjs +2 -24
- package/bin/lib/upgrade-outcome.mjs +1 -1
- package/bin/lib/upstream-report.mjs +21 -10
- package/bin/lib/violations.mjs +10 -9
- package/bin/lib/weakest-link.mjs +13 -0
- package/bin/lib/write-path-capabilities.mjs +6 -4
- package/dist/chunk-A5EIY3HI.cjs +5 -0
- package/dist/chunk-AHACEKSV.js +16 -0
- package/dist/chunk-SVSQVGFJ.js +5 -0
- package/dist/chunk-UN5EH4QV.cjs +16 -0
- package/dist/{configTypes-Bbf_MFGe.d.ts → configTypes-GPvvdleM.d.cts} +30 -4
- package/dist/configTypes-GPvvdleM.d.ts +257 -0
- package/dist/eslint/index.cjs +18 -5
- package/dist/eslint/index.d.cts +368 -0
- package/dist/eslint/index.d.ts +139 -156
- package/dist/eslint/index.js +11 -5
- package/dist/index.cjs +36 -35
- package/dist/index.d.cts +5547 -0
- package/dist/index.d.ts +3283 -198
- package/dist/index.js +36 -35
- package/dist/inspectorListen-6DQVJ4DC.js +1 -0
- package/dist/inspectorListen-KGMIQ2TF.cjs +1 -0
- package/dist/nestjs/index.cjs +1 -18
- package/dist/nestjs/index.d.cts +22 -0
- package/dist/nestjs/index.d.ts +1 -3
- package/dist/nestjs/index.js +1 -18
- package/dist/order/index.cjs +1 -1
- package/dist/order/index.d.cts +155 -0
- package/dist/order/index.d.ts +15 -3
- package/dist/order/index.js +1 -1
- package/dist/runtime/index.cjs +13 -30
- package/dist/{diagnosticCatalog-35mrwAHe.d.ts → runtime/index.d.cts} +828 -276
- package/dist/runtime/index.d.ts +2741 -133
- package/dist/runtime/index.js +13 -30
- package/dist/{types-Bdj32QwA.d.ts → types-CnauMQQL.d.cts} +607 -163
- package/dist/types-CnauMQQL.d.ts +1800 -0
- package/docs/README.md +3 -1
- package/docs/agent-guide.md +217 -16
- package/docs/ai-gates.md +174 -26
- package/docs/arkorder.md +32 -15
- package/docs/brownfield-adoption.md +5 -1
- package/docs/configuration.md +230 -31
- package/docs/develop.md +2 -1
- package/docs/diagnostics.md +212 -19
- package/docs/package-surface.md +35 -9
- package/docs/product-voice.md +7 -1
- package/package.json +69 -19
- package/schemas/ark.analysis-result.schema.json +15 -0
- package/schemas/ark.config.schema.json +77 -12
- package/schemas/ark.invariant-probe.schema.json +368 -0
- package/schemas/ark.resolved-candidate-facts.schema.json +1 -1
- package/schemas/ark.status-manifest.schema.json +22 -0
- package/server.json +3 -9
- package/templates/agent-skills/README.md +1 -1
- package/templates/agent-skills/ark-adopt/SKILL.md +5 -1
- package/templates/agent-skills/ark-contract/SKILL.md +17 -0
- package/templates/agent-skills/ark-coverage/SKILL.md +2 -0
- package/templates/agent-skills/ark-explore/SKILL.md +7 -0
- package/templates/agent-skills/ark-fix/SKILL.md +20 -0
- package/templates/agent-skills/ark-order/SKILL.md +4 -2
- package/templates/agent-skills/ark-place/SKILL.md +8 -0
- package/templates/agent-skills/ark-runtime/SKILL.md +6 -1
- package/templates/arkrules/PersistenceAdapters.json +1 -1
- package/templates/arkrules/PresentationAdapters.json +1 -1
- package/templates/skills/ark-adopt.md +5 -1
- package/templates/skills/ark-contract.md +17 -0
- package/templates/skills/ark-coverage.md +2 -0
- package/templates/skills/ark-explore.md +7 -0
- package/templates/skills/ark-fix.md +20 -0
- package/templates/skills/ark-order.md +4 -2
- package/templates/skills/ark-place.md +8 -0
- package/templates/skills/ark-runtime.md +6 -1
- package/bin/lib/ark-order-error.mjs +0 -18
- package/bin/lib/ark-order-invariants.mjs +0 -346
- package/dist/types-Ik_OakcI.d.ts +0 -183
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
upgradeOutcome,
|
|
19
19
|
} from './upgrade-outcome.mjs';
|
|
20
20
|
import { __packageRoot } from './gate-files.mjs';
|
|
21
|
+
import { compareSemverCore } from './upgrade-package-decision.mjs';
|
|
21
22
|
import {
|
|
22
23
|
applyManagedUpgrade,
|
|
23
24
|
managedUpgradeJson,
|
|
@@ -51,30 +52,7 @@ export function resolveProjectArkgatePackageJson(root) {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
* Compare numeric major.minor.patch cores (prerelease / build ignored).
|
|
56
|
-
* @returns {-1|0|1}
|
|
57
|
-
*/
|
|
58
|
-
export function compareSemverCore(a, b) {
|
|
59
|
-
const parse = (value) => {
|
|
60
|
-
const core = String(value ?? '')
|
|
61
|
-
.trim()
|
|
62
|
-
.replace(/^v/i, '')
|
|
63
|
-
.split(/[-+]/)[0];
|
|
64
|
-
const parts = core.split('.').map((part) => {
|
|
65
|
-
const n = Number.parseInt(part, 10);
|
|
66
|
-
return Number.isFinite(n) ? n : 0;
|
|
67
|
-
});
|
|
68
|
-
return [parts[0] || 0, parts[1] || 0, parts[2] || 0];
|
|
69
|
-
};
|
|
70
|
-
const left = parse(a);
|
|
71
|
-
const right = parse(b);
|
|
72
|
-
for (let i = 0; i < 3; i += 1) {
|
|
73
|
-
if (left[i] < right[i]) return -1;
|
|
74
|
-
if (left[i] > right[i]) return 1;
|
|
75
|
-
}
|
|
76
|
-
return 0;
|
|
77
|
-
}
|
|
55
|
+
export { compareSemverCore };
|
|
78
56
|
|
|
79
57
|
/** True when candidate is the same path as root or a descendant (after resolve). */
|
|
80
58
|
export function isPathInside(candidate, root) {
|
|
@@ -144,7 +144,7 @@ function sampleForViolation(violation, ruleId) {
|
|
|
144
144
|
* @param {string} stdout
|
|
145
145
|
* @returns {Record<string, unknown>|null}
|
|
146
146
|
*/
|
|
147
|
-
|
|
147
|
+
function parseCheckStdout(stdout) {
|
|
148
148
|
const text = typeof stdout === 'string' ? stdout.trim() : '';
|
|
149
149
|
if (!text) return null;
|
|
150
150
|
try {
|
|
@@ -10,7 +10,7 @@ import readline from 'node:readline/promises';
|
|
|
10
10
|
import { __packageRoot } from './gate-files.mjs';
|
|
11
11
|
|
|
12
12
|
export const UPSTREAM_OWNER_REPO = 'pedroknigge/arkgate';
|
|
13
|
-
|
|
13
|
+
const SUBMIT_PROMPT = 'Type submit to send';
|
|
14
14
|
|
|
15
15
|
export function ownerRepoFromGithubUrl(url) {
|
|
16
16
|
if (typeof url !== 'string' || url.trim() === '') return null;
|
|
@@ -22,7 +22,7 @@ export function ownerRepoFromGithubUrl(url) {
|
|
|
22
22
|
return `${owner}/${repo}`;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
function resolveUpstreamRepo(pkg) {
|
|
26
26
|
const fromBugs = ownerRepoFromGithubUrl(pkg?.bugs?.url);
|
|
27
27
|
if (fromBugs) return fromBugs;
|
|
28
28
|
const repository = pkg?.repository;
|
|
@@ -32,7 +32,7 @@ export function resolveUpstreamRepo(pkg) {
|
|
|
32
32
|
return UPSTREAM_OWNER_REPO;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
function posixSingleQuote(value) {
|
|
36
36
|
return `'${String(value).replace(/'/g, `'\\''`)}'`;
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -40,7 +40,7 @@ export function formatGhIssueCreateCommand({ repo, title, body }) {
|
|
|
40
40
|
return `gh issue create --repo ${posixSingleQuote(repo)} --title ${posixSingleQuote(title)} --body ${posixSingleQuote(body)}`;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
function reportUsage() {
|
|
44
44
|
return `arkgate report (alias ark report) — draft an upstream GitHub issue for ArkGate.
|
|
45
45
|
|
|
46
46
|
Target: pedroknigge/arkgate (this package's package.json bugs.url). Never the consumer repo.
|
|
@@ -59,8 +59,13 @@ gh issue create --repo pedroknigge/arkgate command, then exits 2.
|
|
|
59
59
|
`;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Timestamp, active violation count, and verdict of a `.ark/reports/latest.json`
|
|
64
|
+
* snapshot object. Verdict: pass / fail / incomplete, or null when unknown.
|
|
65
|
+
* @param {object} latest
|
|
66
|
+
* @returns {{ at: string|null, active: number|null, verdict: 'pass'|'fail'|'incomplete'|null }}
|
|
67
|
+
*/
|
|
68
|
+
export function lastCheckVerdictFacts(latest) {
|
|
64
69
|
const at =
|
|
65
70
|
typeof latest.generatedAt === 'string'
|
|
66
71
|
? latest.generatedAt
|
|
@@ -79,11 +84,17 @@ export function lastCheckSnippet(latest) {
|
|
|
79
84
|
else if (latest.completeness === 'partial' || latest.completeness === 'unavailable') {
|
|
80
85
|
verdict = 'incomplete';
|
|
81
86
|
} else if (latest.ok === true) verdict = 'pass';
|
|
87
|
+
return { at, active, verdict };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function lastCheckSnippet(latest) {
|
|
91
|
+
if (!latest || typeof latest !== 'object') return null;
|
|
92
|
+
const { at, active, verdict } = lastCheckVerdictFacts(latest);
|
|
82
93
|
if (at == null && verdict == null && active == null) return null;
|
|
83
94
|
return { at, verdict, activeViolations: active };
|
|
84
95
|
}
|
|
85
96
|
|
|
86
|
-
|
|
97
|
+
function readLastCheckSnapshot(root) {
|
|
87
98
|
const latestPath = path.join(root, '.ark', 'reports', 'latest.json');
|
|
88
99
|
try {
|
|
89
100
|
return JSON.parse(fs.readFileSync(latestPath, 'utf8'));
|
|
@@ -92,7 +103,7 @@ export function readLastCheckSnapshot(root) {
|
|
|
92
103
|
}
|
|
93
104
|
}
|
|
94
105
|
|
|
95
|
-
|
|
106
|
+
function buildIssueDraft({ repo, arkgateVersion, lastCheck, finding, title }) {
|
|
96
107
|
const resolvedTitle =
|
|
97
108
|
typeof title === 'string' && title.trim()
|
|
98
109
|
? title.trim()
|
|
@@ -127,7 +138,7 @@ export function buildIssueDraft({ repo, arkgateVersion, lastCheck, finding, titl
|
|
|
127
138
|
return { repo, title: resolvedTitle, body: lines.join('\n') };
|
|
128
139
|
}
|
|
129
140
|
|
|
130
|
-
|
|
141
|
+
function defaultRunGh(argv, options = {}) {
|
|
131
142
|
const env = { ...(options.env ?? process.env) };
|
|
132
143
|
delete env.GH_REPO;
|
|
133
144
|
const result = spawnSync('gh', argv, {
|
|
@@ -182,7 +193,7 @@ async function defaultPromptSubmit(stdin, stdout) {
|
|
|
182
193
|
}
|
|
183
194
|
}
|
|
184
195
|
|
|
185
|
-
|
|
196
|
+
function parseReportArgv(argv = []) {
|
|
186
197
|
const out = {
|
|
187
198
|
submit: false,
|
|
188
199
|
iConfirmSubmit: false,
|
package/bin/lib/violations.mjs
CHANGED
|
@@ -2,7 +2,8 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
4
|
const useColor = process.stderr.isTTY && !process.env.NO_COLOR;
|
|
5
|
-
|
|
5
|
+
/** ANSI styling for ark-check's stderr; plain text when stderr is not a TTY or NO_COLOR is set. */
|
|
6
|
+
export const color = {
|
|
6
7
|
red: (s) => (useColor ? `\x1b[31m${s}\x1b[0m` : s),
|
|
7
8
|
yellow: (s) => (useColor ? `\x1b[33m${s}\x1b[0m` : s),
|
|
8
9
|
green: (s) => (useColor ? `\x1b[32m${s}\x1b[0m` : s),
|
|
@@ -17,10 +18,10 @@ import { toAdapterDiagnostic } from './adapter-contract.mjs';
|
|
|
17
18
|
export { baselineKey, baselineOccurrenceKeys };
|
|
18
19
|
|
|
19
20
|
/** Real regenerate flags: freeze-refuse needs --force; law PR needs --contract-session; stewards[] needs --author. */
|
|
20
|
-
|
|
21
|
+
const REGENERATE_BASELINE_COMMAND =
|
|
21
22
|
'ark-check --update-baseline --force --contract-session --author <steward>';
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
const BASELINE_NOTE =
|
|
24
25
|
`Frozen ark-check violations (one record per edge). Only NEW keys vs the merge-base fail --against / --baseline. Regenerate with: ${REGENERATE_BASELINE_COMMAND} (--author when stewards[] is set)`;
|
|
25
26
|
|
|
26
27
|
export function readBaseline(root, baselinePath) {
|
|
@@ -98,7 +99,7 @@ export function printWarning(warning) {
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
/** Advisory the engine emits once per shared-root → slice edge. Humans see a group. */
|
|
101
|
-
|
|
102
|
+
const SHARED_IMPORTS_SLICE_RULE_ID = 'SHARED_IMPORTS_SLICE';
|
|
102
103
|
|
|
103
104
|
/**
|
|
104
105
|
* Where the full per-edge list lives. Human check output names this on every
|
|
@@ -118,7 +119,7 @@ function layerLabel(value) {
|
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
/** Group key: one fact per rule and layer edge. */
|
|
121
|
-
|
|
122
|
+
function sharedImportsSliceGroupKey(warning) {
|
|
122
123
|
return [
|
|
123
124
|
typeof warning?.ruleId === 'string' ? warning.ruleId : SHARED_IMPORTS_SLICE_RULE_ID,
|
|
124
125
|
layerLabel(warning?.fromLayer),
|
|
@@ -207,7 +208,7 @@ export function printSharedImportsSliceBridgeList(warnings) {
|
|
|
207
208
|
}
|
|
208
209
|
|
|
209
210
|
/** Non-blocking type-only placement debt: exit stays 0; do not paint ✖. */
|
|
210
|
-
|
|
211
|
+
function isNonBlockingPlacementDebt(violation) {
|
|
211
212
|
return violation?.failsStrict === false;
|
|
212
213
|
}
|
|
213
214
|
|
|
@@ -241,7 +242,7 @@ export const CONCENTRATION_MIN_VIOLATIONS = 10;
|
|
|
241
242
|
export const CONCENTRATION_SHARE = 0.9;
|
|
242
243
|
|
|
243
244
|
/** Sensor id for STRUCTURE findings. Orchestration-only is code debt, not a missing toLayer. */
|
|
244
|
-
|
|
245
|
+
function violationSensorId(violation) {
|
|
245
246
|
if (typeof violation?.sensor === 'string' && violation.sensor.trim()) return violation.sensor.trim();
|
|
246
247
|
if (typeof violation?.arkruleId === 'string' && violation.arkruleId.trim()) return violation.arkruleId.trim();
|
|
247
248
|
return undefined;
|
|
@@ -257,11 +258,11 @@ export function violationEdge(violation) {
|
|
|
257
258
|
}
|
|
258
259
|
|
|
259
260
|
/** Layer-import arrows can mean a contract bug. Structural-sensor blobs are code debt. */
|
|
260
|
-
|
|
261
|
+
function isContractConcentrationEdge(edge) {
|
|
261
262
|
return typeof edge === 'string' && edge.includes(' → ');
|
|
262
263
|
}
|
|
263
264
|
|
|
264
|
-
|
|
265
|
+
function isContractStyleViolation(violation) {
|
|
265
266
|
if (violationSensorId(violation)) return false;
|
|
266
267
|
if (violation.ruleId === 'CIRCULAR_DEPENDENCY') return true;
|
|
267
268
|
if (violation.ruleId === 'FORBIDDEN_GLOBAL') return true;
|
package/bin/lib/weakest-link.mjs
CHANGED
|
@@ -296,6 +296,19 @@ export function collectWeakestLinkGaps(root, opts = {}) {
|
|
|
296
296
|
fix: 'Add the architecture CI job name to required status checks',
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
|
+
const upstream = Array.isArray(github.arkCheckUpstreamNotRequired)
|
|
300
|
+
? github.arkCheckUpstreamNotRequired
|
|
301
|
+
: [];
|
|
302
|
+
if (github.available && upstream.length > 0) {
|
|
303
|
+
gaps.push({
|
|
304
|
+
id: 'enforcement-ark-check-upstream-not-required',
|
|
305
|
+
severity: 'warn',
|
|
306
|
+
message:
|
|
307
|
+
`The required architecture job has needs: that are not required (${upstream.join(', ')}); ` +
|
|
308
|
+
'if one fails, the architecture job is skipped and a skipped job satisfies branch protection',
|
|
309
|
+
fix: 'Require those jobs too, or give the architecture job `if: ${{ always() }}` and fail it when a needed job failed',
|
|
310
|
+
});
|
|
311
|
+
}
|
|
299
312
|
}
|
|
300
313
|
|
|
301
314
|
return {
|
|
@@ -20,8 +20,9 @@ import {
|
|
|
20
20
|
import { detectActiveAgentHost } from './skill-install.mjs';
|
|
21
21
|
import { detectCiEnforcement } from './weakest-link.mjs';
|
|
22
22
|
import { buildEnforcementState, packageInstallation } from './enforcement-state.mjs';
|
|
23
|
+
import { npxArkgatePrefixLength } from './package-manager.mjs';
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
const WRITE_CAPABILITY_NAMES = [
|
|
25
26
|
'hard-write',
|
|
26
27
|
'advisory-write',
|
|
27
28
|
'merge-gate',
|
|
@@ -161,8 +162,9 @@ function arkMcpInvocation(server) {
|
|
|
161
162
|
if (argv.filter(isArkMcpToken).length !== 1) return false;
|
|
162
163
|
if (isArkMcpToken(server.command)) return { argv, binIndex: 0 };
|
|
163
164
|
const runner = path.basename(server.command.trim().replace(/\\/g, '/'));
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
const npxPrefix = runner === 'npx' ? npxArkgatePrefixLength(args) : 0;
|
|
166
|
+
if (['npx', 'yarn'].includes(runner) && isArkMcpToken(args[npxPrefix])) {
|
|
167
|
+
return { argv, binIndex: npxPrefix + 1 };
|
|
166
168
|
}
|
|
167
169
|
if (runner === 'node') {
|
|
168
170
|
const script = args[0]?.replace(/\\/g, '/');
|
|
@@ -449,7 +451,7 @@ function hostRecord(hard, advisory, repair, merge, extras = {}) {
|
|
|
449
451
|
};
|
|
450
452
|
}
|
|
451
453
|
|
|
452
|
-
|
|
454
|
+
function detectWritePathInventory(root) {
|
|
453
455
|
// Merge-gate evidence only when CI uses the fail-closed profile (not bare ark-check).
|
|
454
456
|
const ci = detectCiEnforcement(root);
|
|
455
457
|
const merge = ci.failClosed ? ci.arkWorkflowFiles : [];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var G=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var i=(n,e)=>G(n,"name",{value:e,configurable:!0});var Jn=(n,e,r,t)=>{for(var s=t>1?void 0:t?v(e,r):e,u=n.length-1,a;u>=0;u--)(a=n[u])&&(s=(t?a(e,r,s):a(s))||s);return t&&s&&G(e,r,s),s};var D="1.0",nn= exports.d =["singleton","transient"],en=["absorb","escalate_up","hold"],rn=new Set(nn);function E(n,e){return n<e?-1:n>e?1:0}i(E,"compare");function tn(n){return[...new Set(n)].sort(E)}i(tn,"uniqueSorted");function k(n){if(!Array.isArray(n))return[];let e=[];for(let r of n)typeof r=="string"&&r.length>0&&e.push(r);return tn(e)}i(k,"nameList");function on(n){if(n===null)return null;if(typeof n=="string"||typeof n=="boolean"||typeof n=="number"&&Number.isFinite(n))return n}i(on,"jsonPrimitive");function sn(n){return typeof n=="string"&&rn.has(n)?n:"singleton"}i(sn,"closedLifetime");function L(n){if(n===null||typeof n!="object"||Array.isArray(n))return;let e={};for(let r of Object.keys(n).sort(E)){if(r.length===0)continue;let t=on(n[r]);t!==void 0&&(e[r]=t)}return Object.keys(e).length>0?e:void 0}i(L,"sanitizeMetadata");function un(n){if(n===null||typeof n!="object"||Array.isArray(n))return;let e=n,r={};typeof e.label=="string"&&e.label.length>0&&(r.label=e.label),typeof e.architectureKind=="string"&&e.architectureKind.length>0&&(r.architectureKind=e.architectureKind);let t=k(e.tags);t.length>0&&(r.tags=t),typeof e.group=="string"&&e.group.length>0&&(r.group=e.group);let s=L(e.metadata);return s&&(r.metadata=s),Object.keys(r).length>0?r:void 0}i(un,"sanitizeArkRunExtendedInfo");function an(n){if(n===null||typeof n!="object"||Array.isArray(n))return;let e=n,r=typeof e.id=="string"?e.id.trim():"";if(!r)return;let t={id:r,lifetime:sn(e.lifetime),uses:k(e.uses),reactsTo:k(e.reactsTo),raises:k(e.raises),sends:k(e.sends)},s=un(e.extendedInfo);return s&&(t.extendedInfo=s),t}i(an,"sanitizeArkRunComponent");var cn=new Set(en);function dn(n){return L(n)}i(dn,"sanitizeTapePayload");function U(n){if(n===null||typeof n!="object"||Array.isArray(n))return;let e=n,r=typeof e.xiHash=="string"?e.xiHash.trim():"";if(!r)return;let t=e.event;if(t===null||typeof t!="object"||Array.isArray(t))return;let s=t,u=typeof s.kind=="string"?s.kind.trim():"";if(!u)return;let a=e.residual;if(a===null||typeof a!="object"||Array.isArray(a))return;let o=a,c=typeof o.kind=="string"&&cn.has(o.kind)?o.kind:void 0;if(!c)return;let d={kind:u},p=dn(s.payload);p&&(d.payload=p);let w={kind:c};return typeof o.reasonCode=="string"&&o.reasonCode.length>0&&(w.reasonCode=o.reasonCode),typeof o.eventId=="string"&&o.eventId.length>0&&(w.eventId=o.eventId),typeof o.target=="string"&&o.target.length>0&&(w.target=o.target),{xiHash:r,event:d,residual:w}}i(U,"sanitizeDecisionTapeRecord");function pn(n){if(!Array.isArray(n))return[];let e=[];for(let r of n){let t=U(r);t&&e.push(t)}return e}i(pn,"sanitizeDecisionTape");function R(n){let e=typeof n.kernelInstanceId=="string"?n.kernelInstanceId:"",r=Array.isArray(n.components)?n.components:[],t=new Set,s=[];for(let a of r){let o=an(a);!o||t.has(o.id)||(t.add(o.id),s.push(o))}s.sort((a,o)=>E(a.id,o.id));let u=pn(n.decisionTape);return{schemaVersion:"1.0",kernelInstanceId:e,components:s,...u.length>0?{decisionTape:u}:{}}}i(R,"buildDependencyInformationPackage");function Yn(n,e){let r=U(e),t=_nullishCoalesce(n.decisionTape, () => ([])),s=r?[...t,r]:[...t];return{schemaVersion:n.schemaVersion,kernelInstanceId:n.kernelInstanceId,components:n.components,...s.length>0?{decisionTape:s}:{}}}i(Yn,"appendDecisionTape");var fn="1.0",ln= exports.i ="process",gn= exports.j =["process","technical"],ee= exports.k =["component","interaction"],re= exports.l =["raises","reactsTo","sends"],te= exports.m =["uses"],l= exports.n =class extends Error{static{i(this,"InvalidArkRunGraphQueryError")}constructor(e,r){super(_nullishCoalesce(r, () => ((e==="slice"?'ArkRun graph slice must be "process" or "technical".':e==="degreesOfSeparation"?"ArkRun graph degreesOfSeparation must be a non-negative integer.":`ArkRun graph ${e} is not a closed query.`)))),this.name="InvalidArkRunGraphQueryError",this.option=e}},kn=new Set(gn),Rn=new Set(["slice","nodeIds","degreesOfSeparation","include","exclude"]),An=new Set(["ids","labels","tags","groups","architectureKinds"]);function y(n,e){return n<e?-1:n>e?1:0}i(y,"compare");function C(n){return[...new Set(n)].sort(y)}i(C,"uniqueSorted");function H(){return{tokens:[],ids:[],labels:[],tags:[],groups:[],architectureKinds:[]}}i(H,"emptyMatch");function T(n){return n.tokens.length+n.ids.length+n.labels.length+n.tags.length+n.groups.length+n.architectureKinds.length>0}i(T,"matchHasCriteria");function f(n,e){if(n==null||n==="")return[];if(typeof n=="string")return C(n.split(",").map(t=>t.trim()).filter(t=>t.length>0));if(!Array.isArray(n))throw new l(e);let r=[];for(let t of n){if(typeof t!="string")throw new l(e);let s=t.trim();s.length>0&&r.push(s)}return C(r)}i(f,"nameList");function V(n,e){if(e==="*")return n.length>0;if(!e.includes("*"))return n===e;let r="^";for(let t of e)t==="*"?r+=".*":/[.*+?^${}()|[\]\\]/.test(t)?r+=`\\${t}`:r+=t;return r+="$",new RegExp(r).test(n)}i(V,"globMatch");function A(n,e){return n?e.some(r=>V(n,r)):!1}i(A,"anyGlob");function j(n){if(n==null||n==="")return ln;if(typeof n=="string"&&kn.has(n))return n;throw new l("slice")}i(j,"closedSlice");function W(n){if(n==null||n==="")return null;if(typeof n=="string"&&/^(0|[1-9]\d*)$/.test(n))return Number(n);if(typeof n=="number"&&Number.isInteger(n)&&n>=0)return n;throw new l("degreesOfSeparation")}i(W,"closedDegrees");function F(n,e){if(n==null||n==="")return H();if(typeof n=="string"||Array.isArray(n))return{...H(),tokens:f(n,e)};if(typeof n!="object")throw new l(e);let r=n;for(let t of Object.keys(r))if(!An.has(t))throw new l(e);return{tokens:[],ids:f(r.ids,e),labels:f(r.labels,e),tags:f(r.tags,e),groups:f(r.groups,e),architectureKinds:f(r.architectureKinds,e)}}i(F,"closedMatch");function Q(n={}){if(n==null||n==="")return Q({});if(typeof n!="object"||Array.isArray(n))throw new l("slice","ArkRun graph query must be an object.");let e=n;for(let r of Object.keys(e))if(!Rn.has(r))throw new l("slice",`ArkRun graph query key "${r}" is not closed.`);return{slice:j(e.slice),nodeIds:f(e.nodeIds,"nodeIds"),degreesOfSeparation:W(e.degreesOfSeparation),include:F(e.include,"include"),exclude:F(e.exclude,"exclude")}}i(Q,"closeArkRunGraphQuery");function oe(n){let e={};n.slice&&(e.slice=j(n.slice));let r=f(_nullishCoalesce(n.nodeIds, () => (void 0)),"nodeIds");r.length>0&&(e.nodeIds=r);let t=W(_nullishCoalesce(n.degreesOfSeparation, () => (void 0)));t!==null&&(e.degreesOfSeparation=t);let s=f(_nullishCoalesce(n.include, () => (void 0)),"include");s.length>0&&(e.include=s);let u=f(_nullishCoalesce(n.exclude, () => (void 0)),"exclude");return u.length>0&&(e.exclude=u),e}i(oe,"arkRunGraphQueryFromSearchParams");function mn(n){let e=[n.id];return n.label&&e.push(n.label),n.group&&e.push(n.group),n.architectureKind&&e.push(n.architectureKind),n.tags&&e.push(...n.tags),e}i(mn,"nodeFields");function $(n,e){if(!T(e))return!0;let r=mn(n);return e.tokens.some(t=>r.some(s=>V(s,t)))||A(n.id,e.ids)||A(n.label,e.labels)||_optionalChain([n, 'access', _2 => _2.tags, 'optionalAccess', _3 => _3.some, 'call', _4 => _4(t=>A(t,e.tags))])||A(n.group,e.groups)?!0:A(n.architectureKind,e.architectureKinds)}i($,"nodeMatches");function yn(n){if(n&&typeof n=="object"&&!Array.isArray(n)){let e=n;return R({kernelInstanceId:e.kernelInstanceId,components:e.components})}return R({})}i(yn,"asPackage");function hn(n){let e={id:n.id,kind:"component",lifetime:n.lifetime},r=n.extendedInfo;return _optionalChain([r, 'optionalAccess', _5 => _5.label])&&(e.label=r.label),_optionalChain([r, 'optionalAccess', _6 => _6.group])&&(e.group=r.group),_optionalChain([r, 'optionalAccess', _7 => _7.architectureKind])&&(e.architectureKind=r.architectureKind),_optionalChain([r, 'optionalAccess', _8 => _8.tags])&&r.tags.length>0&&(e.tags=[...r.tags]),e}i(hn,"componentNode");function S(n){return{id:n,kind:"interaction"}}i(S,"interactionNode");function m(n,e){let r=n.get(e.id);(!r||r.kind==="interaction"&&e.kind==="component")&&n.set(e.id,e)}i(m,"addNode");function _(n,e,r,t,s){let u=`${r}\0${s}\0${t}`;e.has(u)||(e.add(u),n.push({from:r,to:t,kind:s}))}i(_,"addEdge");function bn(n,e){let r=new Map,t=[],s=new Set;for(let u of n){if(m(r,hn(u)),e==="technical"){for(let a of u.uses)m(r,_nullishCoalesce(r.get(a), () => (S(a)))),_(t,s,u.id,a,"uses");continue}for(let a of u.raises)m(r,_nullishCoalesce(r.get(a), () => (S(a)))),_(t,s,u.id,a,"raises");for(let a of u.reactsTo)m(r,_nullishCoalesce(r.get(a), () => (S(a)))),_(t,s,a,u.id,"reactsTo");for(let a of u.sends)m(r,_nullishCoalesce(r.get(a), () => (S(a)))),_(t,s,u.id,a,"sends")}return{nodes:r,edges:t}}i(bn,"buildSlice");function In(n){let e=new Map,r=i((t,s)=>{let u=e.get(t);u?u.push(s):e.set(t,[s])},"push");for(let t of n)r(t.from,t.to),r(t.to,t.from);return e}i(In,"adjacency");function wn(n,e,r,t){let s=e.filter(o=>n.has(o));if(s.length===0)return new Set;let u=new Set,a=s.map(o=>({id:o,depth:0}));for(;a.length>0;){let o=a.shift();if(!(!o||u.has(o.id))&&(u.add(o.id),!(r!==null&&o.depth>=r)))for(let c of _nullishCoalesce(t.get(o.id), () => ([])))!u.has(c)&&n.has(c)&&a.push({id:c,depth:o.depth+1})}return u}i(wn,"neighborhood");function h(n){let e=n.replace(/[^A-Za-z0-9_]/g,"_");return/^[A-Za-z_]/.test(e)?e:`n_${e}`}i(h,"mermaidSafeId");function B(n){return n.replace(/\\/g,"\\\\").replace(/"/g,"#quot;").replace(/]/g,"#93;")}i(B,"mermaidLabel");function Sn(n){let e=new Set,r=new Map;for(let t of n){let s=h(t),u=s,a=2;for(;e.has(u);)u=`${s}_${a}`,a+=1;e.add(u),r.set(t,u)}return r}i(Sn,"uniqueMermaidIds");function _n(n){let e=n.slice==="technical"?"TD":"LR",r=n.nodes.map(o=>o.id),t=Sn(r),s=C(n.nodes.map(o=>o.group).filter(o=>!!o)),u=[`flowchart ${e}`],a=i((o,c)=>{let d=_nullishCoalesce(t.get(o.id), () => (h(o.id))),p=B(_nullishCoalesce(o.label, () => (o.id)));u.push(`${c}${d}["${p}"]`)},"emitNode");for(let o of s){let c=h(`group_${o}`);u.push(` subgraph ${c}["${B(o)}"]`);for(let d of n.nodes)d.group===o&&a(d," ");u.push(" end")}for(let o of n.nodes)o.group||a(o," ");for(let o of n.edges){let c=_nullishCoalesce(t.get(o.from), () => (h(o.from))),d=_nullishCoalesce(t.get(o.to), () => (h(o.to)));u.push(` ${c} -->|${o.kind}| ${d}`)}return u.join(`
|
|
2
|
+
`)}i(_n,"formatArkRunGraphMermaid");function xn(n,e,r){let t=new Set(n.keys());if(T(r.include)&&(t=new Set([...t].filter(o=>{let c=n.get(o);return c!==void 0&&$(c,r.include)}))),T(r.exclude))for(let o of[...t]){let c=n.get(o);c&&$(c,r.exclude)&&t.delete(o)}let s=e.filter(o=>t.has(o.from)&&t.has(o.to));r.nodeIds.length>0&&(t=wn(t,r.nodeIds,r.degreesOfSeparation,In(s)));let u=[...t].sort(y).map(o=>n.get(o)).filter(o=>!!o),a=s.filter(o=>t.has(o.from)&&t.has(o.to)).sort((o,c)=>y(o.from,c.from)||y(o.kind,c.kind)||y(o.to,c.to));return{nodes:u,edges:a}}i(xn,"filterGraph");function se(n={},e={}){let r=yn(n),t=Q(e),s=bn(r.components,t.slice),u=xn(s.nodes,s.edges,t),a={schemaVersion:fn,kernelInstanceId:r.kernelInstanceId,slice:t.slice,query:t,nodes:u.nodes,edges:u.edges,mermaid:""};return a.mermaid=_n(a),a}i(se,"requestArkRunGraph");var O=["local","localBlocking","broker"],z= exports.t =!0,Nn=new Set(O),x= exports.u =class extends Error{static{i(this,"InvalidArkRunSendOptionError")}constructor(e){super(e==="transport"?'ArkRun transport must be "local", "localBlocking", or "broker".':"ArkRun ephemeral must be a boolean."),this.name="InvalidArkRunSendOptionError",this.option=e}};function En(n){if(n===void 0)return"local";if(typeof n=="string"&&Nn.has(n))return n;throw new x("transport")}i(En,"closedArkRunTransportKind");function Cn(n){if(n===void 0)return!0;if(n===!0||n===!1)return n;throw new x("ephemeral")}i(Cn,"closedArkRunEphemeral");function ae(n){let e=En(n.transport),r=Cn(n.ephemeral),t=e==="broker"&&n.brokerBound!==!0,s=e==="broker"&&!t?"broker":"local",u=e==="localBlocking";return{transport:e,ephemeral:r,deliveredVia:s,fallbackToLocal:t,notifySubscribers:s==="local",awaitHandlers:u,awaitHandoff:r||u}}i(ae,"resolveArkRunSendPlan");var Tn="1.0",q= exports.z ="127.0.0.1",On= exports.A =0,le= exports.B ="/snapshot",ge= exports.C ="/events",ke= exports.D ="/graph",Re= exports.E ="/outbox",Ae= exports.F ="/workflows",Kn= exports.G ="snapshot",Mn= exports.H ="in-process-local",b= exports.I =32;var P=class extends Error{static{i(this,"ArkRunInspectorProductionError")}constructor(){super("ArkRun inspector refuses to start when NODE_ENV=production."),this.name="ArkRunInspectorProductionError"}},I= exports.K =class extends Error{static{i(this,"ArkRunInspectorBindError")}constructor(e){super(`ArkRun inspector binds loopback only (default 127.0.0.1). Public host "${e}" is rejected.`),this.name="ArkRunInspectorBindError"}},Pn=new Set(["","*","0","0.0.0.0","::","::0","[::]","[::0]","::ffff:0.0.0.0","[::ffff:0.0.0.0]"]);function J(n){return n==="production"}i(J,"isArkRunInspectorProductionEnv");function Gn(n){let e=n.split(".");if(e.length!==4)return;let r=[];for(let t of e){if(!/^\d{1,3}$/.test(t))return;let s=Number(t);if(s>255)return;r.push(s)}return r}i(Gn,"ipv4Octets");function X(n){if(n.startsWith("[::ffff:")&&n.endsWith("]"))return n.slice(8,-1);if(n.startsWith("::ffff:"))return n.slice(7)}i(X,"unwrapIpv4Mapped");function Y(n){if(typeof n!="string")return!1;let e=n.trim().toLowerCase();if(e==="localhost"||e==="::1"||e==="[::1]")return!0;let r=X(e);if(r)return Y(r);let t=Gn(e);return t!==void 0&&t[0]===127}i(Y,"isArkRunInspectorLoopbackHost");function Z(n){if(n===void 0)return q;if(typeof n!="string")throw new I(String(n));let e=n.trim();if(Pn.has(e.toLowerCase())||!Y(e))throw new I(e);let r=e.toLowerCase();if(r==="localhost")return q;if(r==="[::1]")return"::1";let t=X(r);return t?Z(t):r}i(Z,"closedHost");function Dn(n){if(n===void 0)return On;if(typeof n!="number"||!Number.isInteger(n)||n<0||n>65535)throw new I(`port:${String(n)}`);return n}i(Dn,"closedPort");function Ln(n={}){if(J(n.nodeEnv)||J(n.processNodeEnv))throw new P;return{host:Z(n.host),port:Dn(n.port)}}i(Ln,"resolveArkRunInspectorBind");function me(n,e,r){return`http://${n.includes(":")?`[${n}]`:n}:${e}${r}`}i(me,"arkRunInspectorUrl");function Un(n){if(n!==void 0)try{return JSON.parse(JSON.stringify(n))}catch (e2){return}}i(Un,"jsonClone");function Hn(n){return{kinds:[...O],ephemeralDefault:n.ephemeralDefault===!1?!1:!0,brokerBound:n.brokerBound===!0,cloudSdksShipped:!1,fallback:Mn}}i(Hn,"closedTransportFacts");function g(n){if(!(!n||typeof n!="object"||Array.isArray(n)))return n}i(g,"asRecord");function Fn(n){let e=g(n);if(!e||typeof e.id!="string")return;let r=e.status;if(r!=="pending"&&r!=="failed")return;let t=g(e.event),s=t&&typeof t.intent=="string"?t.intent:typeof e.intent=="string"?e.intent:void 0,u={id:e.id,status:r,attempts:typeof e.attempts=="number"&&Number.isFinite(e.attempts)?e.attempts:0};return s&&(u.intent=s),typeof e.error=="string"&&e.error.length>0&&(u.error=e.error),typeof e.updatedAt=="string"&&(u.updatedAt=e.updatedAt),u}i(Fn,"closedOutboxSummary");function N(n){if(typeof n!="number"||!Number.isFinite(n))return b;let e=Math.trunc(n);return e<0?0:e>b?b:e}i(N,"closedSampleLimit");function $n(n,e){let r=typeof n=="string"&&n.trim().length>0?n.trim():n&&typeof n=="object"&&"constructor"in n?String(_nullishCoalesce(_optionalChain([n, 'access', _9 => _9.constructor, 'optionalAccess', _10 => _10.name]), () => (e))):e,t=/^InMemory/i.test(r)?"memory":"durable";return{role:e,id:r,kind:t}}i($n,"classifyArkRunInspectorStoreDurability");function Bn(n={}){let e=g(n),r=_nullishCoalesce(g(_optionalChain([e, 'optionalAccess', _11 => _11.durability])), () => (e)),t=Array.isArray(_optionalChain([r, 'optionalAccess', _12 => _12.stores]))?r.stores:Array.isArray(_optionalChain([e, 'optionalAccess', _13 => _13.stores]))?e.stores:[],s=[];for(let u of t){let a=g(u);if(!a)continue;let o=a.role;if(o!=="outbox"&&o!=="audit"&&o!=="workflow")continue;let c=typeof a.id=="string"?a.id:typeof a.name=="string"?a.name:void 0;if(!c)continue;let d=a.kind==="memory"||a.kind==="durable"?a.kind:$n(c,o).kind;s.push({role:o,id:c,kind:d})}return{durability:{stores:s}}}i(Bn,"buildArkRunInspectorHardening");function Vn(n=[],e={}){let r=N(e.sampleLimit),t=Array.isArray(n)?n:[],s=[],u=[];for(let a of t){let o=Fn(a);o&&(o.status==="pending"?s.push(o):u.push(o))}return{available:!0,pendingCount:s.length,failedCount:u.length,pending:s.slice(0,r),failed:u.slice(0,r),sampleLimit:r}}i(Vn,"buildArkRunInspectorOutboxMonitor");function K(){return{available:!1,pendingCount:0,failedCount:0,pending:[],failed:[],sampleLimit:b}}i(K,"unavailableArkRunInspectorOutboxMonitor");function jn(n){let e=g(n);if(!e||typeof e.id!="string")return;let r=typeof e.workflowName=="string"?e.workflowName:typeof e.name=="string"?e.name:void 0;if(!r)return;let t={id:e.id,name:r,status:typeof e.status=="string"?e.status:"unknown"};return typeof e.currentStep=="string"&&(t.currentStep=e.currentStep),typeof e.error=="string"&&e.error.length>0&&(t.error=e.error),t}i(jn,"closedWorkflowSummary");function Wn(n){return n==="idle"||n==="waiting"}i(Wn,"isPendingWorkflowStatus");function Qn(n=[],e={}){let r=N(e.sampleLimit),t=Array.isArray(n)?n:[],s=[],u=0,a=0,o=0,c=0;for(let d of t){let p=jn(d);p&&(s.push(p),p.status==="running"?u+=1:p.status==="compensating"?a+=1:p.status==="failed"?o+=1:Wn(p.status)&&(c+=1))}return{available:!0,total:s.length,runningCount:u,compensatingCount:a,failedCount:o,pendingCount:c,workflows:s.slice(0,r),sampleLimit:r}}i(Qn,"buildArkRunInspectorWorkflowsMonitor");function M(){return{available:!1,total:0,runningCount:0,compensatingCount:0,failedCount:0,pendingCount:0,workflows:[],sampleLimit:b}}i(M,"unavailableArkRunInspectorWorkflowsMonitor");function zn(n){if(n===void 0)return;let e=g(n);if(!e||e.available===!1)return K();let r=N(e.sampleLimit);if(Array.isArray(e.pending)||Array.isArray(e.failed)||Array.isArray(e.records)){let t=[...Array.isArray(e.pending)?e.pending:[],...Array.isArray(e.failed)?e.failed:[],...Array.isArray(e.records)?e.records:[]],s=Vn(t,{sampleLimit:r}),u=typeof e.pendingCount=="number"&&Number.isFinite(e.pendingCount)?Math.max(0,Math.trunc(e.pendingCount)):s.pendingCount,a=typeof e.failedCount=="number"&&Number.isFinite(e.failedCount)?Math.max(0,Math.trunc(e.failedCount)):s.failedCount;return{...s,pendingCount:u,failedCount:a,sampleLimit:r}}return K()}i(zn,"closedOutboxMonitor");function qn(n){if(n===void 0)return;let e=g(n);if(!e||e.available===!1)return M();let r=N(e.sampleLimit);if(Array.isArray(e.workflows)){let t=Qn(e.workflows,{sampleLimit:r}),s=typeof e.total=="number"&&Number.isFinite(e.total)?Math.max(0,Math.trunc(e.total)):t.total,u=typeof e.runningCount=="number"&&Number.isFinite(e.runningCount)?Math.max(0,Math.trunc(e.runningCount)):t.runningCount,a=typeof e.compensatingCount=="number"&&Number.isFinite(e.compensatingCount)?Math.max(0,Math.trunc(e.compensatingCount)):t.compensatingCount,o=typeof e.failedCount=="number"&&Number.isFinite(e.failedCount)?Math.max(0,Math.trunc(e.failedCount)):t.failedCount,c=typeof e.pendingCount=="number"&&Number.isFinite(e.pendingCount)?Math.max(0,Math.trunc(e.pendingCount)):t.pendingCount;return{...t,total:s,runningCount:u,compensatingCount:a,failedCount:o,pendingCount:c,sampleLimit:r}}return M()}i(qn,"closedWorkflowsMonitor");function ye(n={}){let e=Ln({host:n.host,port:n.port}),r=R({kernelInstanceId:n.kernelInstanceId,components:n.package&&typeof n.package=="object"&&!Array.isArray(n.package)&&Array.isArray(n.package.components)?n.package.components:[]}),t=zn(n.outbox),s=qn(n.workflows),u={schemaVersion:Tn,kernelInstanceId:typeof n.kernelInstanceId=="string"?n.kernelInstanceId:r.kernelInstanceId,bind:{host:e.host,port:e.port,loopback:!0},package:{...r,schemaVersion:"1.0"},transport:Hn(n),observability:_nullishCoalesce(Un(n.observability), () => ({})),hardening:Bn(n.hardening)};return t&&(u.outbox=t),s&&(u.workflows=s),u}i(ye,"buildArkRunInspectorSnapshot");function he(n){return`event: ${Kn}
|
|
3
|
+
data: ${JSON.stringify(n)}
|
|
4
|
+
|
|
5
|
+
`}i(he,"formatArkRunInspectorSseEvent");exports.a = i; exports.b = Jn; exports.c = D; exports.d = nn; exports.e = an; exports.f = R; exports.g = Yn; exports.h = fn; exports.i = ln; exports.j = gn; exports.k = ee; exports.l = re; exports.m = te; exports.n = l; exports.o = Q; exports.p = oe; exports.q = _n; exports.r = se; exports.s = O; exports.t = z; exports.u = x; exports.v = En; exports.w = Cn; exports.x = ae; exports.y = Tn; exports.z = q; exports.A = On; exports.B = le; exports.C = ge; exports.D = ke; exports.E = Re; exports.F = Ae; exports.G = Kn; exports.H = Mn; exports.I = b; exports.J = P; exports.K = I; exports.L = J; exports.M = Y; exports.N = Ln; exports.O = me; exports.P = $n; exports.Q = Bn; exports.R = Vn; exports.S = K; exports.T = Qn; exports.U = M; exports.V = ye; exports.W = he;
|