@software-dlc/cli 0.159.1 → 0.164.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @software-dlc/cli
2
2
 
3
+ ## 0.164.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 16e5f0d: Graph: sdlc viewer draws the Queues page at org/<org>/queues from promote status: the four stages with their built-in policies, each stage's turns, waiting entries and batch, every holder named by its thread, and the turns running beside a batch on Main
8
+
9
+ ## 0.163.2
10
+
11
+ ### Patch Changes
12
+
13
+ - f4697e1: Graph: `sdlc workspace commit`'s dropped-evidence warning says to record the sources again with `sdlc workspace evidence record`, and `sdlc workspace attach --all-members` outside a folder's home says to attach each repository with `sdlc workspace attach`, so neither sends a public user to a command of the restricted engine
14
+
15
+ ## 0.163.1
16
+
17
+ ## 0.163.0
18
+
19
+ ## 0.162.0
20
+
21
+ ## 0.161.0
22
+
23
+ ### Minor Changes
24
+
25
+ - e10dd3b: Graph: `sdlc org edit` changes a local org's team, job function or slot (label, description, parent, the slots a function fills, its person and escalation flags), and `sdlc org remove` deletes a team, function, slot or post nothing still needs, naming what does. Every change is checked in one transaction, so an edit that would leave an agent on a person-only post or a gate post without a person is refused and nothing changes.
26
+
27
+ ## 0.160.0
28
+
3
29
  ## 0.159.1
4
30
 
5
31
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"cli-org.d.ts","sourceRoot":"","sources":["../src/cli-org.ts"],"names":[],"mappings":"AA+BA,eAAO,MAAM,SAAS,QAyBkC,CAAC;AAEzD,KAAK,iBAAiB,GAAG;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC3C,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAsMF,gFAAgF;AAChF,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
1
+ {"version":3,"file":"cli-org.d.ts","sourceRoot":"","sources":["../src/cli-org.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,SAAS,QAiCkC,CAAC;AAEzD,KAAK,iBAAiB,GAAG;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC3C,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AA2UF,gFAAgF;AAChF,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
package/dist/cli-org.js CHANGED
@@ -1,12 +1,17 @@
1
1
  import { resolve } from 'node:path';
2
2
  import { argumentValue, argumentValues, hasArgument } from './cli-arguments.js';
3
- import { addJobFunction, addPost, addSlot, addTeam, changeLocalBinding, changeLocalHolder, changeLocalOrg, defaultWorkflowPath, describeLocalOrg, describeLocalProject, escalateLocalSlot, LOCAL_ORG_MISSING, LOCAL_PERSON, localOrgRules, onOrg, openLocalOrgRepository, parseMember, readLocalOrg, readWorkflowRoles, resolveLocalSlots, seedLocalOrg, setLocalProjectTeam } from './local/local-org.js';
3
+ import { addJobFunction, addPost, addSlot, addTeam, changeLocalBinding, changeLocalHolder, changeLocalOrg, defaultWorkflowPath, describeLocalOrg, describeLocalProject, editJobFunction, editSlot, editTeam, escalateLocalSlot, LOCAL_ORG_MISSING, LOCAL_PERSON, localOrgRules, onOrg, openLocalOrgRepository, parseMember, readLocalOrg, readWorkflowRoles, removeDefinition, removePost, resolveLocalSlots, seedLocalOrg, setLocalProjectTeam } from './local/local-org.js';
4
4
  export const ORG_USAGE = 'Usage: sdlc org [show] [--workflow <file>]\n' +
5
5
  ' sdlc org seed [--workflow <file>] [--name <org name>]\n' +
6
6
  ' sdlc org add team <key> [--label <text>] [--parent <team>]\n' +
7
7
  ' sdlc org add function <key> [--label <text>] [--parent <function>] [--fills <slot>]... [--requires-person] [--not-escalable]\n' +
8
8
  ' sdlc org add slot <key> [--label <text>]\n' +
9
9
  ' sdlc org add post <team>/<function> [--label <text>]\n' +
10
+ ' sdlc org edit team <key> [--label <text>] [--description <text>] [--parent <team> | --no-parent] [--workflow <file>]\n' +
11
+ ' sdlc org edit function <key> [--label <text>] [--description <text>] [--parent <function> | --no-parent] [--fills <slot>... | --no-fills] [--requires-person | --no-requires-person] [--escalable | --not-escalable] [--workflow <file>]\n' +
12
+ ' sdlc org edit slot <key> [--label <text>] [--description <text>] [--workflow <file>]\n' +
13
+ ' sdlc org remove (team | function | slot) <key> [--workflow <file>]\n' +
14
+ ' sdlc org remove post <team>/<function> [--workflow <file>]\n' +
10
15
  ' sdlc org hold <team>/<function> (--person <id> | --agent <id>) [--workflow <file>]\n' +
11
16
  ' sdlc org release <team>/<function> (--person <id> | --agent <id>) [--workflow <file>]\n' +
12
17
  ' sdlc org resolve [<slot>] [--team <team>] [--workflow <file>]\n' +
@@ -20,6 +25,9 @@ export const ORG_USAGE = 'Usage: sdlc org [show] [--workflow <file>]\n' +
20
25
  "seed plans an org from the workflow's roles (default: scripts/agent-coordination/workflow.json in this checkout): a root team, an org lead function you hold, under it a slot and a job function for each role, a post for each function, and the workflow's people and agents as holders; a role held only by people or teams requires a person. It is refused once the org exists. " +
21
26
  "Every command reads the workflow's gates the same way: a gate whose role has a holder other than an agent needs a person. Without the default workflow there are no gates; a --workflow file that does not exist is refused. " +
22
27
  'add defines a team, function, slot or post; a post is a job function in a team, named <team>/<function>. hold and release change who holds a post: an agent may not hold a post whose function requires a person, a post deciding a person gate (from the workflow) keeps a person, and a post with reports has one holder, which add also keeps when a new function gives a held post reports. ' +
28
+ 'edit changes a definition; a flag left out keeps its value, an empty --description clears it, --fills replaces the slots a function fills, and a parent may not be the node itself or one under it. Moving a team or function changes only its parent: reporting lines, the chart and slot baselines follow. ' +
29
+ "remove deletes a definition nothing still needs, and is refused naming each thing that does: child teams or functions, posts, the functions filling a slot, the project a team owns, a post's holders, and project overrides naming a slot or post. " +
30
+ 'add, edit and remove check the whole org in one transaction: the definitions, then the holder rules over the new graph against the holders as they stand, so an edit that would leave an agent on a person-only post, a gate post without a person, or a post with reports with several holders is refused and nothing changes. ' +
23
31
  'resolve shows who plays each slot, or one: covered, vacant (posts nobody holds) or uncovered (no function fills it); --team resolves it for that team and its parents. ' +
24
32
  "The repository is the org's one project, owned by the team own names, or else by the org's only root team. " +
25
33
  "slots shows each slot's binding in that project: by default the posts whose function fills it in the owning team, or else the nearest parent team that has one (baseline); bind overrides that with the posts named and a reason, marking a post whose function does not fill the slot off-description, and unbind returns the slot to its baseline. " +
@@ -64,6 +72,94 @@ function definition(args) {
64
72
  const label = argumentValue(args, '--label');
65
73
  return { key: positional(args, 2, 'key'), ...(label ? { label } : {}) };
66
74
  }
75
+ const TYPE = {
76
+ team: 'team',
77
+ function: 'job_function',
78
+ slot: 'slot'
79
+ };
80
+ const PARENT_FLAGS = ['--parent', '--no-parent'];
81
+ const EDIT_FLAGS = {
82
+ team: PARENT_FLAGS,
83
+ function: [
84
+ ...PARENT_FLAGS,
85
+ '--fills',
86
+ '--no-fills',
87
+ '--requires-person',
88
+ '--no-requires-person',
89
+ '--escalable',
90
+ '--not-escalable'
91
+ ],
92
+ slot: []
93
+ };
94
+ /** A yes/no flag pair: true, false, or undefined when neither is given; both are refused. */
95
+ function toggle(args, on, off) {
96
+ const yes = hasArgument(args, on);
97
+ const no = hasArgument(args, off);
98
+ if (yes && no)
99
+ throw new Error(`Pass ${on} or ${off}, not both.`);
100
+ return yes ? true : no ? false : undefined;
101
+ }
102
+ /**
103
+ * A flag's value, or null when the flag is absent. A flag followed by
104
+ * another flag has no value: refused, unless `may_be_empty` (then null).
105
+ */
106
+ function flagValue(args, name, may_be_empty = false) {
107
+ if (!hasArgument(args, name))
108
+ return null;
109
+ const value = argumentValue(args, name);
110
+ if (value !== null && !value.startsWith('--'))
111
+ return value;
112
+ if (may_be_empty)
113
+ return null;
114
+ throw new Error(`${name} needs a value.`);
115
+ }
116
+ /** The changes `sdlc org edit <kind> <key>` names; a flag its kind does not take is refused. */
117
+ function definitionEdit(args, kind) {
118
+ const allowed = new Set([
119
+ '--label',
120
+ '--description',
121
+ '--workflow',
122
+ ...EDIT_FLAGS[kind]
123
+ ]);
124
+ for (const arg of args.slice(3)) {
125
+ if (!arg.startsWith('--'))
126
+ continue;
127
+ const flag = arg.split('=')[0];
128
+ if (!allowed.has(flag)) {
129
+ throw new Error(`sdlc org edit ${kind} does not take ${flag}.\n${ORG_USAGE}`);
130
+ }
131
+ // Only --fills reads the --flag=value form; any other would be dropped.
132
+ if (arg.includes('=') && flag !== '--fills') {
133
+ throw new Error(`Pass ${flag} <value> with a space, not ${arg}.`);
134
+ }
135
+ }
136
+ const label = flagValue(args, '--label');
137
+ const description = hasArgument(args, '--description')
138
+ ? (flagValue(args, '--description', true) ?? '')
139
+ : undefined;
140
+ const parent = flagValue(args, '--parent');
141
+ if (parent !== null && hasArgument(args, '--no-parent'))
142
+ throw new Error('Pass --parent <key> or --no-parent, not both.');
143
+ const fills = argumentValues(args, '--fills');
144
+ if (fills.length && hasArgument(args, '--no-fills'))
145
+ throw new Error('Pass --fills <slot>... or --no-fills, not both.');
146
+ return {
147
+ ...(label !== null ? { label } : {}),
148
+ ...(description !== undefined ? { description } : {}),
149
+ ...(parent !== null
150
+ ? { parent }
151
+ : hasArgument(args, '--no-parent')
152
+ ? { parent: null }
153
+ : {}),
154
+ ...(fills.length
155
+ ? { fills }
156
+ : hasArgument(args, '--no-fills')
157
+ ? { fills: [] }
158
+ : {}),
159
+ requires_person: toggle(args, '--requires-person', '--no-requires-person'),
160
+ escalable: toggle(args, '--escalable', '--not-escalable')
161
+ };
162
+ }
67
163
  async function run(args, repository, cwd) {
68
164
  const [action = 'show', kind] = args;
69
165
  if (action === 'show' || action === 'resolve') {
@@ -178,6 +274,34 @@ async function run(args, repository, cwd) {
178
274
  });
179
275
  return { added: kind, key: args[2], root: result.root };
180
276
  }
277
+ if (action === 'edit' || action === 'remove') {
278
+ if (!kind ||
279
+ !(Object.hasOwn(TYPE, kind) || (action === 'remove' && kind === 'post'))) {
280
+ throw new Error(`sdlc org ${action} takes ${action === 'edit' ? 'team, function or slot' : 'team, function, slot or post'}.\n${ORG_USAGE}`);
281
+ }
282
+ const key = positional(args, 2, kind === 'post' ? 'post, as <team>/<function>' : 'key');
283
+ const edit = action === 'edit' ? definitionEdit(args, kind) : null;
284
+ const result = await changeLocalOrg(repository, (current, rows) => {
285
+ const graph = onOrg(current, false);
286
+ if (!edit) {
287
+ return {
288
+ graph: kind === 'post'
289
+ ? removePost(graph, key, rows)
290
+ : removeDefinition(graph, TYPE[kind], key, rows)
291
+ };
292
+ }
293
+ if (kind === 'team')
294
+ return { graph: editTeam(graph, key, edit) };
295
+ if (kind === 'slot')
296
+ return { graph: editSlot(graph, key, edit) };
297
+ return { graph: editJobFunction(graph, key, edit) };
298
+ }, { workflow: await workflowFor(repository, args, cwd) });
299
+ return {
300
+ [action === 'edit' ? 'edited' : 'removed']: kind,
301
+ key,
302
+ root: result.root
303
+ };
304
+ }
181
305
  if (action === 'hold' || action === 'release') {
182
306
  return changeLocalHolder(repository, {
183
307
  action,
@@ -1 +1 @@
1
- {"version":3,"file":"cli-org.js","sourceRoot":"","sources":["../src/cli-org.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,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M,CAAC;IAChD,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC;QACnE,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC;QAC/B,OAAO,CAAC,CAAC;IACX,CAAC;IACD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACzC,IAAI,UAAU,GAA8B,IAAI,CAAC;IACjD,IAAI,CAAC;QACH,UAAU,GAAG,MAAM,sBAAsB,CAAC;YACxC,GAAG;YACH,SAAS,EAAE,OAAO,CAAC,SAAS;SAC7B,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;QAChD,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QACrD,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5E,OAAO,CAAC,CAAC;IACX,CAAC;YAAS,CAAC;QACT,UAAU,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { AppContractAnswer } from './app-contract-readers.js';
2
+ /**
3
+ * sdlc viewer's Queues page reads (lq6-local, docs/specs/live-queues.md LQ6): GET api/app/queues,
4
+ * the four promotion stages with what each list row draws, and api/app/queues/<stage>, one stage's
5
+ * configuration and its queue-state/v1. Both come from one engine read, `promote status` (a read of
6
+ * a copy, without --wake), whose queue_state gives every stage as queue-state/v1, and from the
7
+ * engine's built-in policy and management for each stage (queue_model/builtin.json). Nothing here
8
+ * words a state of its own: the shared page does.
9
+ *
10
+ * The read runs in a child process and is kept QUEUES_KEEP_MS from when it finished, one read at a
11
+ * time, later requests joining it. A failed read is not kept, so the next request reads again.
12
+ */
13
+ /** One engine run: its exit code and output. */
14
+ export type QueuesRun = (command: {
15
+ script: string;
16
+ args: string[];
17
+ cwd: string;
18
+ timeout_ms: number;
19
+ }) => Promise<{
20
+ code: number;
21
+ stdout: string;
22
+ stderr: string;
23
+ }>;
24
+ export type QueuesInput = {
25
+ /** The checkout whose engine runs, and the main checkout whose queues it reads. */
26
+ engine: string;
27
+ repo: string;
28
+ run?: QueuesRun;
29
+ /** Epoch ms; tests stand it in. */
30
+ now?: () => number;
31
+ /** Where a failure's detail goes: the viewer's terminal. */
32
+ log?: (line: string) => void;
33
+ };
34
+ export type AppQueues = {
35
+ list: () => Promise<AppContractAnswer>;
36
+ queue: (stage: string) => Promise<AppContractAnswer>;
37
+ /** Whether the engine gives queue-state/v1 and the built-in policies; false answers view_outdated. */
38
+ current: boolean;
39
+ };
40
+ export declare const QUEUES_KEEP_MS = 15000;
41
+ export declare const QUEUES_OUTDATED = "This viewer's engine has no queue-state reads yet; update the main checkout and restart sdlc viewer.";
42
+ type Json = Record<string, unknown>;
43
+ /**
44
+ * What a waiting Main entry waits on, as its Note: 'Waits on <thread>: both change <items>', then its
45
+ * own join note. promote names the nearest entry ahead it depends on and the files, migrations or
46
+ * resources both change.
47
+ */
48
+ export declare function waitsOnLine(waits_for: Json): string | null;
49
+ /**
50
+ * The Queues page for the repository sdlc viewer runs in, read by the engine its other panels run:
51
+ * a SoftwareDLC checkout's own, else the packaged one, as the Worktrees page finds it. Null outside
52
+ * a Git repository or with no engine, where the page answers engine_missing.
53
+ */
54
+ export declare function queuesProvider(cwd: string, { packaged }?: {
55
+ packaged?: () => string | null;
56
+ }): AppQueues | null;
57
+ export declare function appQueues(input: QueuesInput): AppQueues;
58
+ export {};
59
+ //# sourceMappingURL=app-queues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-queues.d.ts","sourceRoot":"","sources":["../../src/local/app-queues.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE;;;;;;;;;;GAUG;AAEH,gDAAgD;AAChD,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC;IAChH,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG;IACxB,mFAAmF;IACnF,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,mCAAmC;IACnC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,4DAA4D;IAC5D,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACvC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACrD,sGAAsG;IACtG,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,cAAc,QAAS,CAAC;AAkCrC,eAAO,MAAM,eAAe,yGAC4E,CAAC;AASzG,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAqCpC;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAU1D;AAqDD;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,EAAE,QAA0B,EAAE,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;CAAO,GACtE,SAAS,GAAG,IAAI,CAOlB;AAYD,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CA6JvD"}
@@ -0,0 +1,323 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { readFileSync } from 'node:fs';
3
+ import { join, resolve } from 'node:path';
4
+ import { engineLayout, locateCheckout, packagedEngine, viewCodeRoot } from '../checkout.js';
5
+ import { VIEW_PACKAGE } from '../view-seam.js';
6
+ export const QUEUES_KEEP_MS = 15_000;
7
+ const READ_TIMEOUT_MS = 120_000;
8
+ const STAGES = ['main', 'staging', 'publish', 'accept'];
9
+ // Each stage's name, purpose and second line, in this checkout's words (frame 661a64e7).
10
+ const STAGE_COPY = {
11
+ main: {
12
+ name: 'Main',
13
+ purpose: "Lands this checkout's finished work on local main. Independent entries run side by side; only one lands at a time.",
14
+ binding: { kind: 'label', label: 'Lands on local main' },
15
+ layer: { kind: 'implement' }
16
+ },
17
+ staging: {
18
+ name: 'Staging',
19
+ purpose: "Deploys local main to hosted staging, one turn at a time; a deploy carries every entry waiting to deploy.",
20
+ binding: null,
21
+ layer: { kind: 'release', promotes_to: 'staging' }
22
+ },
23
+ // Publish and Accept ride and hold turns as Staging does: Release's rows, with nowhere to promote to.
24
+ publish: {
25
+ name: 'Publish',
26
+ purpose: "Publishes the local coordinator's graph to the hosted project, one turn at a time.",
27
+ binding: null,
28
+ layer: { kind: 'release' }
29
+ },
30
+ accept: {
31
+ name: 'Accept',
32
+ purpose: 'Accepts the published graph proposal on the hosted project, one turn at a time.',
33
+ binding: null,
34
+ layer: { kind: 'release' }
35
+ }
36
+ };
37
+ export const QUEUES_OUTDATED = "This viewer's engine has no queue-state reads yet; update the main checkout and restart sdlc viewer.";
38
+ const TERMINAL = 'see the sdlc viewer terminal';
39
+ // A registry another command holds: SQLite's 'database is locked' or 'database is busy', which
40
+ // promote's own locked() keeps retrying and then reports. Hosted's errors are never matched.
41
+ const BUSY = /\b(?:database|registry) is (?:locked|busy)\b/;
42
+ /** A live stage hosted could not read: never a busy registry, whatever its text says. */
43
+ class LiveReadError extends Error {
44
+ }
45
+ const record = (value) => value && typeof value === 'object' && !Array.isArray(value) ? value : {};
46
+ const list = (value) => (Array.isArray(value) ? value : []);
47
+ const text = (value) => (typeof value === 'string' ? value : '');
48
+ function runPython({ script, args, cwd, timeout_ms }) {
49
+ return new Promise((done) => {
50
+ execFile('python3', [script, ...args], { cwd, encoding: 'utf8', timeout: timeout_ms, maxBuffer: 64 * 1024 * 1024 }, (error, stdout, stderr) => {
51
+ const code = error ? (typeof error.code === 'number' ? error.code : 1) : 0;
52
+ done({ code, stdout: String(stdout), stderr: String(stderr) || (error && !stdout ? error.message : '') });
53
+ });
54
+ });
55
+ }
56
+ /** promote's {ok, result} answer, from its last line when other output comes before it. */
57
+ function answerOf(out) {
58
+ const stdout = out.stdout.trim();
59
+ for (const candidate of [stdout, stdout.split('\n').pop() ?? '']) {
60
+ let parsed;
61
+ try {
62
+ parsed = record(JSON.parse(candidate));
63
+ }
64
+ catch {
65
+ continue;
66
+ }
67
+ if (parsed.ok !== true)
68
+ throw new Error(`promote status refused it: ${text(parsed.error)}`);
69
+ return record(parsed.result);
70
+ }
71
+ throw new Error(`promote status printed no answer: ${(out.stderr || out.stdout).trim().slice(-300)}`);
72
+ }
73
+ /**
74
+ * What a waiting Main entry waits on, as its Note: 'Waits on <thread>: both change <items>', then its
75
+ * own join note. promote names the nearest entry ahead it depends on and the files, migrations or
76
+ * resources both change.
77
+ */
78
+ export function waitsOnLine(waits_for) {
79
+ const thread = text(waits_for.thread);
80
+ if (!thread)
81
+ return null;
82
+ const items = list(waits_for.why)
83
+ .map(record)
84
+ .flatMap((why) => list(why.items).map(text))
85
+ .filter(Boolean);
86
+ const shown = items.slice(0, 3).join(', ') + (items.length > 3 ? ` and ${items.length - 3} more` : '');
87
+ const others = Number(waits_for.and_others_ahead) || 0;
88
+ return `Waits on ${thread}${shown ? `: both change ${shown}` : ''}${others ? ` (and ${others} more ahead)` : ''}`;
89
+ }
90
+ function withReasons(state, reasons) {
91
+ return {
92
+ ...state,
93
+ entries: list(state.entries)
94
+ .map(record)
95
+ .map((entry) => {
96
+ const line = entry.turn === 'running' ? null : waitsOnLine(reasons.get(text(entry.ref)) ?? {});
97
+ if (!line)
98
+ return entry;
99
+ return { ...entry, note: entry.note ? `${line} · ${text(entry.note)}` : line };
100
+ })
101
+ };
102
+ }
103
+ /**
104
+ * Every holder named: a holder with no thread (an execution the registry no longer ties to one) is
105
+ * named by its key, as an entry is, never as a missing organization member.
106
+ */
107
+ function named(state) {
108
+ const subject = (holder) => ({ kind: 'thread', id: text(holder) });
109
+ const fill = (part) => {
110
+ const found = part ? record(part) : null;
111
+ return found && !found.holder_subject ? { ...found, holder_subject: subject(found.holder) } : (part ?? null);
112
+ };
113
+ return { ...state, freeze: fill(state.freeze), manager: fill(state.manager), batch: fill(state.batch) };
114
+ }
115
+ /** The built-in policy and management of each stage, or null when the engine has none to read. */
116
+ function builtinOf(scripts) {
117
+ try {
118
+ const queues = record(record(JSON.parse(readFileSync(join(scripts, 'queue_model', 'builtin.json'), 'utf8'))).queues);
119
+ const found = {};
120
+ for (const stage of STAGES) {
121
+ const queue = record(queues[stage]);
122
+ if (!queue.policy || !queue.management)
123
+ return null;
124
+ found[stage] = { policy: record(queue.policy), management: record(queue.management) };
125
+ }
126
+ return found;
127
+ }
128
+ catch {
129
+ return null;
130
+ }
131
+ }
132
+ /** Whether promote status gives queue_state (the engine behind sdlc viewer may be older). */
133
+ function givesQueueState(scripts) {
134
+ try {
135
+ return readFileSync(join(scripts, 'promote.py'), 'utf8').includes('"queue_state"');
136
+ }
137
+ catch {
138
+ return false;
139
+ }
140
+ }
141
+ /**
142
+ * The Queues page for the repository sdlc viewer runs in, read by the engine its other panels run:
143
+ * a SoftwareDLC checkout's own, else the packaged one, as the Worktrees page finds it. Null outside
144
+ * a Git repository or with no engine, where the page answers engine_missing.
145
+ */
146
+ export function queuesProvider(cwd, { packaged = installedEngine } = {}) {
147
+ const checkout = locateCheckout(cwd);
148
+ if (!checkout)
149
+ return null;
150
+ const dir = viewCodeRoot(checkout);
151
+ if (!dir && process.env.SDLC_VIEW_ROOT)
152
+ return null;
153
+ const engine = dir ? resolve(dir, '..', '..') : packaged();
154
+ return engine ? appQueues({ engine, repo: checkout.main }) : null;
155
+ }
156
+ function installedEngine() {
157
+ const own = packagedEngine(import.meta.url);
158
+ if (own)
159
+ return own;
160
+ try {
161
+ return packagedEngine(import.meta.resolve(VIEW_PACKAGE));
162
+ }
163
+ catch {
164
+ return null;
165
+ }
166
+ }
167
+ export function appQueues(input) {
168
+ const run = input.run ?? runPython;
169
+ const now = input.now ?? Date.now;
170
+ const log = input.log ?? ((line) => process.stderr.write(`sdlc viewer: ${line}\n`));
171
+ const scripts = engineLayout(input.engine).scripts;
172
+ const builtin = builtinOf(scripts);
173
+ const current = builtin !== null && givesQueueState(scripts);
174
+ let kept;
175
+ let reading;
176
+ const readNow = async () => {
177
+ const out = await run({
178
+ script: join(scripts, 'promote'),
179
+ args: ['--repo', input.repo, 'status'],
180
+ cwd: input.repo,
181
+ timeout_ms: READ_TIMEOUT_MS
182
+ });
183
+ const answer = answerOf(out);
184
+ // A stage bound to a live queue gives hosted's queue-state/v1 in live_state, in place of the
185
+ // local registry's (promote live_status); one hosted could not read fails the read. While the
186
+ // local registry still has open entries for a newly bound stage, promote gives both hosted's
187
+ // state and that problem: those local entries hold the stage until they end, so the page draws
188
+ // the local state and the terminal says why.
189
+ const stores = record(answer.stores);
190
+ const live = record(answer.live_state);
191
+ const live_errors = record(answer.live_errors);
192
+ const states = Object.fromEntries(STAGES.map((stage) => {
193
+ const local = record(answer.queue_state)[stage];
194
+ if (stores[stage] !== 'live')
195
+ return [stage, local];
196
+ const problem = text(live_errors[stage]);
197
+ if (!live[stage])
198
+ throw new LiveReadError(`the live ${stage} queue could not be read: ${problem || 'no state'}`);
199
+ if (problem) {
200
+ log(`the ${stage} stage is drawn from the local registry: ${problem}`);
201
+ return [stage, local];
202
+ }
203
+ return [stage, live[stage]];
204
+ }));
205
+ // promote's own rows for Main carry what each waiting entry waits on, which queue-state/v1 leaves out.
206
+ const reasons = new Map(list(record(answer.queues).main)
207
+ .map(record)
208
+ .map((row) => [text(row.execution), record(row.waits_for)]));
209
+ const found = {};
210
+ for (const stage of STAGES) {
211
+ const state = record(states[stage]);
212
+ if (state.version !== 'queue-state/v1')
213
+ throw new Error(`promote status gave no queue-state/v1 for ${stage}`);
214
+ found[stage] = named(stage === 'main' ? withReasons(state, reasons) : state);
215
+ }
216
+ return found;
217
+ };
218
+ const read = () => {
219
+ if (kept && now() - kept.at < QUEUES_KEEP_MS)
220
+ return Promise.resolve(kept.states);
221
+ if (reading)
222
+ return reading;
223
+ const started = readNow()
224
+ .then((states) => {
225
+ kept = { at: now(), states };
226
+ return states;
227
+ })
228
+ .finally(() => {
229
+ reading = undefined;
230
+ });
231
+ reading = started;
232
+ return started;
233
+ };
234
+ const config = (stage) => {
235
+ const copy = STAGE_COPY[stage];
236
+ return {
237
+ id: stage,
238
+ name: copy.name,
239
+ purpose: copy.purpose,
240
+ binding: copy.binding,
241
+ layer: copy.layer,
242
+ policy: builtin[stage].policy,
243
+ management: builtin[stage].management
244
+ };
245
+ };
246
+ const summary = (stage, state) => {
247
+ const entries = list(state.entries).map(record);
248
+ const running = entries.filter((entry) => entry.turn === 'running' && entry.batching !== 'in_batch');
249
+ // The row names the turn holding the landing lock, else the first running.
250
+ const landing = running.find((entry) => state.landing && entry.ref === state.landing);
251
+ const first = landing ?? running[0];
252
+ const batch = state.batch ? record(state.batch) : null;
253
+ const members = batch ? list(batch.members).map(record) : [];
254
+ return {
255
+ ...config(stage),
256
+ waiting: entries.filter((entry) => entry.turn !== 'running').length,
257
+ turn: first
258
+ ? {
259
+ ref: first.ref,
260
+ subject: first.subject,
261
+ ...(typeof first.started_at === 'number' ? { started_at: first.started_at } : {}),
262
+ ...(typeof first.fixing_since === 'number' ? { fixing_since: first.fixing_since } : {}),
263
+ ...(first.hold === true ? { hold: true, ...(text(first.note) ? { note: text(first.note) } : {}) } : {}),
264
+ ...(landing ? { landing: true } : {})
265
+ }
266
+ : null,
267
+ freeze: state.freeze ?? null,
268
+ batch: batch
269
+ ? {
270
+ id: batch.id,
271
+ holder: batch.holder,
272
+ ...(batch.holder_subject ? { holder_subject: batch.holder_subject } : {}),
273
+ opened_at: batch.opened_at,
274
+ size: members.length,
275
+ remaining: members.filter((member) => member.outcome === null || member.outcome === undefined).length
276
+ }
277
+ : null,
278
+ running_count: running.length
279
+ };
280
+ };
281
+ const failed = (error) => {
282
+ const message = error instanceof Error ? error.message : String(error);
283
+ log(`queues read failed: ${message}`);
284
+ // promote keeps trying a registry another command holds, and gives up saying it is locked.
285
+ if (!(error instanceof LiveReadError) && BUSY.test(message)) {
286
+ return {
287
+ status: 503,
288
+ body: { reason: 'store_locked', error: 'The coordination registry is busy; read again in a moment.', retry: true, retry_after: 15 }
289
+ };
290
+ }
291
+ return { status: 500, body: { reason: 'engine_failed', error: `The queues could not be read; ${TERMINAL}.`, retry: true } };
292
+ };
293
+ const outdated = { status: 409, body: { reason: 'view_outdated', error: QUEUES_OUTDATED } };
294
+ return {
295
+ current,
296
+ list: async () => {
297
+ if (!current)
298
+ return outdated;
299
+ try {
300
+ const states = await read();
301
+ return { status: 200, body: { queues: STAGES.map((stage) => summary(stage, states[stage])) } };
302
+ }
303
+ catch (error) {
304
+ return failed(error);
305
+ }
306
+ },
307
+ queue: async (stage) => {
308
+ if (!STAGES.includes(stage)) {
309
+ return { status: 404, body: { reason: 'not_found', error: 'No queue here has that name.' } };
310
+ }
311
+ if (!current)
312
+ return outdated;
313
+ try {
314
+ const states = await read();
315
+ return { status: 200, body: { queue: config(stage), state: states[stage] } };
316
+ }
317
+ catch (error) {
318
+ return failed(error);
319
+ }
320
+ }
321
+ };
322
+ }
323
+ //# sourceMappingURL=app-queues.js.map