@aperant/framework 0.17.0 → 0.19.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.
Files changed (152) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/dist/cli/commands/ci-watch.mjs +49 -2
  3. package/dist/cli/commands/ci-watch.mjs.map +1 -1
  4. package/dist/cli/commands/commit.mjs +3 -3
  5. package/dist/cli/commands/commit.mjs.map +1 -1
  6. package/dist/cli/commands/event.mjs +16 -16
  7. package/dist/cli/commands/event.mjs.map +1 -1
  8. package/dist/cli/commands/merge-integrate.mjs +3 -3
  9. package/dist/cli/commands/merge-integrate.mjs.map +1 -1
  10. package/dist/cli/commands/produce.d.mts +9 -0
  11. package/dist/cli/commands/produce.d.mts.map +1 -0
  12. package/dist/cli/commands/produce.mjs +1345 -0
  13. package/dist/cli/commands/produce.mjs.map +1 -0
  14. package/dist/cli/commands/task.d.mts +16 -1
  15. package/dist/cli/commands/task.d.mts.map +1 -1
  16. package/dist/cli/commands/task.mjs +434 -266
  17. package/dist/cli/commands/task.mjs.map +1 -1
  18. package/dist/cli/coordination/auto-emit-artifact-ready.mjs +5 -5
  19. package/dist/cli/coordination/auto-emit-artifact-ready.mjs.map +1 -1
  20. package/dist/cli/coordination/event-schema.d.mts +5 -3
  21. package/dist/cli/coordination/event-schema.d.mts.map +1 -1
  22. package/dist/cli/coordination/event-schema.mjs +245 -21
  23. package/dist/cli/coordination/event-schema.mjs.map +1 -1
  24. package/dist/cli/coordination/store.d.mts +2 -2
  25. package/dist/cli/coordination/store.mjs +4 -4
  26. package/dist/cli/coordination/store.mjs.map +1 -1
  27. package/dist/cli/dispatch.d.mts.map +1 -1
  28. package/dist/cli/dispatch.mjs +2 -0
  29. package/dist/cli/dispatch.mjs.map +1 -1
  30. package/dist/cli/help.d.mts.map +1 -1
  31. package/dist/cli/help.mjs +30 -0
  32. package/dist/cli/help.mjs.map +1 -1
  33. package/dist/cli/install/legacy-paths.d.mts.map +1 -1
  34. package/dist/cli/install/legacy-paths.mjs +2 -0
  35. package/dist/cli/install/legacy-paths.mjs.map +1 -1
  36. package/dist/cli/produce/blind-probe.d.mts +85 -0
  37. package/dist/cli/produce/blind-probe.d.mts.map +1 -0
  38. package/dist/cli/produce/blind-probe.mjs +217 -0
  39. package/dist/cli/produce/blind-probe.mjs.map +1 -0
  40. package/dist/cli/produce/claim.d.mts +188 -0
  41. package/dist/cli/produce/claim.d.mts.map +1 -0
  42. package/dist/cli/produce/claim.mjs +518 -0
  43. package/dist/cli/produce/claim.mjs.map +1 -0
  44. package/dist/cli/produce/done-gate.d.mts +87 -0
  45. package/dist/cli/produce/done-gate.d.mts.map +1 -0
  46. package/dist/cli/produce/done-gate.mjs +200 -0
  47. package/dist/cli/produce/done-gate.mjs.map +1 -0
  48. package/dist/cli/produce/events.d.mts +77 -0
  49. package/dist/cli/produce/events.d.mts.map +1 -0
  50. package/dist/cli/produce/events.mjs +126 -0
  51. package/dist/cli/produce/events.mjs.map +1 -0
  52. package/dist/cli/produce/evidence-oracle.d.mts +63 -0
  53. package/dist/cli/produce/evidence-oracle.d.mts.map +1 -0
  54. package/dist/cli/produce/evidence-oracle.mjs +122 -0
  55. package/dist/cli/produce/evidence-oracle.mjs.map +1 -0
  56. package/dist/cli/produce/ledger.d.mts +140 -0
  57. package/dist/cli/produce/ledger.d.mts.map +1 -0
  58. package/dist/cli/produce/ledger.mjs +272 -0
  59. package/dist/cli/produce/ledger.mjs.map +1 -0
  60. package/dist/cli/produce/probe-family.d.mts +53 -0
  61. package/dist/cli/produce/probe-family.d.mts.map +1 -0
  62. package/dist/cli/produce/probe-family.mjs +160 -0
  63. package/dist/cli/produce/probe-family.mjs.map +1 -0
  64. package/dist/cli/produce/projection.d.mts +55 -0
  65. package/dist/cli/produce/projection.d.mts.map +1 -0
  66. package/dist/cli/produce/projection.mjs +97 -0
  67. package/dist/cli/produce/projection.mjs.map +1 -0
  68. package/dist/cli/produce/run-id.d.mts +42 -0
  69. package/dist/cli/produce/run-id.d.mts.map +1 -0
  70. package/dist/cli/produce/run-id.mjs +79 -0
  71. package/dist/cli/produce/run-id.mjs.map +1 -0
  72. package/dist/cli/produce/saga.d.mts +180 -0
  73. package/dist/cli/produce/saga.d.mts.map +1 -0
  74. package/dist/cli/produce/saga.mjs +290 -0
  75. package/dist/cli/produce/saga.mjs.map +1 -0
  76. package/dist/cli/produce/scheduler.d.mts +165 -0
  77. package/dist/cli/produce/scheduler.d.mts.map +1 -0
  78. package/dist/cli/produce/scheduler.mjs +399 -0
  79. package/dist/cli/produce/scheduler.mjs.map +1 -0
  80. package/dist/cli/produce/setpoint.d.mts +52 -0
  81. package/dist/cli/produce/setpoint.d.mts.map +1 -0
  82. package/dist/cli/produce/setpoint.mjs +113 -0
  83. package/dist/cli/produce/setpoint.mjs.map +1 -0
  84. package/dist/cli/produce/verification-ttl.d.mts +75 -0
  85. package/dist/cli/produce/verification-ttl.d.mts.map +1 -0
  86. package/dist/cli/produce/verification-ttl.mjs +169 -0
  87. package/dist/cli/produce/verification-ttl.mjs.map +1 -0
  88. package/dist/cli/roadmap/{conductor-view.d.mts → showrunner-view.d.mts} +3 -3
  89. package/dist/cli/roadmap/showrunner-view.d.mts.map +1 -0
  90. package/dist/cli/roadmap/{conductor-view.mjs → showrunner-view.mjs} +7 -7
  91. package/dist/cli/roadmap/showrunner-view.mjs.map +1 -0
  92. package/dist/plugin/.claude-plugin/plugin.json +2 -1
  93. package/dist/plugin/skills/apt/SKILL.md +112 -38
  94. package/dist/plugin/skills/apt-debug/SKILL.md +14 -24
  95. package/dist/plugin/skills/apt-fan-out/SKILL.md +4 -4
  96. package/dist/plugin/skills/apt-handoff/SKILL.md +1 -1
  97. package/dist/plugin/skills/apt-plan/SKILL.md +5 -5
  98. package/dist/plugin/skills/apt-plan/adapters/{conductor.md → showrunner.md} +16 -16
  99. package/dist/plugin/skills/apt-produce/SKILL.md +606 -0
  100. package/dist/plugin/skills/apt-quick/SKILL.md +14 -22
  101. package/dist/plugin/skills/apt-run/SKILL.md +126 -3
  102. package/dist/plugin/skills/apt-ship/SKILL.md +2 -0
  103. package/dist/plugin/skills/apt-spar/SKILL.md +5 -3
  104. package/dist/plugin/skills/apt-watch-ci/SKILL.md +4 -4
  105. package/package.json +4 -4
  106. package/prompts/{conductor-framework-context.md → showrunner-framework-context.md} +1 -1
  107. package/prompts/{conductor-status-check.md → showrunner-status-check.md} +1 -1
  108. package/prompts/{conductor-sub-agent.md → showrunner-sub-agent.md} +6 -6
  109. package/prompts/{conductor-system.md → showrunner-system.md} +8 -8
  110. package/skills/apt/SKILL.md +112 -38
  111. package/skills/apt-debug/SKILL.md +14 -24
  112. package/skills/apt-fan-out/SKILL.md +4 -4
  113. package/skills/apt-handoff/SKILL.md +1 -1
  114. package/skills/apt-plan/SKILL.md +5 -5
  115. package/skills/apt-plan/adapters/{conductor.md → showrunner.md} +16 -16
  116. package/skills/apt-produce/SKILL.md +606 -0
  117. package/skills/apt-quick/SKILL.md +14 -22
  118. package/skills/apt-run/SKILL.md +126 -3
  119. package/skills/apt-ship/SKILL.md +2 -0
  120. package/skills/apt-spar/SKILL.md +5 -3
  121. package/skills/apt-watch-ci/SKILL.md +4 -4
  122. package/src/cli/commands/ci-watch.mjs +51 -2
  123. package/src/cli/commands/commit.mjs +3 -3
  124. package/src/cli/commands/event.mjs +16 -16
  125. package/src/cli/commands/merge-integrate.mjs +3 -3
  126. package/src/cli/commands/produce.mjs +1466 -0
  127. package/src/cli/commands/task.mjs +482 -285
  128. package/src/cli/coordination/auto-emit-artifact-ready.mjs +5 -5
  129. package/src/cli/coordination/event-schema.d.ts +4 -2
  130. package/src/cli/coordination/event-schema.mjs +276 -21
  131. package/src/cli/coordination/store.mjs +4 -4
  132. package/src/cli/dispatch.mjs +2 -0
  133. package/src/cli/help.mjs +30 -0
  134. package/src/cli/install/legacy-paths.mjs +2 -0
  135. package/src/cli/produce/blind-probe.mjs +245 -0
  136. package/src/cli/produce/claim.mjs +543 -0
  137. package/src/cli/produce/done-gate.mjs +238 -0
  138. package/src/cli/produce/events.mjs +131 -0
  139. package/src/cli/produce/evidence-oracle.mjs +133 -0
  140. package/src/cli/produce/ledger.mjs +284 -0
  141. package/src/cli/produce/probe-family.mjs +168 -0
  142. package/src/cli/produce/projection.mjs +105 -0
  143. package/src/cli/produce/run-id.mjs +84 -0
  144. package/src/cli/produce/saga.mjs +303 -0
  145. package/src/cli/produce/scheduler.mjs +423 -0
  146. package/src/cli/produce/setpoint.mjs +122 -0
  147. package/src/cli/produce/verification-ttl.mjs +191 -0
  148. package/src/cli/roadmap/showrunner-view.d.ts +10 -0
  149. package/src/cli/roadmap/{conductor-view.mjs → showrunner-view.mjs} +6 -6
  150. package/dist/cli/roadmap/conductor-view.d.mts.map +0 -1
  151. package/dist/cli/roadmap/conductor-view.mjs.map +0 -1
  152. package/src/cli/roadmap/conductor-view.d.ts +0 -10
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Recompute the roadmap projection for a run by folding its append-only
3
+ * `produce.roadmap.*` events. `milestone_added` seeds a planned milestone (in
4
+ * first-seen order); `milestone_status_changed` advances its status. Idempotent
5
+ * re-adds keep the first seed (never clobber an advanced status). `updated_at`
6
+ * is derived from the last folded event's timestamp so the projection is
7
+ * DETERMINISTIC — two folds of the same log yield the identical roadmap.
8
+ *
9
+ * @param {string} projectDir
10
+ * @param {string} runId
11
+ * @returns {{ run_id: string, milestones: Array<{ id: string, title: string, status: string }>, updated_at: string | null }}
12
+ */
13
+ export function projectRoadmap(projectDir: string, runId: string): {
14
+ run_id: string;
15
+ milestones: Array<{
16
+ id: string;
17
+ title: string;
18
+ status: string;
19
+ }>;
20
+ updated_at: string | null;
21
+ };
22
+ /**
23
+ * The derived roadmap.json cache path for a run.
24
+ * @param {string} projectDir
25
+ * @param {string} runId
26
+ * @returns {string}
27
+ */
28
+ export function roadmapCachePath(projectDir: string, runId: string): string;
29
+ /**
30
+ * Refresh the derived roadmap.json cache single-writer under withFileLock, and
31
+ * return the freshly-folded roadmap. Convenience only — the log is the
32
+ * authority; a corrupt cache is repaired by re-folding (ID-01).
33
+ *
34
+ * The fold happens INSIDE the lock (not precomputed then written): the write is
35
+ * a full idempotent regenerate from the authoritative log, never a
36
+ * read-modify-write of a shared blob. This guarantees the last writer to
37
+ * acquire the lock persists the COMPLETE set — a precompute-then-write pattern
38
+ * could persist a STALE fold if a concurrent O_APPEND landed between the
39
+ * precompute and the write, silently dropping that milestone from the cache
40
+ * (parent TD-06 / subtask 4). The event log stays lossless regardless.
41
+ *
42
+ * @param {string} projectDir
43
+ * @param {string} runId
44
+ * @returns {{ run_id: string, milestones: Array<{ id: string, title: string, status: string }>, updated_at: string | null }}
45
+ */
46
+ export function writeProjectionCache(projectDir: string, runId: string): {
47
+ run_id: string;
48
+ milestones: Array<{
49
+ id: string;
50
+ title: string;
51
+ status: string;
52
+ }>;
53
+ updated_at: string | null;
54
+ };
55
+ //# sourceMappingURL=projection.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection.d.mts","sourceRoot":"","sources":["../../../src/cli/produce/projection.mjs"],"names":[],"mappings":"AAyBA;;;;;;;;;;;GAWG;AACH,2CAJW,MAAM,SACN,MAAM,GACJ;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CA6B3H;AAED;;;;;GAKG;AACH,6CAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,iDAJW,MAAM,SACN,MAAM,GACJ;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAa3H"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * @internal
3
+ * produce/projection.mjs — event-sourced roadmap projection (M1, ID-01).
4
+ *
5
+ * The roadmap is DERIVED: `projectRoadmap` folds the run's `produce.roadmap.*`
6
+ * events into `{ run_id, milestones:[{id,title,status}], updated_at }` on every
7
+ * call. It is NEVER read as the source of truth — a persisted `roadmap.json`
8
+ * cache MAY be written for convenience but is always regenerable from the log,
9
+ * so the shared-mutable-blob lost-update bug is structurally impossible.
10
+ *
11
+ * `writeProjectionCache` is a SINGLE-WRITER-PER-RECORD write under withFileLock
12
+ * (a torn cache is recoverable by re-folding). The event log is the authority;
13
+ * the cache is disposable.
14
+ */
15
+ import { join } from 'node:path';
16
+ import { withFileLock } from '../util/fs-lock.mjs';
17
+ import { atomicWriteJson } from '../util/io.mjs';
18
+ import { resolveMainRepoRoot } from '../util/state-paths.mjs';
19
+ import { readProduceEventsForRun } from './events.mjs';
20
+ import { resolveRunDir } from './run-id.mjs';
21
+ /** M1 milestone lifecycle — `done` is external-oracle-gated (M2, ID-03). */
22
+ const SEED_STATUS = 'planned';
23
+ /**
24
+ * Recompute the roadmap projection for a run by folding its append-only
25
+ * `produce.roadmap.*` events. `milestone_added` seeds a planned milestone (in
26
+ * first-seen order); `milestone_status_changed` advances its status. Idempotent
27
+ * re-adds keep the first seed (never clobber an advanced status). `updated_at`
28
+ * is derived from the last folded event's timestamp so the projection is
29
+ * DETERMINISTIC — two folds of the same log yield the identical roadmap.
30
+ *
31
+ * @param {string} projectDir
32
+ * @param {string} runId
33
+ * @returns {{ run_id: string, milestones: Array<{ id: string, title: string, status: string }>, updated_at: string | null }}
34
+ */
35
+ export function projectRoadmap(projectDir, runId) {
36
+ const events = readProduceEventsForRun(projectDir, runId);
37
+ const byId = new Map();
38
+ const order = [];
39
+ let updatedAt = null;
40
+ for (const e of events) {
41
+ const d = e.data || {};
42
+ const id = typeof d.milestone_id === 'string' ? d.milestone_id : null;
43
+ if (e.op === 'produce.roadmap.milestone_added') {
44
+ if (id && !byId.has(id)) {
45
+ byId.set(id, { id, title: typeof d.title === 'string' ? d.title : id, status: SEED_STATUS });
46
+ order.push(id);
47
+ }
48
+ }
49
+ else if (e.op === 'produce.roadmap.milestone_status_changed') {
50
+ if (id && byId.has(id) && typeof d.status === 'string') {
51
+ byId.get(id).status = d.status;
52
+ }
53
+ }
54
+ if (typeof e.t === 'string')
55
+ updatedAt = e.t;
56
+ }
57
+ return {
58
+ run_id: runId,
59
+ milestones: order.map((id) => byId.get(id)),
60
+ updated_at: updatedAt,
61
+ };
62
+ }
63
+ /**
64
+ * The derived roadmap.json cache path for a run.
65
+ * @param {string} projectDir
66
+ * @param {string} runId
67
+ * @returns {string}
68
+ */
69
+ export function roadmapCachePath(projectDir, runId) {
70
+ return join(resolveRunDir(projectDir, runId), 'roadmap.json');
71
+ }
72
+ /**
73
+ * Refresh the derived roadmap.json cache single-writer under withFileLock, and
74
+ * return the freshly-folded roadmap. Convenience only — the log is the
75
+ * authority; a corrupt cache is repaired by re-folding (ID-01).
76
+ *
77
+ * The fold happens INSIDE the lock (not precomputed then written): the write is
78
+ * a full idempotent regenerate from the authoritative log, never a
79
+ * read-modify-write of a shared blob. This guarantees the last writer to
80
+ * acquire the lock persists the COMPLETE set — a precompute-then-write pattern
81
+ * could persist a STALE fold if a concurrent O_APPEND landed between the
82
+ * precompute and the write, silently dropping that milestone from the cache
83
+ * (parent TD-06 / subtask 4). The event log stays lossless regardless.
84
+ *
85
+ * @param {string} projectDir
86
+ * @param {string} runId
87
+ * @returns {{ run_id: string, milestones: Array<{ id: string, title: string, status: string }>, updated_at: string | null }}
88
+ */
89
+ export function writeProjectionCache(projectDir, runId) {
90
+ const path = roadmapCachePath(projectDir, runId);
91
+ return withFileLock(path, () => {
92
+ const roadmap = projectRoadmap(projectDir, runId);
93
+ atomicWriteJson(path, roadmap);
94
+ return roadmap;
95
+ }, { projectRoot: resolveMainRepoRoot(projectDir) });
96
+ }
97
+ //# sourceMappingURL=projection.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection.mjs","sourceRoot":"","sources":["../../../src/cli/produce/projection.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C,4EAA4E;AAC5E,MAAM,WAAW,GAAG,SAAS,CAAA;AAE7B;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,UAAU,EAAE,KAAK;IAC/C,MAAM,MAAM,GAAG,uBAAuB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IACzD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,CAAA;IACtB,MAAM,KAAK,GAAG,EAAE,CAAA;IAChB,IAAI,SAAS,GAAG,IAAI,CAAA;IAEpB,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACxB,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,EAAE,CAAA;QACtB,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAA;QACrE,IAAI,CAAC,CAAC,EAAE,KAAK,iCAAiC,EAAE,CAAC;YAChD,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBACzB,IAAI,CAAC,GAAG,C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,UAAU,EAAE,KAAK,CAAC,CAAA;QACjD,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAC9B,OAAO,OAAO,CAAA;IACf,CAAC,EACD,EAAE,WAAW,EAAE,mBAAmB,CAAC,UAAU,CAAC,EAAE,CAChD,CAAA;AACF,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Slugify an outcome string into a short kebab identifier. Strips punctuation,
3
+ * lowercases, keeps the first `maxWords` words. Falls back to 'run' when empty.
4
+ *
5
+ * @param {string} outcome
6
+ * @param {number} [maxWords=6]
7
+ * @returns {string}
8
+ */
9
+ export function slugFromOutcome(outcome: string, maxWords?: number): string;
10
+ /**
11
+ * Mint a fresh run-id: `<slug>-<YYYYMMDD-HHMMSS>-<rand>`. The random suffix
12
+ * guarantees uniqueness even for identical outcomes minted in the same second.
13
+ *
14
+ * @param {string} outcome
15
+ * @param {Date} [now]
16
+ * @returns {string}
17
+ */
18
+ export function mintRunId(outcome: string, now?: Date): string;
19
+ /**
20
+ * The `.aperant/produce/` root, resolved to the shared main repo from any cwd.
21
+ *
22
+ * @param {string} projectDir
23
+ * @returns {string}
24
+ */
25
+ export function resolveProduceRoot(projectDir: string): string;
26
+ /**
27
+ * The run dir `.aperant/produce/<run-id>/`, resolved to the shared main repo.
28
+ *
29
+ * @param {string} projectDir
30
+ * @param {string} runId
31
+ * @returns {string}
32
+ */
33
+ export function resolveRunDir(projectDir: string, runId: string): string;
34
+ /**
35
+ * Repo-relative setpoint path for a run — used as the `setpoint_path` event
36
+ * field. Forward-slash separated for portability across the event log.
37
+ *
38
+ * @param {string} runId
39
+ * @returns {string}
40
+ */
41
+ export function relativeSetpointPath(runId: string): string;
42
+ //# sourceMappingURL=run-id.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-id.d.mts","sourceRoot":"","sources":["../../../src/cli/produce/run-id.mjs"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH,yCAJW,MAAM,aACN,MAAM,GACJ,MAAM,CAYlB;AAED;;;;;;;GAOG;AACH,mCAJW,MAAM,QACN,IAAI,GACF,MAAM,CAUlB;AAED;;;;;GAKG;AACH,+CAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;GAMG;AACH,0CAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;GAMG;AACH,4CAHW,MAAM,GACJ,MAAM,CAIlB"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @internal
3
+ * produce/run-id.mjs — mint + resolve produce run identifiers and run dirs (M1).
4
+ *
5
+ * A produce run is scoped to one frozen acceptance setpoint. Its run-id is a
6
+ * human-readable slug derived from the outcome plus a short timestamp and a
7
+ * random suffix (so two `start`s in the same second never collide). The run
8
+ * dir lives under the SHARED main-repo root at `.aperant/produce/<run-id>/`
9
+ * (resolveMainRepoRoot) so every worktree agent reads/writes one board
10
+ * (parent AC8 path / ID-06).
11
+ */
12
+ import { join } from 'node:path';
13
+ import { resolveMainRepoRoot } from '../util/state-paths.mjs';
14
+ /**
15
+ * Slugify an outcome string into a short kebab identifier. Strips punctuation,
16
+ * lowercases, keeps the first `maxWords` words. Falls back to 'run' when empty.
17
+ *
18
+ * @param {string} outcome
19
+ * @param {number} [maxWords=6]
20
+ * @returns {string}
21
+ */
22
+ export function slugFromOutcome(outcome, maxWords = 6) {
23
+ const words = String(outcome || '')
24
+ .toLowerCase()
25
+ .replace(/[^a-z0-9\s-]/g, ' ')
26
+ .trim()
27
+ .split(/\s+/)
28
+ .filter(Boolean)
29
+ .slice(0, maxWords);
30
+ const slug = words.join('-').replace(/-+/g, '-');
31
+ return slug || 'run';
32
+ }
33
+ /**
34
+ * Mint a fresh run-id: `<slug>-<YYYYMMDD-HHMMSS>-<rand>`. The random suffix
35
+ * guarantees uniqueness even for identical outcomes minted in the same second.
36
+ *
37
+ * @param {string} outcome
38
+ * @param {Date} [now]
39
+ * @returns {string}
40
+ */
41
+ export function mintRunId(outcome, now = new Date()) {
42
+ const stamp = now
43
+ .toISOString()
44
+ .replace(/\.\d+Z$/, '')
45
+ .replace(/[-:]/g, '')
46
+ .replace('T', '-');
47
+ const rand = Math.random().toString(36).slice(2, 6);
48
+ return `${slugFromOutcome(outcome)}-${stamp}-${rand}`;
49
+ }
50
+ /**
51
+ * The `.aperant/produce/` root, resolved to the shared main repo from any cwd.
52
+ *
53
+ * @param {string} projectDir
54
+ * @returns {string}
55
+ */
56
+ export function resolveProduceRoot(projectDir) {
57
+ return join(resolveMainRepoRoot(projectDir), '.aperant', 'produce');
58
+ }
59
+ /**
60
+ * The run dir `.aperant/produce/<run-id>/`, resolved to the shared main repo.
61
+ *
62
+ * @param {string} projectDir
63
+ * @param {string} runId
64
+ * @returns {string}
65
+ */
66
+ export function resolveRunDir(projectDir, runId) {
67
+ return join(resolveProduceRoot(projectDir), runId);
68
+ }
69
+ /**
70
+ * Repo-relative setpoint path for a run — used as the `setpoint_path` event
71
+ * field. Forward-slash separated for portability across the event log.
72
+ *
73
+ * @param {string} runId
74
+ * @returns {string}
75
+ */
76
+ export function relativeSetpointPath(runId) {
77
+ return ['.aperant', 'produce', runId, 'setpoint.json'].join('/');
78
+ }
79
+ //# sourceMappingURL=run-id.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-id.mjs","sourceRoot":"","sources":["../../../src/cli/produce/run-id.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAE7D;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,CAAC;IACpD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;SACjC,WAAW,EAAE;SACb,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC;SAC7B,IAAI,EAAE;SACN,KAAK,CAAC,KAAK,CAAC;SACZ,MAAM,CAAC,O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phase. Returns a fresh
3
+ * copy (the table is never handed out mutable) or null for an out-of-vocabulary
4
+ * phase (fail-closed). The returned descriptor ALWAYS has
5
+ * `rolls_back_merged_pr: false` (ID-M4-02).
6
+ *
7
+ * @param {string} phase
8
+ * @returns {{ kind: string, reopens_task: boolean, ships_revert: boolean, rolls_back_merged_pr: boolean } | null}
9
+ */
10
+ export function resolveCompensator(phase: string): {
11
+ kind: string;
12
+ reopens_task: boolean;
13
+ ships_revert: boolean;
14
+ rolls_back_merged_pr: boolean;
15
+ } | null;
16
+ /**
17
+ * Append `produce.saga.phase_entered` for a milestone's saga phase. Validates
18
+ * the phase against SAGA_PHASES fail-closed (an out-of-vocabulary phase appends
19
+ * nothing).
20
+ *
21
+ * @param {string} projectDir
22
+ * @param {{ runId: string, milestoneId: string, phase: string }} args
23
+ * @returns {{ ok: true, phase: string } | { ok: false, reason: string }}
24
+ */
25
+ export function enterPhase(projectDir: string, { runId, milestoneId, phase }: {
26
+ runId: string;
27
+ milestoneId: string;
28
+ phase: string;
29
+ }): {
30
+ ok: true;
31
+ phase: string;
32
+ } | {
33
+ ok: false;
34
+ reason: string;
35
+ };
36
+ /**
37
+ * Append `produce.saga.phase_completed` for a milestone's saga phase. Validates
38
+ * the phase against SAGA_PHASES fail-closed.
39
+ *
40
+ * @param {string} projectDir
41
+ * @param {{ runId: string, milestoneId: string, phase: string }} args
42
+ * @returns {{ ok: true, phase: string } | { ok: false, reason: string }}
43
+ */
44
+ export function completePhase(projectDir: string, { runId, milestoneId, phase }: {
45
+ runId: string;
46
+ milestoneId: string;
47
+ phase: string;
48
+ }): {
49
+ ok: true;
50
+ phase: string;
51
+ } | {
52
+ ok: false;
53
+ reason: string;
54
+ };
55
+ /**
56
+ * Fire the FORWARD compensator for a failed saga phase (ID-M4-02). Resolves the
57
+ * declared compensator, then appends `produce.saga.compensated {run_id,
58
+ * milestone_id, phase, compensator: <descriptor.kind>, reason}` — carrying the
59
+ * descriptor KIND, never a rollback instruction. Validates the phase fail-closed.
60
+ * The CLI records the forward compensator; it does NOT execute the revert/reopen/
61
+ * re-plan (OOS dispatch) and NEVER mutates the roadmap milestone status.
62
+ *
63
+ * @param {string} projectDir
64
+ * @param {{ runId: string, milestoneId: string, phase: string, reason?: string }} args
65
+ * @returns {{ ok: true, phase: string, compensator: object } | { ok: false, reason: string }}
66
+ */
67
+ export function compensatePhase(projectDir: string, { runId, milestoneId, phase, reason }: {
68
+ runId: string;
69
+ milestoneId: string;
70
+ phase: string;
71
+ reason?: string;
72
+ }): {
73
+ ok: true;
74
+ phase: string;
75
+ compensator: object;
76
+ } | {
77
+ ok: false;
78
+ reason: string;
79
+ };
80
+ /**
81
+ * Record a provider-diverse review verdict (ID-M4-04 / ID-08). The review-path
82
+ * analog of evidence-oracle.mjs::recordOracleVerdict. REFUSES fail-closed when
83
+ * the reviewer family equals the recorded implementer family (a same-family
84
+ * reviewer rubber-stamps its own family's work) or when no implementer family is
85
+ * recorded (ID-M2-02). On acceptance appends `produce.saga.reviewed {run_id,
86
+ * milestone_id, reviewer_family, verdict}`.
87
+ *
88
+ * @param {string} projectDir
89
+ * @param {{ runId: string, milestoneId: string, verdict: string, reviewerFamily: string }} args
90
+ * @returns {{ ok: true, verdict: string, reviewer_family: string, implementer_family: string }
91
+ * | { ok: false, reason: string, implementer_family?: string | null }}
92
+ */
93
+ export function recordReview(projectDir: string, { runId, milestoneId, verdict, reviewerFamily }: {
94
+ runId: string;
95
+ milestoneId: string;
96
+ verdict: string;
97
+ reviewerFamily: string;
98
+ }): {
99
+ ok: true;
100
+ verdict: string;
101
+ reviewer_family: string;
102
+ implementer_family: string;
103
+ } | {
104
+ ok: false;
105
+ reason: string;
106
+ implementer_family?: string | null;
107
+ };
108
+ /**
109
+ * Resolve a REVIEW-phase reviewer family DISJOINT from the recorded implementer
110
+ * (ID-M4-04 / ID-08), a THIN wrapper over the M2 `resolveProbeFamily` — NO
111
+ * duplicated cross-family / partner-map / model-resolution logic. Reads the
112
+ * implementer family from the recorded `produce.milestone.implemented` trail
113
+ * (fail-closed when absent). Returns the resolution with `probe_family` surfaced
114
+ * as `reviewer_family`. Provider is an OUTPUT; the model is resolved LIVE (null
115
+ * for self-resolving families) — never a hardcoded id.
116
+ *
117
+ * @param {string} projectDir
118
+ * @param {{ runId: string, milestoneId: string, hostFamily?: string | null, availableFamilies?: string[] }} args
119
+ * @returns {{ available: boolean, reviewer_family: string | null, implementer_family: string | null,
120
+ * transport_hint: object | null, model: string | null, source: string | null, reason: string | null }}
121
+ */
122
+ export function resolveReviewer(projectDir: string, { runId, milestoneId, hostFamily, availableFamilies }: {
123
+ runId: string;
124
+ milestoneId: string;
125
+ hostFamily?: string | null;
126
+ availableFamilies?: string[];
127
+ }): {
128
+ available: boolean;
129
+ reviewer_family: string | null;
130
+ implementer_family: string | null;
131
+ transport_hint: object | null;
132
+ model: string | null;
133
+ source: string | null;
134
+ reason: string | null;
135
+ };
136
+ /**
137
+ * Fold the run's `produce.saga.*` events into per-milestone saga state — a
138
+ * SEPARATE fold parallel to the roadmap projection (the roadmap projection folds
139
+ * `produce.roadmap.*` ONLY, so saga events never enter the roadmap the Showrunner
140
+ * re-reads each tick — blindness preserved, ID-M4-01). Deterministic: two folds
141
+ * of the same log yield the identical saga state; `updated_at` is the last folded
142
+ * event's timestamp.
143
+ *
144
+ * @param {string} projectDir
145
+ * @param {string} runId
146
+ * @returns {{
147
+ * run_id: string,
148
+ * milestones: Array<{
149
+ * milestone_id: string,
150
+ * current_phase: string | null,
151
+ * phase_status: 'entered' | 'completed' | null,
152
+ * phases: Record<string, 'entered' | 'completed'>,
153
+ * last_compensated: { phase: string | null, compensator: string | null, reason: string | null } | null,
154
+ * reviewed: { reviewer_family: string | null, verdict: string | null } | null,
155
+ * }>,
156
+ * updated_at: string | null,
157
+ * }}
158
+ */
159
+ export function projectSaga(projectDir: string, runId: string): {
160
+ run_id: string;
161
+ milestones: Array<{
162
+ milestone_id: string;
163
+ current_phase: string | null;
164
+ phase_status: "entered" | "completed" | null;
165
+ phases: Record<string, "entered" | "completed">;
166
+ last_compensated: {
167
+ phase: string | null;
168
+ compensator: string | null;
169
+ reason: string | null;
170
+ } | null;
171
+ reviewed: {
172
+ reviewer_family: string | null;
173
+ verdict: string | null;
174
+ } | null;
175
+ }>;
176
+ updated_at: string | null;
177
+ };
178
+ /** The ordered saga phases (ID-M4-01). Mirrors ALLOWED_SAGA_PHASES in event-schema.mjs. */
179
+ export const SAGA_PHASES: string[];
180
+ //# sourceMappingURL=saga.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saga.d.mts","sourceRoot":"","sources":["../../../src/cli/produce/saga.mjs"],"names":[],"mappings":"AA0EA;;;;;;;;GAQG;AACH,0CAHW,MAAM,GACJ;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;IAAC,oBAAoB,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAMhH;AAED;;;;;;;;GAQG;AACH,uCAJW,MAAM,iCACN;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAUvE;AAED;;;;;;;GAOG;AACH,0CAJW,MAAM,iCACN;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAUvE;AAED;;;;;;;;;;;GAWG;AACH,4CAJW,MAAM,yCACN;I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