@inixiative/foundry-core 0.5.4 → 0.5.5
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/package.json +1 -1
- package/src/feedback/experiment-gate.ts +16 -4
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* whose `<design>.review.md` says `verdict: go` for this exact design (`design-sha256:` of its
|
|
6
6
|
* bytes). A tiny test runs without one. When a `<design>.decisions.md` companion sits beside the
|
|
7
7
|
* design (run pins and answers that are filled after review, so the design's hash stays fixed), the
|
|
8
|
-
* run is refused while it still
|
|
8
|
+
* run is refused while it still holds a TBD value outside its `## Log`, and its path and hash are
|
|
9
|
+
* recorded too.
|
|
9
10
|
*/
|
|
10
11
|
import { createHash } from 'node:crypto';
|
|
11
12
|
import { existsSync, readFileSync } from 'node:fs';
|
|
@@ -39,6 +40,19 @@ export const decisionsPathOf = (design: string) => design.replace(/\.md$/, '.dec
|
|
|
39
40
|
|
|
40
41
|
const sha256 = (path: string) => createHash('sha256').update(readFileSync(path)).digest('hex');
|
|
41
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Line numbers of a decisions companion that still hold a `TBD` value. The `## Log` section is
|
|
45
|
+
* history and is skipped, and the token quoted alone in backticks is a mention of it, not a value.
|
|
46
|
+
*/
|
|
47
|
+
export const openDecisionLines = (text: string): number[] => {
|
|
48
|
+
let inLog = false;
|
|
49
|
+
return text.split('\n').flatMap((line, i) => {
|
|
50
|
+
const heading = /^(#{1,6})\s+(.+?)\s*$/.exec(line);
|
|
51
|
+
if (heading) inLog = heading[1] === '##' ? /^log$/i.test(heading[2] ?? '') : inLog;
|
|
52
|
+
return !inLog && /\bTBD\b/.test(line.replaceAll('`TBD`', '')) ? [i + 1] : [];
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
42
56
|
/** Why the design may not run wide; empty when it may. */
|
|
43
57
|
export const experimentProblems = (designPath: string): string[] => {
|
|
44
58
|
const design = resolve(designPath);
|
|
@@ -65,9 +79,7 @@ export const experimentProblems = (designPath: string): string[] => {
|
|
|
65
79
|
if (text.includes('<fill')) problems.push('unfilled <fill: …> placeholders remain');
|
|
66
80
|
const decisions = decisionsPathOf(design);
|
|
67
81
|
if (existsSync(decisions)) {
|
|
68
|
-
const open = readFileSync(decisions, 'utf8')
|
|
69
|
-
.split('\n')
|
|
70
|
-
.flatMap((line, i) => (/\bTBD\b/.test(line) ? [i + 1] : []));
|
|
82
|
+
const open = openDecisionLines(readFileSync(decisions, 'utf8'));
|
|
71
83
|
if (open.length)
|
|
72
84
|
problems.push(
|
|
73
85
|
`${decisions} still says TBD (line${open.length > 1 ? 's' : ''} ${open.join(', ')})`,
|