arkaik 0.7.0 → 0.9.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.
@@ -201,7 +201,7 @@ interface JournalEvent extends Record<string, unknown> {
201
201
  id: string;
202
202
  /** ISO 8601 timestamp. */
203
203
  ts: string;
204
- /** Who/what wrote it: "alexis", "claude-code", "arkaik-sync", "ci". */
204
+ /** Who/what wrote it: "alexis", "claude-code", "arkaik-sync", "arkaik-ci". */
205
205
  actor?: string;
206
206
  /** Event type — the v1 vocabulary, or an unknown forward-compatible value. */
207
207
  type: string;
@@ -230,6 +230,12 @@ interface NodeStatusChangedEvent extends JournalEvent {
230
230
  from: StatusId;
231
231
  to: StatusId;
232
232
  platform?: PlatformId;
233
+ /**
234
+ * Free-form evidence for the move — the deployment URL, the store build
235
+ * number. Written by the hosted `release:append` door, the one writer that
236
+ * always knows it; edits through the mutations route never carry it.
237
+ */
238
+ detail?: string;
233
239
  }
234
240
 
235
241
  interface NodeDeletedEvent extends JournalEvent {
package/dist/index.js CHANGED
@@ -15080,7 +15080,7 @@ function missingProvenanceNodeIds(snapshotNodeIds, events) {
15080
15080
  var envelope = {
15081
15081
  id: external_exports.string().meta({ description: "ULID \u2014 sortable, collision-free without coordination." }),
15082
15082
  ts: external_exports.string().meta({ description: "ISO 8601 timestamp." }),
15083
- actor: external_exports.string().optional().meta({ description: 'Who/what wrote it (e.g. "claude-code", "ci").' }),
15083
+ actor: external_exports.string().optional().meta({ description: 'Who/what wrote it (e.g. "claude-code", "arkaik-ci").' }),
15084
15084
  v: external_exports.number().int().optional().meta({ description: "Reserved per-event payload version; absent today." })
15085
15085
  };
15086
15086
  var JournalEventSchema = external_exports.object({
@@ -15107,7 +15107,8 @@ var NodeStatusChangedEventSchema = external_exports.object({
15107
15107
  // their legacy status ids, so strict per-type validation must accept them.
15108
15108
  from: AnyStatusSchema,
15109
15109
  to: AnyStatusSchema,
15110
- platform: PlatformSchema.optional()
15110
+ platform: PlatformSchema.optional(),
15111
+ detail: external_exports.string().optional()
15111
15112
  }).catchall(external_exports.unknown());
15112
15113
  var DecisionStatusChangedEventSchema = external_exports.object({
15113
15114
  ...envelope,
@@ -16971,8 +16972,8 @@ function makeEvent(type, payload = {}, options = {}) {
16971
16972
 
16972
16973
  // ../schema/src/promote.ts
16973
16974
  var DEFAULT_REF_POLICY = {
16974
- "github-pr": { open: "development", merged: "live", closed: null },
16975
- "gitlab-mr": { open: "development", merged: "live", closed: null }
16975
+ "github-pr": { open: "development", merged: "releasing", closed: null },
16976
+ "gitlab-mr": { open: "development", merged: "releasing", closed: null }
16976
16977
  };
16977
16978
  function resolveRefPolicy(bundle) {
16978
16979
  const declared = bundle.project.metadata?.ref_policy;
@@ -17031,6 +17032,10 @@ function computeRefPromotions(bundle) {
17031
17032
  skipped.push({ node_id: node.id, ref_id: ref.id, reason: "already-there", detail: to });
17032
17033
  continue;
17033
17034
  }
17035
+ if (from === "live") {
17036
+ skipped.push({ node_id: node.id, ref_id: ref.id, reason: "live", detail: to });
17037
+ continue;
17038
+ }
17034
17039
  promotions.push({
17035
17040
  node_id: node.id,
17036
17041
  ref_id: ref.id,
@@ -17704,6 +17709,167 @@ function scopeSummary(scope) {
17704
17709
  return `${cells}${split} from ${from}${scope.since !== null ? ` since ${scope.since}` : ""}`;
17705
17710
  }
17706
17711
 
17712
+ // ../schema/src/quality-burndown.ts
17713
+ var EVENT_CAUSE = {
17714
+ "quality.finding.opened": "opened",
17715
+ "quality.finding.resolved": "resolved",
17716
+ "quality.finding.accepted": "accepted",
17717
+ "quality.audit.completed": "audit"
17718
+ };
17719
+ var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
17720
+ var isString2 = (value) => typeof value === "string" && value !== "";
17721
+ var emptyCounts = () => ({ critical: 0, high: 0, medium: 0, low: 0, info: 0 });
17722
+ var asSeverity = (value) => typeof value === "string" && FINDING_SEVERITIES.includes(value) ? value : null;
17723
+ function cleanCounts2(raw) {
17724
+ const counts = emptyCounts();
17725
+ if (!isRecord2(raw)) return counts;
17726
+ for (const severity of FINDING_SEVERITIES) {
17727
+ const value = raw[severity];
17728
+ if (typeof value === "number" && Number.isFinite(value) && value > 0) counts[severity] = value;
17729
+ }
17730
+ return counts;
17731
+ }
17732
+ function openTotal(open) {
17733
+ return FINDING_SEVERITIES.reduce((sum, severity) => sum + (open[severity] ?? 0), 0);
17734
+ }
17735
+ function deriveFindingsBurndown(events, options = {}) {
17736
+ const { surface, domain: domain2, library } = options;
17737
+ const filtered = surface !== void 0 || domain2 !== void 0;
17738
+ const sectionById = /* @__PURE__ */ new Map();
17739
+ for (const finding of Array.isArray(options.findings) ? options.findings : []) {
17740
+ if (isRecord2(finding) && isString2(finding.id)) sectionById.set(finding.id, finding);
17741
+ }
17742
+ const inView = (where) => {
17743
+ if (!filtered) return true;
17744
+ if (where === void 0) return false;
17745
+ if (surface !== void 0 && where.surface !== surface) return false;
17746
+ if (domain2 !== void 0 && (!isString2(where.criterion_id) || domainCodeOf(where.criterion_id, library) !== domain2)) {
17747
+ return false;
17748
+ }
17749
+ return true;
17750
+ };
17751
+ const relevant = (Array.isArray(events) ? events : []).filter(
17752
+ (event) => isRecord2(event) && typeof event.type === "string" && event.type in EVENT_CAUSE
17753
+ );
17754
+ const openedIds = /* @__PURE__ */ new Set();
17755
+ const decidedIds = /* @__PURE__ */ new Set();
17756
+ for (const event of relevant) {
17757
+ if (!isString2(event.finding_id)) continue;
17758
+ if (event.type === "quality.finding.opened") openedIds.add(event.finding_id);
17759
+ else if (event.type !== "quality.audit.completed") decidedIds.add(event.finding_id);
17760
+ }
17761
+ const seedable = (id, finding) => {
17762
+ if (openedIds.has(id) || !inView(finding)) return false;
17763
+ if (finding.status === "open") return true;
17764
+ return (finding.status === "resolved" || finding.status === "accepted-risk") && decidedIds.has(id);
17765
+ };
17766
+ const tracked = /* @__PURE__ */ new Map();
17767
+ const open = emptyCounts();
17768
+ const points = [];
17769
+ const totals = { opened: 0, resolved: 0, accepted: 0 };
17770
+ let since = null;
17771
+ let seeded = false;
17772
+ const bump = (severity, by) => {
17773
+ if (severity !== null) open[severity] = Math.max(0, open[severity] + by);
17774
+ };
17775
+ const mark = (event, type, id) => {
17776
+ points.push({ ts: typeof event.ts === "string" ? event.ts : "", open: { ...open }, cause: { type, id } });
17777
+ };
17778
+ const count = (type) => {
17779
+ totals[type]++;
17780
+ if (since !== null) since[type]++;
17781
+ };
17782
+ for (const event of orderEvents(relevant)) {
17783
+ const type = EVENT_CAUSE[event.type];
17784
+ if (type === "audit") {
17785
+ if (!seeded) {
17786
+ seeded = true;
17787
+ for (const [id2, finding] of sectionById) {
17788
+ if (tracked.has(id2) || !seedable(id2, finding)) continue;
17789
+ const severity = severityOf(finding, library);
17790
+ tracked.set(id2, { severity, open: true, surface: finding.surface, criterion_id: finding.criterion_id });
17791
+ bump(severity, 1);
17792
+ }
17793
+ }
17794
+ if (!filtered) Object.assign(open, cleanCounts2(event.counts));
17795
+ const auditId = isString2(event.audit_id) ? event.audit_id : isString2(event.id) ? event.id : "";
17796
+ since = { audit_id: auditId, ts: typeof event.ts === "string" ? event.ts : "", opened: 0, resolved: 0, accepted: 0 };
17797
+ mark(event, "audit", auditId);
17798
+ continue;
17799
+ }
17800
+ const id = event.finding_id;
17801
+ if (!isString2(id)) continue;
17802
+ const known = tracked.get(id);
17803
+ if (type === "opened") {
17804
+ if (known?.open) continue;
17805
+ if (!inView(event)) continue;
17806
+ const severity = asSeverity(event.severity);
17807
+ tracked.set(id, {
17808
+ severity,
17809
+ open: true,
17810
+ ...typeof event.surface === "string" ? { surface: event.surface } : {},
17811
+ ...typeof event.criterion_id === "string" ? { criterion_id: event.criterion_id } : {}
17812
+ });
17813
+ bump(severity, 1);
17814
+ count("opened");
17815
+ mark(event, "opened", id);
17816
+ continue;
17817
+ }
17818
+ if (known !== void 0) {
17819
+ if (!known.open) continue;
17820
+ known.open = false;
17821
+ bump(known.severity, -1);
17822
+ } else {
17823
+ const fromSection = sectionById.get(id);
17824
+ if (!inView(fromSection)) continue;
17825
+ tracked.set(id, {
17826
+ severity: null,
17827
+ open: false,
17828
+ ...fromSection ? { surface: fromSection.surface, criterion_id: fromSection.criterion_id } : {}
17829
+ });
17830
+ }
17831
+ count(type);
17832
+ mark(event, type, id);
17833
+ }
17834
+ return { points, ...totals, since };
17835
+ }
17836
+ function burndownRows(burndown) {
17837
+ const { points, since } = burndown;
17838
+ if (points.length === 0) return { reference: null, rows: [] };
17839
+ let referenceIndex = 0;
17840
+ if (since !== null) {
17841
+ for (let index = points.length - 1; index >= 0; index--) {
17842
+ if (points[index].cause.type === "audit") {
17843
+ referenceIndex = index;
17844
+ break;
17845
+ }
17846
+ }
17847
+ }
17848
+ const reference = points[referenceIndex];
17849
+ const last = points[points.length - 1];
17850
+ return {
17851
+ reference: {
17852
+ kind: since !== null ? "audit" : "start",
17853
+ id: reference.cause.id,
17854
+ ts: reference.ts
17855
+ },
17856
+ rows: FINDING_SEVERITIES.map((severity) => ({
17857
+ severity,
17858
+ at_reference: reference.open[severity],
17859
+ now: last.open[severity],
17860
+ change: last.open[severity] - reference.open[severity]
17861
+ }))
17862
+ };
17863
+ }
17864
+ function burndownSummary(burndown, openNow) {
17865
+ if (burndown.points.length === 0) return null;
17866
+ const tally = burndown.since ?? burndown;
17867
+ const closed = tally.resolved + tally.accepted;
17868
+ const where = burndown.since ? ` since the ${burndown.since.audit_id} audit` : "";
17869
+ const open = openNow ?? openTotal(burndown.points[burndown.points.length - 1].open);
17870
+ return `${closed} closed${where} (${tally.resolved} resolved, ${tally.accepted} accepted) \xB7 ${tally.opened} opened \xB7 ${open} open`;
17871
+ }
17872
+
17707
17873
  // src/commands/init.ts
17708
17874
  var DEFAULT_BUNDLE_PATH = "docs/arkaik/bundle.json";
17709
17875
  var DEFAULT_JOURNAL_PATH = "docs/arkaik/journal.jsonl";
@@ -18296,7 +18462,8 @@ function renderEventLine(event, nodesById) {
18296
18462
  const from = str(event.from) ?? "?";
18297
18463
  const to = str(event.to) ?? "?";
18298
18464
  const platform = str(event.platform);
18299
- return `${title(event.node_id, nodesById)}: ${from} -> ${to}${platform ? ` [${platform}]` : ""}`;
18465
+ const detail = str(event.detail);
18466
+ return `${title(event.node_id, nodesById)}: ${from} -> ${to}${platform ? ` [${platform}]` : ""}${detail ? ` - ${detail}` : ""}`;
18300
18467
  }
18301
18468
  case "node.deleted":
18302
18469
  return `${title(event.node_id, nodesById)} deleted`;
@@ -22133,6 +22300,7 @@ Subcommands:
22133
22300
  signals The signal pack, and what has tripped since the last audit.
22134
22301
  regressions What got worse between two audits.
22135
22302
  trend Every recorded audit's scores, and which way each moved.
22303
+ burndown Open findings over time, and what closed since the last audit.
22136
22304
  scope The cells your resolved findings made stale since the last audit.
22137
22305
  issue <criterion> Print the prefilled GitHub issue skeleton.
22138
22306
  criterion add ... Add a project-specific criterion to the overlay.
@@ -22249,6 +22417,21 @@ Reads the journal, so it needs a bundle (--bundle, default docs/arkaik/bundle.js
22249
22417
  and audits recorded with \`arkaik kritik matrix --record\`. A framework major
22250
22418
  bump between two audits breaks the comparison there (SPEC \xA7 8): the row still
22251
22419
  prints, without an arrow.`;
22420
+ var BURNDOWN_USAGE = `arkaik kritik burndown [--surface <s>] [--domain <CODE>] [--json]
22421
+
22422
+ How many findings closed since the last recorded audit, and how many are open
22423
+ by severity then and now. The findings, not the score: a score only moves when
22424
+ its cell is re-scored, and this moves the day a finding closes.
22425
+
22426
+ --surface <s> Only findings on that surface.
22427
+ --domain <CODE> Only findings in that domain (SEC, PRF, \u2026).
22428
+ --json Print the totals, the table and every point as JSON.
22429
+
22430
+ Replays quality.finding.opened / resolved / accepted from the journal, so it
22431
+ needs a bundle (--bundle, default docs/arkaik/bundle.json). Each recorded audit
22432
+ (\`arkaik kritik matrix --record\`) re-baselines the counts to what it counted,
22433
+ which corrects a finding closed by hand. A narrowed view is never re-baselined:
22434
+ an audit's counts are project-wide.`;
22252
22435
  var SCOPE_USAGE = `arkaik kritik scope [--since <audit>] [--no-widen] [--json]
22253
22436
 
22254
22437
  The cells a batch of fixes made stale. A score is an assessment, so closing
@@ -23080,6 +23263,86 @@ function runTrend(args, common) {
23080
23263
  );
23081
23264
  process.exit(0);
23082
23265
  }
23266
+ function runBurndown(args, common) {
23267
+ const { single, flags } = collect(args, [], ["json"]);
23268
+ if (flags.has("help")) {
23269
+ console.log(BURNDOWN_USAGE);
23270
+ process.exit(0);
23271
+ }
23272
+ const journal = resolveJournal(common.root, common.bundlePath);
23273
+ if (!journal.present) {
23274
+ fail12(
23275
+ `kritik: no bundle at ${journal.bundlePath} \u2014 the burndown is read from the journal's quality.finding.* events, and there is no journal without a bundle.`
23276
+ );
23277
+ }
23278
+ const events = readFullJournalEvents(journal.journalPath);
23279
+ let library;
23280
+ let section;
23281
+ try {
23282
+ library = loadKritikLibrary(common.root).library;
23283
+ section = loadCurrentQualitySection(common.root, library);
23284
+ } catch {
23285
+ }
23286
+ const filter = {
23287
+ ...single.surface !== void 0 ? { surface: single.surface } : {},
23288
+ ...single.domain !== void 0 ? { domain: single.domain } : {}
23289
+ };
23290
+ const burndown = deriveFindingsBurndown(events, { ...filter, library, findings: section?.findings });
23291
+ const openNow = section ? section.findings.filter(
23292
+ (finding) => isOpenFinding(finding) && (filter.surface === void 0 || finding.surface === filter.surface) && (filter.domain === void 0 || domainCodeOf(finding.criterion_id, library) === filter.domain)
23293
+ ).length : void 0;
23294
+ const { reference, rows } = burndownRows(burndown);
23295
+ const summary = burndownSummary(burndown, openNow);
23296
+ if (flags.has("json")) {
23297
+ console.log(
23298
+ JSON.stringify(
23299
+ {
23300
+ summary,
23301
+ opened: burndown.opened,
23302
+ resolved: burndown.resolved,
23303
+ accepted: burndown.accepted,
23304
+ since: burndown.since,
23305
+ ...openNow !== void 0 ? { open: openNow } : {},
23306
+ reference,
23307
+ rows,
23308
+ points: burndown.points
23309
+ },
23310
+ null,
23311
+ 2
23312
+ )
23313
+ );
23314
+ process.exit(0);
23315
+ }
23316
+ if (summary === null || reference === null) {
23317
+ console.log(
23318
+ `
23319
+ no finding history yet \u2014 \`arkaik kritik finding open\` and \`finding resolve\` write it, and \`arkaik kritik matrix --record\` records an audit to measure from.
23320
+ `
23321
+ );
23322
+ process.exit(0);
23323
+ }
23324
+ const referenceTitle = reference.kind === "audit" ? `at ${reference.id}` : "at start";
23325
+ const header = ["severity", referenceTitle, "now", "change"];
23326
+ const table = rows.map((row) => [
23327
+ row.severity,
23328
+ String(row.at_reference),
23329
+ String(row.now),
23330
+ row.change === 0 ? "=" : row.change > 0 ? `+${row.change}` : `\u2212${Math.abs(row.change)}`
23331
+ ]);
23332
+ const widths = header.map((title2, column) => Math.max(title2.length, ...table.map((line3) => line3[column].length)));
23333
+ const line2 = (cells) => ` ${cells.map((cell, column) => cell.padEnd(widths[column])).join(" ")}`.trimEnd();
23334
+ console.log(`
23335
+ ${summary}
23336
+ `);
23337
+ console.log(line2(header));
23338
+ for (const cells of table) console.log(line2(cells));
23339
+ if (reference.kind === "start") {
23340
+ console.log(`
23341
+ no recorded audit \u2014 read from the first event (${reference.ts.slice(0, 10)}).`);
23342
+ }
23343
+ console.log("");
23344
+ process.exit(0);
23345
+ }
23083
23346
  function scopeReason(cell, resolvedBy) {
23084
23347
  if (cell.kind === "widened") return `widened via ${cell.because.join(", ")}`;
23085
23348
  const findings = cell.because.map((id) => resolvedBy[id] !== void 0 ? `${id} (resolved by ${resolvedBy[id]})` : id);
@@ -23312,6 +23575,8 @@ function runKritik(args) {
23312
23575
  return runRegressions(subArgs, common);
23313
23576
  case "trend":
23314
23577
  return runTrend(subArgs, common);
23578
+ case "burndown":
23579
+ return runBurndown(subArgs, common);
23315
23580
  case "scope":
23316
23581
  return runScope(subArgs, common);
23317
23582
  case "issue":
@@ -23353,7 +23618,7 @@ Options:
23353
23618
  -v, --version Print the version.
23354
23619
 
23355
23620
  Run "arkaik <command> --help" for command-specific help.`;
23356
- var VERSION = "0.7.0";
23621
+ var VERSION = "0.9.0";
23357
23622
  function main(argv) {
23358
23623
  const [command, ...rest] = argv;
23359
23624
  if (command === void 0 || command === "--help" || command === "-h" || command === "help") {
package/dist/io.js CHANGED
@@ -15067,7 +15067,7 @@ function missingProvenanceNodeIds(snapshotNodeIds, events) {
15067
15067
  var envelope = {
15068
15068
  id: external_exports.string().meta({ description: "ULID \u2014 sortable, collision-free without coordination." }),
15069
15069
  ts: external_exports.string().meta({ description: "ISO 8601 timestamp." }),
15070
- actor: external_exports.string().optional().meta({ description: 'Who/what wrote it (e.g. "claude-code", "ci").' }),
15070
+ actor: external_exports.string().optional().meta({ description: 'Who/what wrote it (e.g. "claude-code", "arkaik-ci").' }),
15071
15071
  v: external_exports.number().int().optional().meta({ description: "Reserved per-event payload version; absent today." })
15072
15072
  };
15073
15073
  var JournalEventSchema = external_exports.object({
@@ -15094,7 +15094,8 @@ var NodeStatusChangedEventSchema = external_exports.object({
15094
15094
  // their legacy status ids, so strict per-type validation must accept them.
15095
15095
  from: AnyStatusSchema,
15096
15096
  to: AnyStatusSchema,
15097
- platform: PlatformSchema.optional()
15097
+ platform: PlatformSchema.optional(),
15098
+ detail: external_exports.string().optional()
15098
15099
  }).catchall(external_exports.unknown());
15099
15100
  var DecisionStatusChangedEventSchema = external_exports.object({
15100
15101
  ...envelope,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkaik",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Arkaik CLI — link a repository to a hosted product graph, validate and pack bundles, mirror external ref status.",
5
5
  "license": "MIT",
6
6
  "type": "module",