bareloop 0.47.1 → 0.49.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 +56 -0
- package/README.md +16 -9
- package/bareloop.context.md +70 -46
- package/bin/bareloop.mjs +2 -0
- package/package.json +3 -3
- package/src/bundle.js +36 -9
- package/src/bundleref.js +103 -0
- package/src/bundlerun.js +134 -17
- package/src/cli.js +138 -144
- package/src/config.js +1 -1
- package/src/draftspend.js +88 -34
- package/src/facts.js +1 -1
- package/src/interviewrun.js +11 -11
- package/src/invoke.js +3 -2
- package/src/launcher.js +122 -12
- package/src/learn.js +34 -20
- package/src/learnstore.js +30 -14
- package/src/pagedropwords.js +1 -0
- package/src/pagedry.js +77 -6
- package/src/pagemap.js +17 -3
- package/src/pagerules.js +2 -1
- package/src/panel/authorsession.js +7 -13
- package/src/panel/index.html +30 -7
- package/src/panel/runroutes.js +28 -14
- package/src/panel/server.js +69 -118
- package/src/prompts.js +50 -0
- package/src/reuse.js +1 -1
- package/src/runexport.js +162 -0
- package/src/runfiles.js +65 -0
- package/src/runlist.js +72 -0
- package/src/userrun.js +17 -13
- package/types/bundle.d.ts +16 -0
- package/types/bundleref.d.ts +63 -0
- package/types/bundlerun.d.ts +10 -3
- package/types/cli.d.ts +2 -1
- package/types/draftspend.d.ts +7 -23
- package/types/launcher.d.ts +67 -2
- package/types/learn.d.ts +29 -15
- package/types/learnstore.d.ts +31 -10
- package/types/pagedry.d.ts +26 -0
- package/types/pagemap.d.ts +1 -0
- package/types/panel/server.d.ts +7 -3
- package/types/prompts.d.ts +21 -0
- package/types/reuse.d.ts +3 -0
- package/types/runexport.d.ts +58 -0
- package/types/runfiles.d.ts +40 -0
- package/types/runlist.d.ts +55 -0
package/src/pagedry.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// uses - no copy of its logic here. A fact that reads no result line is dropped as `reads-no-result` and shows under Not checked.
|
|
5
5
|
// No limits, no counts, no pass bar: only "can it read". Async (gradeStep is), so it sits beside applyPageRules, not inside it: the caller is
|
|
6
6
|
// src/pagemap.js `runPageMap`. No I/O, no clock, no model.
|
|
7
|
+
// TIME DRY READ (docs/logs/time-dryread-poc-PREREG.md, F236/F237): the same "can it read" for TIME facts - `dryReadTimes` below.
|
|
7
8
|
|
|
8
9
|
import { createHash } from 'node:crypto';
|
|
9
10
|
import { gradeStep } from './rubricstep.js';
|
|
@@ -17,6 +18,23 @@ const AFTER_LABEL = new RegExp(`^\\s*(?:[$€£]\\s*)?(${NUM})`);
|
|
|
17
18
|
/** the label every dry-read claim is made under (the checker only needs one name; the fact's own is not read) */
|
|
18
19
|
const CLAIM = 'price';
|
|
19
20
|
const SOURCE = 'page';
|
|
21
|
+
const CLAIM_TIME = 'time';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* How many of `lines` the run's real checker reads green as an honest claim of `fact`: each line is graded alone by `gradeStep` (quote = the line,
|
|
25
|
+
* the claim named `claim` carrying the line's value). The one grading call money and time dry reads share.
|
|
26
|
+
* @param {string} text the frozen page text @param {string} sha its sha256 @param {object} fact the signed fact @param {string} claim the claim name inside `fact`
|
|
27
|
+
* @param {{quote: string, value: string}[]} lines @returns {Promise<number>}
|
|
28
|
+
*/
|
|
29
|
+
async function greenLines(text, sha, fact, claim, lines) {
|
|
30
|
+
let n = 0;
|
|
31
|
+
for (const r of lines) {
|
|
32
|
+
const params = { step: 1, parts: [{ text: 'dry read', class: 'fact', source: SOURCE, covers: [1], facts: [fact] }] };
|
|
33
|
+
const g = await gradeStep({ params, bytes: JSON.stringify({ results: [{ quote: r.quote, values: { [claim]: r.value } }] }), outputBytes: null, inputs: { [SOURCE]: text } }, { [SOURCE]: sha });
|
|
34
|
+
if (g.verdict === 'green') n += 1;
|
|
35
|
+
}
|
|
36
|
+
return n;
|
|
37
|
+
}
|
|
20
38
|
|
|
21
39
|
/**
|
|
22
40
|
* The result lines of a kept money fact: with a label, every page line where a kept label is followed by a number (one sign between allowed);
|
|
@@ -73,12 +91,7 @@ export async function dryReadMoney(text, facts) {
|
|
|
73
91
|
if (k.shape !== 'money') { kept.push(k); continue; }
|
|
74
92
|
const fact = signedOf(k);
|
|
75
93
|
const lines = moneyResultLines(text, k);
|
|
76
|
-
|
|
77
|
-
for (const r of lines) {
|
|
78
|
-
const params = { step: 1, parts: [{ text: 'dry read', class: 'fact', source: SOURCE, covers: [1], facts: [fact] }] };
|
|
79
|
-
const g = await gradeStep({ params, bytes: JSON.stringify({ results: [{ quote: r.quote, values: { [CLAIM]: r.value } }] }), outputBytes: null, inputs: { [SOURCE]: text } }, { [SOURCE]: sha });
|
|
80
|
-
if (g.verdict === 'green') n += 1;
|
|
81
|
-
}
|
|
94
|
+
const n = await greenLines(text, sha, fact, CLAIM, lines);
|
|
82
95
|
reads[k.name] = n;
|
|
83
96
|
results[k.name] = lines.length;
|
|
84
97
|
if (n > 0) { kept.push(k); continue; }
|
|
@@ -122,3 +135,61 @@ export async function dryReadPhrases(text, facts) {
|
|
|
122
135
|
}
|
|
123
136
|
return { facts: kept, dropped, reads };
|
|
124
137
|
}
|
|
138
|
+
|
|
139
|
+
/** a clock time as the page writes it: H:MM or HH:MM, then an optional AM/PM (any case, a space between allowed) */
|
|
140
|
+
const CLOCK = /\d{1,2}:\d{2}(?:\s?[AaPp][Mm])?/;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* The candidate lines of a kept time fact: a LOOSE finder (it only collects). Every page line where a kept label word has a clock time anywhere
|
|
144
|
+
* after it; the value is that line's first time after the label. Whether the run's checker can read it is not decided here.
|
|
145
|
+
* @param {string} text @param {KeptFact} k @returns {{quote: string, value: string}[]}
|
|
146
|
+
*/
|
|
147
|
+
export function timeCandidateLines(text, k) {
|
|
148
|
+
const raw = text.split('\n');
|
|
149
|
+
const squashed = linesOf(text);
|
|
150
|
+
/** @type {{quote: string, value: string}[]} */
|
|
151
|
+
const out = [];
|
|
152
|
+
squashed.forEach((ln, i) => {
|
|
153
|
+
for (const w of k.words) {
|
|
154
|
+
for (let at = ln.indexOf(w); at !== -1; at = ln.indexOf(w, at + w.length)) {
|
|
155
|
+
const m = CLOCK.exec(ln.slice(at + w.length));
|
|
156
|
+
if (m) { out.push({ quote: raw[i].trim(), value: m[0] }); return; }
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* The same "can it read" for TIME facts (F236: the label "Departure time" sat on a page that writes "Departure time:", the colon right after it, so
|
|
165
|
+
* no time could ever be read after the label, and the fact was signed anyway). Each candidate line of a kept time fact is graded as an HONEST claim
|
|
166
|
+
* (quote = that line, value = its first time after the label) by the real `gradeStep`, signed like a run would sign it (name, shape, anchor = the
|
|
167
|
+
* primary label; no window, as dryReadMoney leaves the limits out). A fact with no green line is dropped whole as `reads-no-time`.
|
|
168
|
+
* No counts, no pass bar. A time fact with no label word has nothing to anchor a read to (a run could not sign it either), so it passes through untouched.
|
|
169
|
+
* Facts of other shapes pass through untouched. It catches an IMPOSSIBLE label only: a label that reads a WRONG time is kept (left to the person at Accept).
|
|
170
|
+
* @param {string} text the frozen page text @param {KeptFact[]} facts what the money dry read kept
|
|
171
|
+
* @returns {Promise<{facts: KeptFact[], dropped: Dropped[], reads: Record<string, number>, results: Record<string, number>}>}
|
|
172
|
+
* `reads` / `results` = candidate lines the checker read / found, per fact name (for tests and reports; no verdict derives from the numbers)
|
|
173
|
+
*/
|
|
174
|
+
export async function dryReadTimes(text, facts) {
|
|
175
|
+
const sha = createHash('sha256').update(text).digest('hex');
|
|
176
|
+
/** @type {KeptFact[]} */
|
|
177
|
+
const kept = [];
|
|
178
|
+
/** @type {Dropped[]} */
|
|
179
|
+
const dropped = [];
|
|
180
|
+
/** @type {Record<string, number>} */
|
|
181
|
+
const reads = {};
|
|
182
|
+
/** @type {Record<string, number>} */
|
|
183
|
+
const results = {};
|
|
184
|
+
for (const k of facts) {
|
|
185
|
+
if (k.shape !== 'time' || !k.words.length) { kept.push(k); continue; }
|
|
186
|
+
const fact = { name: CLAIM_TIME, shape: 'time', anchor: k.words[0] };
|
|
187
|
+
const lines = timeCandidateLines(text, k);
|
|
188
|
+
const n = await greenLines(text, sha, fact, CLAIM_TIME, lines);
|
|
189
|
+
reads[k.name] = n;
|
|
190
|
+
results[k.name] = lines.length;
|
|
191
|
+
if (n > 0) { kept.push(k); continue; }
|
|
192
|
+
dropped.push({ line: k.line, ...(k.forRule === undefined ? {} : { rule: k.forRule }), fact: k.name, other: k.words[0], reason: 'reads-no-time' });
|
|
193
|
+
}
|
|
194
|
+
return { facts: kept, dropped, reads, results };
|
|
195
|
+
}
|
package/src/pagemap.js
CHANGED
|
@@ -15,7 +15,7 @@ import { isOutputCutOff } from './authorflow.js';
|
|
|
15
15
|
import { AUTHOR_CALL_TIMEOUT_MS, AUTHOR_SCOUT_MAX_TOKENS, SURVEY_CAUSES } from './authorscout.js';
|
|
16
16
|
import { lineRules, boundInWords, wordsSaidOn } from './rubricstep.js';
|
|
17
17
|
import { applyPageRules, validReading } from './pagerules.js';
|
|
18
|
-
import { dryReadMoney, dryReadPhrases } from './pagedry.js';
|
|
18
|
+
import { dryReadMoney, dryReadTimes, dryReadPhrases } from './pagedry.js';
|
|
19
19
|
import { ruleWords } from './facts.js';
|
|
20
20
|
import { lookFactOf } from './inputlook.js';
|
|
21
21
|
|
|
@@ -167,10 +167,12 @@ export async function runPageMap({
|
|
|
167
167
|
const kept = applyPageRules(texts[label], mapping, jobLines);
|
|
168
168
|
// money build v2: "can it read" - a money fact whose forms read no result line of the page, by the run's own checker, is Not checked
|
|
169
169
|
const read = await dryReadMoney(texts[label], kept.facts);
|
|
170
|
+
// time dry read (F236/F237): a time fact whose label has no time the run's checker can read after it is Not checked
|
|
171
|
+
const tim = await dryReadTimes(texts[label], read.facts);
|
|
170
172
|
// hamr 3a: a phrase fact is read against the same result lines (only when the job keeps a money fact)
|
|
171
|
-
const phr = await dryReadPhrases(texts[label],
|
|
173
|
+
const phr = await dryReadPhrases(texts[label], tim.facts);
|
|
172
174
|
for (const f of phr.facts) facts.push(lookFactOf(f, label));
|
|
173
|
-
for (const d of [...kept.dropped, ...read.dropped, ...phr.dropped]) dropped.push({ ...d, source: label });
|
|
175
|
+
for (const d of [...kept.dropped, ...read.dropped, ...tim.dropped, ...phr.dropped]) dropped.push({ ...d, source: label });
|
|
174
176
|
maps.push({ source: label, facts: mapping.facts.length });
|
|
175
177
|
looks.push(label);
|
|
176
178
|
}
|
|
@@ -188,6 +190,18 @@ export const isDropIt = (text) => String(text ?? '').trim().replace(/\.$/, '').t
|
|
|
188
190
|
const AGREE_WORDS = ['agree', 'yes'];
|
|
189
191
|
/** @param {unknown} text @returns {boolean} */
|
|
190
192
|
export const isAgree = (text) => AGREE_WORDS.includes(String(text ?? '').trim().replace(/[.!]$/, '').toLowerCase());
|
|
193
|
+
/**
|
|
194
|
+
* F240: an answer that opens with an agree word IMMEDIATELY followed by a comma or a colon (spaces allowed only after it) and more text
|
|
195
|
+
* ("yes, check it as ...", "agree: the outbound flight") is the person's own reading with a courtesy word in front: the word and the
|
|
196
|
+
* comma/colon go, the rest stays word for word. No hyphen or dash of any kind and no bare space counts, so "yes-no questions only",
|
|
197
|
+
* "agree-ment on price", "yes - departs", "yes departs" and "yesterday, ..." are kept whole. A bare "yes"/"agree" (isAgree) and a text that
|
|
198
|
+
* only contains the word later are returned untouched.
|
|
199
|
+
* @param {string} text @returns {string}
|
|
200
|
+
*/
|
|
201
|
+
export const stripAgreeLead = (text) => {
|
|
202
|
+
const m = String(text ?? '').match(new RegExp(`^(?:${AGREE_WORDS.join('|')})[,:]\\s*(\\S[\\s\\S]*)$`, 'i'));
|
|
203
|
+
return m ? m[1].trim() : String(text ?? '');
|
|
204
|
+
};
|
|
191
205
|
|
|
192
206
|
/** @typedef {{line: number, rule: number, source: 'look', question: string, ask: 'reading'|'cant-check', ruleText: string, reading?: string}} LookAsk
|
|
193
207
|
* `reading` = the plain words an `agree` writes as a `~` rule (a reading ask only) */
|
package/src/pagerules.js
CHANGED
|
@@ -228,7 +228,8 @@ export function applyPageRules(text, mapping, jobLines) {
|
|
|
228
228
|
// form the AI listed in either box is pooled and moved to the box its own shape belongs to
|
|
229
229
|
const listedCurrencies = (Array.isArray(f.currency) ? f.currency : []).map(String);
|
|
230
230
|
// a currency SIGN listed in BOTH unit and currency is said once: the unit copy goes (fwd F71 drafts)
|
|
231
|
-
|
|
231
|
+
// bareguard 0.26: two units equal after whitespace normalization are one form, so trim + collapse here and the twins collapse in the pool
|
|
232
|
+
const listedUnits = (Array.isArray(f.unit) ? f.unit : []).map((u) => String(u).replace(/\s+/g, ' ').trim()).filter((u) => {
|
|
232
233
|
if (!(CURRENCY_SYMBOLS.includes(u) && listedCurrencies.includes(u))) return true;
|
|
233
234
|
drop(f, u, 'sign-twice');
|
|
234
235
|
return false;
|
|
@@ -53,10 +53,10 @@ import { closeJudges } from '../kinds.js';
|
|
|
53
53
|
import { RUBRIC_LANG } from '../authoring.js';
|
|
54
54
|
import { rubricGoal, reconcileRubricPlan, signedFactNames } from '../rubricstep.js';
|
|
55
55
|
import { redactSecrets } from '../validate.js';
|
|
56
|
-
import { isDropIt, isAgree } from '../pagemap.js';
|
|
56
|
+
import { isDropIt, isAgree, stripAgreeLead } from '../pagemap.js';
|
|
57
57
|
import { FIT_ABSENT_NOTE } from '../fitcheck.js';
|
|
58
58
|
import { tallyCalls } from '../text.js';
|
|
59
|
-
import {
|
|
59
|
+
import { appendDraftLog } from '../draftspend.js';
|
|
60
60
|
import { PLAIN_PROPOSAL_STOPS, proposalStopText, signingStopText, draftStopText, redsRecord, declarationRecord, calibrationSummary, tryRefusedText } from '../authorreadout.js';
|
|
61
61
|
import { runNpmCi, NPM_CI_LOCKS } from '../npminstall.js';
|
|
62
62
|
import {
|
|
@@ -648,10 +648,9 @@ export function createSession(card, deps = {}) {
|
|
|
648
648
|
state.cost = t.spendComplete ? `$${t.knownUsd.toFixed(4)}` : `≥$${t.knownUsd.toFixed(4)} (unpriced calls present)`;
|
|
649
649
|
state.draftSpentUsd = t.knownUsd;
|
|
650
650
|
state.draftSpendComplete = t.spendComplete;
|
|
651
|
-
// self-review 2026-10-05 (hamr's ruling A): the
|
|
652
|
-
//
|
|
651
|
+
// self-review 2026-10-05 (hamr's ruling A): the call reaches DISK as a log line after every metered call, and the money
|
|
652
|
+
// readers fold those lines with this same `tallyCalls`, so an abandoned / refused / restarted session's drafting spend still counts (src/draftspend.js)
|
|
653
653
|
const nowIso = new Date().toISOString();
|
|
654
|
-
draftStartedAt ??= nowIso;
|
|
655
654
|
// the same call, one line in the drafting LOG (the part a run's views show first): the step running right now,
|
|
656
655
|
// the call's label, the drafting model, its cost (null stays null: unpriced is never $0). One owner: this onCall.
|
|
657
656
|
const runningNo = state.steps.findLastIndex((/** @type {any} */ x) => x.status === 'running');
|
|
@@ -670,21 +669,14 @@ export function createSession(card, deps = {}) {
|
|
|
670
669
|
}
|
|
671
670
|
appendDraftLog(outDir, {
|
|
672
671
|
kind: 'call', no: callNo, step: state.steps[callNo]?.id ?? null, label: call.label, model: draftIdentity?.model ?? null,
|
|
672
|
+
provider: draftIdentity?.provider ?? null, baseUrl: draftIdentity?.baseUrl ?? null,
|
|
673
673
|
thinking: draftThinkingPlan === null ? null : draftThinkingPlan.mode, thinkingSupport: draftThinkingPlan === null ? null : draftThinkingPlan.support,
|
|
674
674
|
...(call.thinkingStatus === undefined ? {} : { thinkingStatus: call.thinkingStatus }),
|
|
675
675
|
// idea A core: the page-word map's scrubbed answer (src/pagemap.js) - unsigned, kept so a run can be replayed at $0
|
|
676
676
|
...(typeof call.raw === 'string' ? { raw: call.raw } : {}),
|
|
677
677
|
costUsd: call.costUsd ?? null, unpricedRounds: call.unpricedRounds ?? 0, at: nowIso,
|
|
678
678
|
});
|
|
679
|
-
try {
|
|
680
|
-
writeDraftSpend(outDir, {
|
|
681
|
-
sessionId: id, spentUsd: t.knownUsd, spendComplete: t.spendComplete, provider: draftIdentity?.provider ?? null,
|
|
682
|
-
baseUrl: draftIdentity?.baseUrl ?? null, model: draftIdentity?.model ?? null, startedAt: draftStartedAt, updatedAt: nowIso,
|
|
683
|
-
});
|
|
684
|
-
} catch { /* money already spent stays in memory for a signed run; a disk fault never stops the draft */ }
|
|
685
679
|
};
|
|
686
|
-
/** @type {string|null} */
|
|
687
|
-
let draftStartedAt = null;
|
|
688
680
|
/** what the drafting calls will carry for thinking — the tick's mode and bare-agent's support answer — set once the Model resolves; null before
|
|
689
681
|
* @type {ReturnType<typeof thinkingPlanFor>|null} */
|
|
690
682
|
let draftThinkingPlan = null;
|
|
@@ -1075,6 +1067,8 @@ export function createSession(card, deps = {}) {
|
|
|
1075
1067
|
// PRD v1.107 Part 5b: a code-forced look question about a `~` rule. A can't-check ask answered "drop it" adds NO rule; the caller puts that
|
|
1076
1068
|
// rule on the look's Not checked list. A reading ask answered "agree" adds the code's reading, in plain words, as the `~` rule (so the
|
|
1077
1069
|
// bound is now the person's own words); anything else typed is the person's own rule, word for word.
|
|
1070
|
+
// F240: "yes, check it as ..." is the person's own words minus the leading "yes,"
|
|
1071
|
+
if (q.source === 'look') text = stripAgreeLead(text);
|
|
1078
1072
|
if (q.source === 'look' && q.ask === 'reading' && typeof q.reading === 'string' && isAgree(text)) text = q.reading;
|
|
1079
1073
|
if (q.source === 'look' && q.ask === 'cant-check' && Number.isInteger(q.rule) && isDropIt(text)) { left.push({ line: q.line, rule: /** @type {number} */ (q.rule) }); continue; }
|
|
1080
1074
|
const line = jobLines.find((l) => l.n === q.line);
|
package/src/panel/index.html
CHANGED
|
@@ -292,6 +292,10 @@
|
|
|
292
292
|
.ended-row{display:flex;gap:10px;align-items:baseline;flex-wrap:wrap;margin-bottom:6px;}
|
|
293
293
|
.ended-label{color:var(--text-faint);font-size:11px;letter-spacing:0.08em;min-width:52px;}
|
|
294
294
|
.ended-text{flex:1 1 220px;min-width:0;overflow-wrap:anywhere;}
|
|
295
|
+
/* a NEXT with several instructions is one per line: label muted, instructions in a second column (the shape fwdloop copied, 2026-10-25) */
|
|
296
|
+
.next-rows{display:grid;grid-template-columns:max-content minmax(0,1fr);column-gap:10px;row-gap:2px;}
|
|
297
|
+
.next-label{color:var(--text-faint);}
|
|
298
|
+
.next-text{min-width:0;overflow-wrap:anywhere;}
|
|
295
299
|
.ended-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:8px;}
|
|
296
300
|
/* P5 item 4: Import (read only) — the folder browser, the imported rows, the view */
|
|
297
301
|
.import-box{border:1px dashed var(--border-strong);padding:10px;margin-bottom:10px;display:grid;gap:8px;}
|
|
@@ -1117,12 +1121,13 @@
|
|
|
1117
1121
|
});
|
|
1118
1122
|
}
|
|
1119
1123
|
|
|
1120
|
-
// ---- step map renderer (buildStepMapHTML below — ONE renderer, no second hand-authored map anywhere on this page) ----
|
|
1121
1124
|
// The one Audit fold arrow (fwdloop's): \u25B6 closed, \u25BC open, faint, never shrinking; the gap after it is CSS (smaller on a phone).
|
|
1122
|
-
function auditCaret(open){ return '<span class="audit-caret">' + (open ? "\u25BC" : "\u25B6") + '</span>'; }
|
|
1123
|
-
function escapeXml(s){
|
|
1125
|
+
function auditCaret(open){ return '<span class="audit-caret">' + (open ? "\u25BC" : "\u25B6") + '</span>'; }
|
|
1126
|
+
function escapeXml(s){
|
|
1124
1127
|
return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");
|
|
1125
1128
|
}
|
|
1129
|
+
|
|
1130
|
+
// ---- step map renderer (buildStepMapHTML below — ONE renderer, no second hand-authored map anywhere on this page) ----
|
|
1126
1131
|
// s.noNumber (F196): a synthetic placeholder box (e.g. "died during
|
|
1127
1132
|
// planning") is a LABEL, never a real step — it renders without the
|
|
1128
1133
|
// leading "<n> " step number a real step gets.
|
|
@@ -2484,6 +2489,12 @@ function escapeXml(s){
|
|
|
2484
2489
|
// RULED 2026-10-15 (aligned with fwdloop M9 am7): ONE block, the same shape every time: ENDED (a finished run), NEXT (a finished run), SCHEDULE
|
|
2485
2490
|
// (always: the schedule's words and a second line, or "By hand"). A schedule that started nothing turns the SCHEDULE row AND the frame red.
|
|
2486
2491
|
// The sentences are CODE-OWNED on the server (`endedFor`/`endedText` in src/panel/server.js, `detail.schedule` from src/schedulewords.js) — this only paints them.
|
|
2492
|
+
// NEXT: `e.next` is one string; `e.rows` ([label, instruction] pairs, from endedFor) is there only when it holds several instructions
|
|
2493
|
+
function nextRow(e){
|
|
2494
|
+
if(!Array.isArray(e.rows) || e.rows.length < 2) return summaryRow("NEXT", e.next, "ended-next", false);
|
|
2495
|
+
var grid = e.rows.map(function(r){ return '<span class="next-row" style="display:contents"><span class="next-label">' + escapeXml(r[0]) + '</span><span class="next-text">' + escapeXml(r[1]) + '</span></span>'; }).join("");
|
|
2496
|
+
return '<div class="ended-row"><span class="ended-label">NEXT</span><span class="ended-text next-rows" data-testid="ended-next">' + grid + '</span></div>';
|
|
2497
|
+
}
|
|
2487
2498
|
function renderEnded(detail){
|
|
2488
2499
|
var box = document.getElementById("ended-block");
|
|
2489
2500
|
var e = detail.ended;
|
|
@@ -2499,7 +2510,7 @@ function escapeXml(s){
|
|
|
2499
2510
|
var h = "";
|
|
2500
2511
|
if(e){
|
|
2501
2512
|
// text only: the ONE place for [Stop] / [Resume] / [Reuse workflow] is the Run tab's top action row (renderRunActions)
|
|
2502
|
-
h += summaryRow("ENDED", detail.endedText || e.reason, "ended-reason", false) +
|
|
2513
|
+
h += summaryRow("ENDED", detail.endedText || e.reason, "ended-reason", false) + nextRow(e);
|
|
2503
2514
|
}
|
|
2504
2515
|
if(sc){
|
|
2505
2516
|
var w = sc.words || {};
|
|
@@ -2872,7 +2883,11 @@ function escapeXml(s){
|
|
|
2872
2883
|
if(!box || !list) return;
|
|
2873
2884
|
var items = detail && Array.isArray(detail.learnings) ? detail.learnings : [];
|
|
2874
2885
|
list.innerHTML = "";
|
|
2875
|
-
var
|
|
2886
|
+
var errLine = detail && typeof detail.learningsError === "string" ? detail.learningsError : "";
|
|
2887
|
+
// only the error and nothing handed: the title says so (hamr 2026-10-24); with hints it stays "What the planner was told ..."
|
|
2888
|
+
var head = items.length === 0 && errLine ? "No lessons were given to the planner" : "What the planner was told from earlier runs";
|
|
2889
|
+
// header mark (hamr 2026-10-24): \u2713 when lessons were handed to the planner, \u2717 when the learnings file could not be read and nothing was handed (hints win if both ever exist)
|
|
2890
|
+
var mark = items.length === 0 && errLine ? "\u2717" : "\u2713";
|
|
2876
2891
|
items.forEach(function(it, gi){
|
|
2877
2892
|
var hints = Array.isArray(it.hints) ? it.hints : [];
|
|
2878
2893
|
var when = it.phase === "replan" ? "first replan" : "draft";
|
|
@@ -2927,7 +2942,7 @@ function escapeXml(s){
|
|
|
2927
2942
|
});
|
|
2928
2943
|
var label = items.length ? head + " \u00B7 " + first + (first === 1 ? " hint" : " hints") : head;
|
|
2929
2944
|
// arrow back (hamr 2026-10-24, latest wins over 2026-10-23): auditCaret (\u25BC open / \u25B6 closed) first, as the schedule header; then the same `[✓] word` state markup the schedule/step headers wear (stateDotHTML), then the plain-words title
|
|
2930
|
-
var paint = function(){ sum.innerHTML = auditCaret(sum.getAttribute("aria-expanded") === "true") + stateDotHTML(glyphClass(
|
|
2945
|
+
var paint = function(){ sum.innerHTML = auditCaret(sum.getAttribute("aria-expanded") === "true") + stateDotHTML(glyphClass(mark), "learnings", "audit-learnings-state") + " " + escapeXml(label); };
|
|
2931
2946
|
paint();
|
|
2932
2947
|
// ONE fold, same as the other Audit sections: the header button toggles the body (wired once)
|
|
2933
2948
|
sum.onclick = function(){
|
|
@@ -2937,7 +2952,15 @@ function escapeXml(s){
|
|
|
2937
2952
|
paint();
|
|
2938
2953
|
};
|
|
2939
2954
|
}
|
|
2940
|
-
|
|
2955
|
+
if(errLine){
|
|
2956
|
+
var en = document.createElement("div");
|
|
2957
|
+
en.className = "hint";
|
|
2958
|
+
en.style.cssText = "margin:6px 0;overflow-wrap:anywhere;";
|
|
2959
|
+
en.setAttribute("data-testid", "audit-learnings-error");
|
|
2960
|
+
en.textContent = errLine;
|
|
2961
|
+
list.appendChild(en);
|
|
2962
|
+
}
|
|
2963
|
+
box.hidden = items.length === 0 && !errLine;
|
|
2941
2964
|
}
|
|
2942
2965
|
|
|
2943
2966
|
// ONE spelling of a step's state: its dot + the bold state word — read by the Run tab's step cards AND the Audit tab's grouped rows
|
package/src/panel/runroutes.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import { spawn as realSpawn } from 'node:child_process';
|
|
15
15
|
import {
|
|
16
|
-
openSync, closeSync, writeFileSync, readFileSync, readdirSync,
|
|
16
|
+
openSync, closeSync, writeFileSync, readFileSync, readdirSync, appendFileSync, statSync,
|
|
17
17
|
} from 'node:fs';
|
|
18
18
|
import { dirname, join } from 'node:path';
|
|
19
19
|
import {
|
|
@@ -51,13 +51,33 @@ function nextRevisionName(dir) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* The
|
|
54
|
+
* The folder's ONE `run.log` for an Accept / Rerun / Pause / Resume child (records ruling 2026-10-24: one log per folder, not a
|
|
55
|
+
* new file per action). One header line says which action's words follow; `offset` is the byte after it, so {@link readLogTail}
|
|
56
|
+
* shows this action's own output and never an older action's.
|
|
57
|
+
* @param {string} dir the run's folder (beside its spec)
|
|
58
|
+
* @param {string} action accept | rerun | pause | resume
|
|
59
|
+
* @param {string} runid
|
|
60
|
+
* @returns {{logFile: string, fd: number|null, offset: number}}
|
|
61
|
+
*/
|
|
62
|
+
function openActionLog(dir, action, runid) {
|
|
63
|
+
const logFile = join(dir, 'run.log');
|
|
64
|
+
try {
|
|
65
|
+
appendFileSync(logFile, `== ${action} ${runid} at ${new Date().toISOString()} ==\n`);
|
|
66
|
+
const offset = statSync(logFile).size;
|
|
67
|
+
return { logFile, fd: openSync(logFile, 'a'), offset };
|
|
68
|
+
} catch { return { logFile, fd: null, offset: 0 }; }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The tail of the engine's own log — its refusal text, verbatim — read only from `offset` (this action's own lines).
|
|
55
73
|
* @param {string} file
|
|
74
|
+
* @param {number} [offset] byte to start from (0 = the whole file)
|
|
56
75
|
* @returns {string}
|
|
57
76
|
*/
|
|
58
|
-
function readLogTail(file) {
|
|
77
|
+
function readLogTail(file, offset = 0) {
|
|
59
78
|
try {
|
|
60
|
-
const
|
|
79
|
+
const buf = readFileSync(file);
|
|
80
|
+
const text = buf.subarray(offset).toString('utf8');
|
|
61
81
|
return text.slice(Math.max(0, text.length - LOG_TAIL_BYTES)).trim();
|
|
62
82
|
} catch { return ''; }
|
|
63
83
|
}
|
|
@@ -203,7 +223,6 @@ export function createRunRoutes(opts) {
|
|
|
203
223
|
}
|
|
204
224
|
const questionOf = (/** @type {string} */ n) => (signed !== null && opts.stageQuestionsOfSpec ? opts.stageQuestionsOfSpec(signed).get(n) ?? null : null);
|
|
205
225
|
const dir = dirname(ctx.specPath);
|
|
206
|
-
const logFile = join(dir, `${decide}-${runid}-${Date.now()}.log`);
|
|
207
226
|
const args = [
|
|
208
227
|
'--wait', 'systemd-inhibit', `--why=bareloop panel ${decide}`,
|
|
209
228
|
process.execPath, bareloopBin,
|
|
@@ -211,9 +230,7 @@ export function createRunRoutes(opts) {
|
|
|
211
230
|
// last, so no flag lookup in the engine can land on the person's words
|
|
212
231
|
...(decide === 'rerun' ? ['--text', text] : []),
|
|
213
232
|
];
|
|
214
|
-
|
|
215
|
-
let logFd = null;
|
|
216
|
-
try { logFd = openSync(logFile, 'a'); } catch { logFd = null; }
|
|
233
|
+
const { logFile, fd: logFd, offset: logFrom } = openActionLog(dir, decide, runid);
|
|
217
234
|
const child = spawnFn('setsid', args, { detached: true, stdio: ['ignore', logFd ?? 'ignore', logFd ?? 'ignore'], env: envNow() });
|
|
218
235
|
if (logFd !== null) { try { closeSync(logFd); } catch { /* the child holds its own copy */ } }
|
|
219
236
|
if (typeof child?.unref === 'function') child.unref();
|
|
@@ -230,7 +247,7 @@ export function createRunRoutes(opts) {
|
|
|
230
247
|
child.once('exit', (/** @type {number|null} */ code) => {
|
|
231
248
|
clearTimeout(timer);
|
|
232
249
|
if (code === 0) finish(200, { ok: true, ...answered, runid, log: logFile });
|
|
233
|
-
else finish(409, { ok: false, error: engineRefusalWords(readLogTail(logFile), decide, logFile, questionOf), log: logFile });
|
|
250
|
+
else finish(409, { ok: false, error: engineRefusalWords(readLogTail(logFile, logFrom), decide, logFile, questionOf), log: logFile });
|
|
234
251
|
});
|
|
235
252
|
child.once('error', (/** @type {Error} */ e) => {
|
|
236
253
|
clearTimeout(timer);
|
|
@@ -352,7 +369,6 @@ export function createRunRoutes(opts) {
|
|
|
352
369
|
writeFileSync(specPath, `${JSON.stringify(spec, null, 2)}\n`, { flag: 'wx' });
|
|
353
370
|
}
|
|
354
371
|
|
|
355
|
-
const logFile = join(dir, `resume-${m[1]}-${Date.now()}.log`);
|
|
356
372
|
const args = [
|
|
357
373
|
'--wait', 'systemd-inhibit', '--why=bareloop panel resume',
|
|
358
374
|
process.execPath, bareloopBin,
|
|
@@ -363,9 +379,7 @@ export function createRunRoutes(opts) {
|
|
|
363
379
|
// the drafting fold rides every leg of the chain (a leg that dropped it would widen the ceiling)
|
|
364
380
|
...(plan.draftSpentUsd !== null ? ['--draft-spent-usd', String(plan.draftSpentUsd), ...(plan.draftSpendComplete === false ? ['--draft-spend-incomplete'] : [])] : []),
|
|
365
381
|
];
|
|
366
|
-
|
|
367
|
-
let logFd = null;
|
|
368
|
-
try { logFd = openSync(logFile, 'a'); } catch { logFd = null; }
|
|
382
|
+
const { logFile, fd: logFd, offset: logFrom } = openActionLog(dir, 'resume', m[1]);
|
|
369
383
|
const child = spawnFn('setsid', args, {
|
|
370
384
|
detached: true, stdio: ['ignore', logFd ?? 'ignore', logFd ?? 'ignore'], env: envNow(),
|
|
371
385
|
});
|
|
@@ -389,7 +403,7 @@ export function createRunRoutes(opts) {
|
|
|
389
403
|
ok: true, runid: m[1], specHash, capsChanged: changed, log: logFile,
|
|
390
404
|
});
|
|
391
405
|
} else {
|
|
392
|
-
finish(409, { ok: false, error: engineRefusalWords(readLogTail(logFile), 'resume', logFile), log: logFile });
|
|
406
|
+
finish(409, { ok: false, error: engineRefusalWords(readLogTail(logFile, logFrom), 'resume', logFile), log: logFile });
|
|
393
407
|
}
|
|
394
408
|
});
|
|
395
409
|
child.once('error', (/** @type {Error} */ e) => {
|