@prestack/thread 0.1.21 → 0.1.23

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 (138) hide show
  1. package/CHANGELOG.md +227 -0
  2. package/dist/core/attach.js +21 -0
  3. package/dist/core/descend.js +6 -3
  4. package/dist/core/generators/commit.js +55 -3
  5. package/dist/core/generators/dev.d.ts +1 -0
  6. package/dist/core/generators/dev.js +69 -0
  7. package/dist/derivation/generators/build.d.ts +3 -1
  8. package/dist/derivation/generators/build.js +104 -22
  9. package/dist/derivation/generators/release.js +74 -25
  10. package/dist/derivation/release.js +3 -3
  11. package/dist/integrations/cli.d.ts +0 -1
  12. package/dist/integrations/cli.js +69 -11
  13. package/dist/integrations/declared.d.ts +2 -0
  14. package/dist/integrations/declared.js +6 -1
  15. package/dist/integrations/pglite.js +13 -3
  16. package/dist/integrations/target.d.ts +3 -0
  17. package/dist/integrity/attach.js +1 -5
  18. package/dist/integrity/slopnators/sl_stale_path.js +10 -0
  19. package/dist/operations/access.js +3 -2
  20. package/dist/operations/capabilities.d.ts +2 -0
  21. package/dist/operations/capabilities.js +2 -0
  22. package/dist/operations/generators/capability.js +237 -24
  23. package/dist/operations/generators/compile.js +150 -50
  24. package/dist/operations/generators/seed.d.ts +3 -0
  25. package/dist/operations/generators/seed.js +25 -3
  26. package/dist/operations/nodes.d.ts +2 -2
  27. package/package.json +1 -1
  28. package/dist/core/actor.ts +0 -21
  29. package/dist/core/attach.ts +0 -613
  30. package/dist/core/chain.ts +0 -145
  31. package/dist/core/condition.ts +0 -227
  32. package/dist/core/descend.ts +0 -1185
  33. package/dist/core/errors/catalogue.ts +0 -314
  34. package/dist/core/errors/classes.ts +0 -51
  35. package/dist/core/errors/error.ts +0 -152
  36. package/dist/core/errors/namespaces.ts +0 -19
  37. package/dist/core/finding.ts +0 -37
  38. package/dist/core/generators/commit.ts +0 -157
  39. package/dist/core/init.ts +0 -222
  40. package/dist/core/invoked.ts +0 -52
  41. package/dist/core/round.ts +0 -74
  42. package/dist/core/rows.ts +0 -506
  43. package/dist/core/scope.ts +0 -20
  44. package/dist/core/thread.ts +0 -29
  45. package/dist/core/tree.ts +0 -90
  46. package/dist/core/types.ts +0 -351
  47. package/dist/derivation/attach.ts +0 -57
  48. package/dist/derivation/generators/build.ts +0 -371
  49. package/dist/derivation/generators/check.ts +0 -118
  50. package/dist/derivation/generators/determinism.ts +0 -145
  51. package/dist/derivation/generators/release.ts +0 -236
  52. package/dist/derivation/release.ts +0 -43
  53. package/dist/integrations/attach.ts +0 -187
  54. package/dist/integrations/cli.ts +0 -606
  55. package/dist/integrations/declared.ts +0 -34
  56. package/dist/integrations/disk.ts +0 -466
  57. package/dist/integrations/generators/read.ts +0 -127
  58. package/dist/integrations/generators/vault.ts +0 -210
  59. package/dist/integrations/https.ts +0 -216
  60. package/dist/integrations/pglite.ts +0 -206
  61. package/dist/integrations/secret.ts +0 -54
  62. package/dist/integrations/target.ts +0 -672
  63. package/dist/integrations/vault.ts +0 -148
  64. package/dist/integrity/attach.ts +0 -150
  65. package/dist/integrity/check-threads.ts +0 -166
  66. package/dist/integrity/constraint.ts +0 -1246
  67. package/dist/integrity/generators/compiler.ts +0 -138
  68. package/dist/integrity/generators/gate.ts +0 -227
  69. package/dist/integrity/generators/issues.ts +0 -160
  70. package/dist/integrity/generators/publish.ts +0 -233
  71. package/dist/integrity/generators/trial.ts +0 -359
  72. package/dist/integrity/lint.ts +0 -214
  73. package/dist/integrity/lsp/bin.ts +0 -44
  74. package/dist/integrity/lsp/diagnostics.ts +0 -92
  75. package/dist/integrity/lsp/findings.ts +0 -63
  76. package/dist/integrity/lsp/lint.ts +0 -124
  77. package/dist/integrity/lsp/protocol.ts +0 -78
  78. package/dist/integrity/lsp/server.ts +0 -224
  79. package/dist/integrity/slopnator.ts +0 -324
  80. package/dist/integrity/slopnators/sl_broken_lineage.ts +0 -38
  81. package/dist/integrity/slopnators/sl_declared_elsewhere.ts +0 -60
  82. package/dist/integrity/slopnators/sl_derived_drift.ts +0 -101
  83. package/dist/integrity/slopnators/sl_door_in_a_node.ts +0 -250
  84. package/dist/integrity/slopnators/sl_hardcoded_style.ts +0 -55
  85. package/dist/integrity/slopnators/sl_inert_island.ts +0 -84
  86. package/dist/integrity/slopnators/sl_inert_slopnator.ts +0 -93
  87. package/dist/integrity/slopnators/sl_missing_row.ts +0 -140
  88. package/dist/integrity/slopnators/sl_no_barrel.ts +0 -48
  89. package/dist/integrity/slopnators/sl_no_child_process.ts +0 -100
  90. package/dist/integrity/slopnators/sl_no_comment.ts +0 -43
  91. package/dist/integrity/slopnators/sl_no_dispatch_bypass.ts +0 -276
  92. package/dist/integrity/slopnators/sl_no_import_cycle.ts +0 -66
  93. package/dist/integrity/slopnators/sl_no_such_command.ts +0 -81
  94. package/dist/integrity/slopnators/sl_only_takes_a_literal.ts +0 -63
  95. package/dist/integrity/slopnators/sl_outside_an_operation.ts +0 -25
  96. package/dist/integrity/slopnators/sl_screen_holds_only_declared.ts +0 -70
  97. package/dist/integrity/slopnators/sl_secret_literal.ts +0 -68
  98. package/dist/integrity/slopnators/sl_stale_path.ts +0 -178
  99. package/dist/integrity/slopnators/sl_twice_meant.ts +0 -57
  100. package/dist/integrity/slopnators/sl_twice_parented.ts +0 -82
  101. package/dist/integrity/slopnators/sl_undeclared_crossing.ts +0 -481
  102. package/dist/integrity/slopnators/sl_undeclared_destination.ts +0 -113
  103. package/dist/integrity/slopnators/sl_undeclared_element.ts +0 -44
  104. package/dist/integrity/slopnators/sl_undeclared_list.ts +0 -358
  105. package/dist/integrity/slopnators/sl_undeclared_node.ts +0 -75
  106. package/dist/integrity/slopnators/sl_undeclared_operation.ts +0 -257
  107. package/dist/integrity/slopnators/sl_undeclared_variant.ts +0 -152
  108. package/dist/integrity/slopnators/sl_undeclared_webhook.ts +0 -108
  109. package/dist/integrity/slopnators/sl_underived_route.ts +0 -72
  110. package/dist/integrity/slopnators/sl_undescribed.ts +0 -65
  111. package/dist/integrity/slopnators/sl_ungoverned_island.ts +0 -60
  112. package/dist/integrity/slopnators/sl_unlisted_program.ts +0 -46
  113. package/dist/integrity/slopnators/sl_unnamed_island.ts +0 -41
  114. package/dist/integrity/slopnators/sl_unpaired_member.ts +0 -139
  115. package/dist/integrity/slopnators/sl_unpaired_slopnator.ts +0 -71
  116. package/dist/integrity/slopnators/sl_unprefixed_member.ts +0 -110
  117. package/dist/integrity/slopnators/sl_unthreaded.ts +0 -421
  118. package/dist/integrity/slopnators/sl_untranslated_key.ts +0 -140
  119. package/dist/integrity/slopnators/sl_unvaulted_secret.ts +0 -132
  120. package/dist/integrity/slopnators/sl_unversioned.ts +0 -52
  121. package/dist/integrity/sweep.ts +0 -395
  122. package/dist/knowledge/attach.ts +0 -327
  123. package/dist/knowledge/generators/docsgen.ts +0 -186
  124. package/dist/knowledge/generators/glossary.ts +0 -73
  125. package/dist/knowledge/glossary.ts +0 -6
  126. package/dist/operations/access.ts +0 -131
  127. package/dist/operations/attach.ts +0 -408
  128. package/dist/operations/capabilities.ts +0 -88
  129. package/dist/operations/dispatch.ts +0 -294
  130. package/dist/operations/error-results.ts +0 -31
  131. package/dist/operations/generators/capability.ts +0 -1054
  132. package/dist/operations/generators/compile.ts +0 -701
  133. package/dist/operations/generators/permits.ts +0 -229
  134. package/dist/operations/generators/seed.ts +0 -359
  135. package/dist/operations/generators/trial.ts +0 -666
  136. package/dist/operations/nodes.ts +0 -53
  137. package/dist/operations/operations.ts +0 -91
  138. package/dist/operations/result.ts +0 -28
@@ -50,6 +50,11 @@ export function builtFrom(row, known) {
50
50
  const found = (row.requires ?? []).filter((one) => known.has(one));
51
51
  return found.length === 1 ? found[0] : undefined;
52
52
  }
53
+ export const HOLDING = {
54
+ nd_repeat: () => '1',
55
+ nd_branch: (first) => `async () => ${quoted(first)}`,
56
+ };
57
+ export const stepsOf = (one) => [...one.nodes, ...[...one.within.values()].flat()];
53
58
  const reaches = (pass, one) => pass.stated.has(one) && !under(pass, one, NODES_ID);
54
59
  const waiting = (held) => held !== undefined && ts.isNumericLiteral(held) ? Number(held.text.replace(/_/g, '')) : undefined;
55
60
  export function operations(pass, known) {
@@ -64,6 +69,7 @@ export function operations(pass, known) {
64
69
  nodes: [],
65
70
  takes: [],
66
71
  body: undefined,
72
+ within: new Map(),
67
73
  wants: new Set(stated?.takes ?? []),
68
74
  requires: asked.filter((one) => reaches(pass, one)),
69
75
  stray: asked.filter((one) => !reaches(pass, one)),
@@ -72,8 +78,17 @@ export function operations(pass, known) {
72
78
  found.set(id, made);
73
79
  return made;
74
80
  };
81
+ const steps = new Map();
75
82
  for (const [at, threadings] of pass.threaded) {
76
83
  for (const one of threadings) {
84
+ const holder = steps.get(one.by);
85
+ if (holder !== undefined && one.list === 'seeds') {
86
+ const within = held(holder).within;
87
+ within.set(one.by, [...(within.get(one.by) ?? []), one.row]);
88
+ if (one.row.id !== undefined)
89
+ steps.set(one.row.id, holder);
90
+ continue;
91
+ }
77
92
  if (!isOperation(pass, one.by))
78
93
  continue;
79
94
  if (one.list === 'derives' && one.row.by === COMPILES)
@@ -82,8 +97,11 @@ export function operations(pass, known) {
82
97
  const mine = held(one.by);
83
98
  if (mine.wants.has(one.row.id ?? ''))
84
99
  mine.takes.push(one.row);
85
- else
100
+ else {
86
101
  mine.nodes.push(one.row);
102
+ if (one.row.id !== undefined)
103
+ steps.set(one.row.id, one.by);
104
+ }
87
105
  }
88
106
  }
89
107
  }
@@ -166,14 +184,18 @@ function planned(bodies) {
166
184
  for (const row of one.takes)
167
185
  if (row.at !== undefined)
168
186
  found.push({ at: row.at, derived: false, text: takesFile(row.at) });
169
- for (const row of one.nodes) {
187
+ for (const row of stepsOf(one)) {
170
188
  const from = builtFrom(row, known);
171
189
  const takes = one.takes[0]?.at;
172
190
  if (row.at === undefined || from === undefined || takes === undefined)
173
191
  continue;
174
192
  const path = resolve(ROOT, row.at);
175
193
  const held = existsSync(path) ? readFileSync(path, 'utf8') : undefined;
176
- const block = bodies.get(row.at) ?? (held === undefined ? undefined : blockIn(held));
194
+ const first = one.within.get(String(row.id))?.[0]?.id;
195
+ const fresh = first === undefined ? undefined : HOLDING[from]?.(first);
196
+ const written = held === undefined ? undefined : blockIn(held);
197
+ const untouched = held === undefined || written === scaffold(from, String(row.id));
198
+ const block = bodies.get(row.at) ?? (fresh !== undefined && untouched ? fresh : written);
177
199
  if (held !== undefined && block === undefined) {
178
200
  found.push({
179
201
  at: row.at,
@@ -14,7 +14,7 @@ export declare const nd_read: <I, R extends string = never>(block: (opened: Read
14
14
  export declare const nd_action: <I, R extends string = never>(block: (opened: Opened<R>, held: Held<I>) => Promise<unknown>) => {
15
15
  type: 'nd_action';
16
16
  };
17
- export declare const nd_branch: <I, R extends string = never>(choose: (opened: Reads<Opened<R>>, held: Held<I>) => Promise<string>, ways: Readonly<Record<string, (opened: Opened<R>, held: Held<I>) => Promise<unknown>>>) => {
17
+ export declare const nd_branch: <I, R extends string = never>(choose: (opened: Reads<Opened<R>>, held: Held<I>) => Promise<string>, ways?: Readonly<Record<string, (opened: Opened<R>, held: Held<I>) => Promise<unknown>>>) => {
18
18
  type: 'nd_branch';
19
19
  };
20
20
  export declare const nd_each: <I, R extends string = never>(over: (held: Held<I>) => readonly unknown[], block: (item: unknown, opened: Opened<R>, held: Held<I>) => Promise<unknown>) => {
@@ -23,7 +23,7 @@ export declare const nd_each: <I, R extends string = never>(over: (held: Held<I>
23
23
  export declare const nd_parallel: <I, R extends string = never>(blocks: readonly ((opened: Opened<R>, held: Held<I>) => Promise<unknown>)[]) => {
24
24
  type: 'nd_parallel';
25
25
  };
26
- export declare const nd_repeat: <I, R extends string = never>(ceiling: number, block: (pass: number, carried: unknown, opened: Opened<R>, held: Held<I>) => Promise<{
26
+ export declare const nd_repeat: <I, R extends string = never>(ceiling: number, block?: (pass: number, carried: unknown, opened: Opened<R>, held: Held<I>) => Promise<{
27
27
  readonly done: boolean;
28
28
  readonly value: unknown;
29
29
  }>) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prestack/thread",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -1,21 +0,0 @@
1
- export type Env = 'sandbox' | 'production'
2
-
3
- export const ENVIRONMENT = [
4
- ['run', 'x-request-id', 'crypto.randomUUID()'],
5
- ['address', 'x-forwarded-for', null],
6
- ['device', 'user-agent', null],
7
- ['replay', 'idempotency-key', null],
8
- ['moment', null, 'new Date().toISOString()'],
9
- ] as const
10
-
11
- export type Environment = { readonly [K in (typeof ENVIRONMENT)[number][0]]?: string }
12
-
13
- export type Actor = Environment & {
14
- readonly id: string | null
15
- readonly roles: readonly string[]
16
- readonly entitlements: readonly string[]
17
- }
18
-
19
- export const PUBLIC_ROLE = 'role_public'
20
-
21
- export const ANONYMOUS: Actor = { id: null, roles: [PUBLIC_ROLE], entitlements: [] }