pi-harness-runtime 1.1.463 → 1.1.464
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 +41 -0
- package/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/dist/decision-context.d.ts +12 -2
- package/packages/jev-judge/dist/decision-context.d.ts.map +1 -1
- package/packages/jev-judge/dist/decision-context.js +157 -35
- package/packages/jev-judge/dist/decision-context.js.map +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/jev-judge/src/decision-context.ts +181 -40
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/logging/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/tooling-preference/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/two-phase-review/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/write-review/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.1.464](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.448...v1.1.464) (2026-11-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **delegation:** a child is only a child when it really ran ([ac4e678](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ac4e6782d7d4bc4941e458425c8a9f38a51fc9d4))
|
|
11
|
+
* **delegation:** the scope of a request is measured before it is judged ([684b6a5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/684b6a55184f63d3be24c48dcecfb0b13410dc15))
|
|
12
|
+
* **honcho:** the memory service speaks the native MCP of Pi ([f9f740c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f9f740c12869bae4c4380afbe8c76e12388bb744))
|
|
13
|
+
* **jev:** the evaluation of a choice sees what the options mean ([f0c207e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f0c207e074701e6b7dab0965170ec39453d9d502))
|
|
14
|
+
* **jev:** the pending question carries the ask and the answer ([a792133](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a792133e517fb8c12d3363e98942f3af30270f27))
|
|
15
|
+
* **jev:** the pending question counts down to the decision ([d0cc171](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0cc171223986b2d32c670b6c1c74712fe0a4ad8))
|
|
16
|
+
* **keys:** the key files are repaired when their permissions are unsafe ([e9c2c26](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e9c2c26b287665b56ed749de269737e8403bb8af))
|
|
17
|
+
* **merge:** a manual run can leave the merge to the pull request event ([b3d1950](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b3d1950b5941c78ccd56951acdafd1d4afbe1bff))
|
|
18
|
+
* **phase:** the agent owns the todo list and the harness says so ([c489370](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c489370bd7926aece8cb1a77aa20ca2d2672f1fb))
|
|
19
|
+
* **review:** the review starts on its own when the implementation is done ([04f51f5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/04f51f599cd3222b6c74dd8fadb1373bd72d9bd7))
|
|
20
|
+
* **status:** the status line names the phase, the progress and the children ([0167bf3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/0167bf396a0b987c1d44f3b869351976a951dd65))
|
|
21
|
+
* **test:** the task waits for the final tier of the validation plan ([fa147db](https://github.com/ManotLuijiu/pi-harness-runtime/commit/fa147dbf7d50d56e6ea48c6d8fbb4fcb190caf8a))
|
|
22
|
+
* **validation:** a large job starts with a measured pilot ([425964b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/425964b04a3d4fa02adfabed47ff62c5ec2b9c28))
|
|
23
|
+
* **validation:** the size of a job is a fact, not a phrase ([8aa6c11](https://github.com/ManotLuijiu/pi-harness-runtime/commit/8aa6c119565d0f8412dc8aeafa6b295d47d3f093))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* **ci:** every run of a required check counts, and the worst one decides ([da9e0da](https://github.com/ManotLuijiu/pi-harness-runtime/commit/da9e0da6b0ca29cb320764fd5fc1b8a8dee8b1e0))
|
|
29
|
+
* **ci:** the newest attempt of a run decides, not the attempt that failed ([9d7adcc](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9d7adcc31cbacc517c3c1a9bcd3956be94c908ef))
|
|
30
|
+
* **hooks:** a tag is checked through the commit behind it ([c823e8e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c823e8e1f6973c62b5449a97c101759a4d5cbba5))
|
|
31
|
+
* **jev:** a session switch ends the wait of the old session ([ca03d39](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ca03d399c0d4a1b2dd428ac39836ab53c0e51ab6))
|
|
32
|
+
* **jev:** the alternatives of a question are parsed without a quadratic pattern ([63016a3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/63016a3f0488acb801990dd46770c00d382b5858))
|
|
33
|
+
* **jev:** the facts of an option survive the wording of the agent ([5a6250c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5a6250c07aa8d965bc6ae242cccbf519477598f8))
|
|
34
|
+
* **keys:** the key directory is audited as a tree ([081cc75](https://github.com/ManotLuijiu/pi-harness-runtime/commit/081cc75ac8ceff36b0d619c3f76371dc08459d3c))
|
|
35
|
+
* **merge:** the boolean input is read as a boolean ([971b716](https://github.com/ManotLuijiu/pi-harness-runtime/commit/971b7169a43db382dbdeb6bb9bab02ab56e0351c))
|
|
36
|
+
* **merge:** the manual job needs the right of the merge ([7ba685e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7ba685ec43d815f90aa35b742579e87e76c69209))
|
|
37
|
+
* **merge:** the merge of the pull request is the GraphQL mutation ([972bab4](https://github.com/ManotLuijiu/pi-harness-runtime/commit/972bab4b0f7faf1b0047f3bb767ef6db3de4b2fa))
|
|
38
|
+
* **merge:** the workflow merges the pull request the gates cleared ([d7639ec](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d7639ec9b83723510acb4a5c4e23d5d6167c3af6))
|
|
39
|
+
* **release:** a manual release keeps the version of its manifest ([122e661](https://github.com/ManotLuijiu/pi-harness-runtime/commit/122e661ea48cb8aff14c71dbd0221a4cf0ba4c8e))
|
|
40
|
+
* **release:** the alignment names the reason of a failure ([5814dd0](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5814dd0b780f5839cf8011ed0cbbbb31e7eb0418))
|
|
41
|
+
* **release:** the channels of the package name the release ([a7a273f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a7a273ffe8398e2b5b07ef1c321777de41792c6e))
|
|
42
|
+
* **release:** the release publishes and leaves the channels alone ([5871746](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5871746589c1281d855dbeb591b02419fa43f22e))
|
|
43
|
+
* **release:** the release pull request names the version of its branch ([a846e83](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a846e83e6de6e529f4bca05e869db0b5eebb37c5))
|
|
44
|
+
* **release:** the release scans the tree of the commit it publishes ([7d47a0b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7d47a0b5406480a1e1d3a52623a76aabd1e2d0ba))
|
|
45
|
+
|
|
5
46
|
### [1.1.463](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.448...v1.1.463) (2026-11-07)
|
|
6
47
|
|
|
7
48
|
|
package/package.json
CHANGED
|
@@ -77,13 +77,14 @@ export interface ChoiceDecisionContext {
|
|
|
77
77
|
truncated: boolean;
|
|
78
78
|
/** What the evaluation does not see. */
|
|
79
79
|
omittedInformation: string[];
|
|
80
|
-
/** Where the facts came from. */
|
|
80
|
+
/** Where the facts came from: the structure, the message, or both. */
|
|
81
81
|
derived: "structured" | "extracted" | "mixed";
|
|
82
82
|
/** Whether every option carries its meaning. */
|
|
83
83
|
complete: boolean;
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
/** The facts the agent supplied itself. They
|
|
86
|
+
/** The facts the agent supplied itself. They come first; the facts of the
|
|
87
|
+
* message are merged with them. */
|
|
87
88
|
export interface StructuredChoiceFacts {
|
|
88
89
|
/** The problem the choice is about. */
|
|
89
90
|
problem?: string;
|
|
@@ -135,6 +136,15 @@ export interface ExtractedOption {
|
|
|
135
136
|
found: boolean;
|
|
136
137
|
/** The line of the header the facts were found at, -1 when there was none. */
|
|
137
138
|
headerIndex: number;
|
|
139
|
+
/**
|
|
140
|
+
* Whether the description of the option states a restriction.
|
|
141
|
+
*
|
|
142
|
+
* The wording of the source for an option can carry the caveat of that
|
|
143
|
+
* option ("it must actually connect"). When another wording is supplied
|
|
144
|
+
* for the option, this tells the caller which list the source wording
|
|
145
|
+
* belongs to.
|
|
146
|
+
*/
|
|
147
|
+
descriptionConstraint: boolean;
|
|
138
148
|
}
|
|
139
149
|
/** What the extraction needs to know about one option. */
|
|
140
150
|
export interface OptionExtractionInput {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decision-context.d.ts","sourceRoot":"","sources":["../src/decision-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,6CAA6C;AAC7C,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,gEAAgE;AAChE,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,uDAAuD;AACvD,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,iEAAiE;AACjE,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAChD,yEAAyE;AACzE,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,+DAA+D;AAC/D,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAC7C,wDAAwD;AACxD,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,mEAAmE;AACnE,MAAM,WAAW,iBAAiB;IACjC,+DAA+D;IAC/D,EAAE,EAAE,MAAM,CAAC;IACX,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,gDAAgD;IAChD,WAAW,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,8CAA8C;AAC9C,MAAM,WAAW,qBAAqB;IACrC,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,2CAA2C;I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CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAS3D;AAgMD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,qBAAqB,GAC1B,eAAe,CAsKjB;AAoBD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACzC,KAAK,EAAE,kBAAkB,GACvB,qBAAqB,CA6UvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CACnC,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EAAE,GACnB,MAAM,CAUR;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAsC1E"}
|
|
@@ -225,6 +225,16 @@ function statesConstraint(paragraph) {
|
|
|
225
225
|
function mentionsAny(text, anchors) {
|
|
226
226
|
return anchors.some((anchor) => mentionsAnchor(text, anchor));
|
|
227
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* The offset of a line in the source message.
|
|
230
|
+
*/
|
|
231
|
+
function lineOffset(lines, index) {
|
|
232
|
+
let offset = 0;
|
|
233
|
+
for (let position = 0; position < index; position += 1) {
|
|
234
|
+
offset += lines[position].length + 1;
|
|
235
|
+
}
|
|
236
|
+
return offset;
|
|
237
|
+
}
|
|
228
238
|
/**
|
|
229
239
|
* Whether a paragraph is a fact of one option.
|
|
230
240
|
*
|
|
@@ -276,6 +286,7 @@ export function extractOptionFacts(input) {
|
|
|
276
286
|
constraints: [],
|
|
277
287
|
found: false,
|
|
278
288
|
headerIndex: -1,
|
|
289
|
+
descriptionConstraint: false,
|
|
279
290
|
};
|
|
280
291
|
if (headerCandidates.length === 0 || source.length === 0)
|
|
281
292
|
return empty;
|
|
@@ -284,11 +295,16 @@ export function extractOptionFacts(input) {
|
|
|
284
295
|
const paragraphs = splitParagraphs(source);
|
|
285
296
|
let description = "";
|
|
286
297
|
let region = [];
|
|
298
|
+
// The range of the section of the option in the source message.
|
|
299
|
+
let sectionRange = null;
|
|
300
|
+
// The paragraphs of the source that the section of the option covers.
|
|
301
|
+
const covered = new Set();
|
|
287
302
|
if (headerIndex >= 0) {
|
|
288
303
|
// The region of the option ends at the next option header, at the
|
|
289
304
|
// next heading of the message, or at the question itself.
|
|
290
305
|
const regionLines = [];
|
|
291
306
|
const questionMarker = question.trim().slice(0, 40);
|
|
307
|
+
let lastIndex = headerIndex;
|
|
292
308
|
for (let index = headerIndex; index < lines.length; index += 1) {
|
|
293
309
|
const line = lines[index];
|
|
294
310
|
if (index > headerIndex) {
|
|
@@ -301,7 +317,13 @@ export function extractOptionFacts(input) {
|
|
|
301
317
|
}
|
|
302
318
|
}
|
|
303
319
|
regionLines.push(line);
|
|
320
|
+
lastIndex = index;
|
|
304
321
|
}
|
|
322
|
+
sectionRange = {
|
|
323
|
+
start: lineOffset(lines, headerIndex),
|
|
324
|
+
end: lineOffset(lines, lastIndex) +
|
|
325
|
+
lines[lastIndex].length,
|
|
326
|
+
};
|
|
305
327
|
region = splitParagraphs(regionLines.join("\n"));
|
|
306
328
|
if (region.length > 0) {
|
|
307
329
|
const anchor = headerCandidates.find((candidate) => isOptionHeader(lines[headerIndex], candidate)) ?? headerCandidates[0];
|
|
@@ -311,22 +333,31 @@ export function extractOptionFacts(input) {
|
|
|
311
333
|
else {
|
|
312
334
|
// No header: the first paragraph that names the option and no other
|
|
313
335
|
// one carries its meaning.
|
|
314
|
-
const
|
|
315
|
-
const candidate =
|
|
336
|
+
const candidateIndex = paragraphs.findIndex((paragraph) => belongsToOption(paragraph.text, mentionAnchors, otherMentionAnchors));
|
|
337
|
+
const candidate = candidateIndex >= 0
|
|
338
|
+
? paragraphs[candidateIndex]
|
|
339
|
+
: undefined;
|
|
316
340
|
if (candidate) {
|
|
317
341
|
const anchor = mentionAnchors.find((token) => mentionsAnchor(candidate.text.slice(0, MENTION_WINDOW_CHARS), token)) ?? mentionAnchors[0];
|
|
318
342
|
description = stripMarkdown(stripLeadingAnchor(candidate.text, anchor));
|
|
319
|
-
|
|
343
|
+
covered.add(candidateIndex);
|
|
320
344
|
}
|
|
321
345
|
}
|
|
346
|
+
// The paragraphs that the section of the option covers: they belong to
|
|
347
|
+
// the option, and they are not looked at a second time.
|
|
348
|
+
if (sectionRange) {
|
|
349
|
+
paragraphs.forEach((paragraph, paragraphIndex) => {
|
|
350
|
+
const paragraphEnd = paragraph.start + paragraph.text.length;
|
|
351
|
+
if (paragraph.start < sectionRange.end &&
|
|
352
|
+
paragraphEnd > sectionRange.start) {
|
|
353
|
+
covered.add(paragraphIndex);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
}
|
|
322
357
|
const tradeoffs = [];
|
|
323
358
|
const constraints = [];
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
if (value.length === 0)
|
|
327
|
-
return;
|
|
328
|
-
if (!belongsToOption(value, mentionAnchors, otherMentionAnchors))
|
|
329
|
-
return;
|
|
359
|
+
/** Remember a fact, as a constraint when it states a restriction. */
|
|
360
|
+
const recordFact = (value) => {
|
|
330
361
|
if (statesConstraint(value)) {
|
|
331
362
|
if (!constraints.includes(value))
|
|
332
363
|
constraints.push(value);
|
|
@@ -335,17 +366,43 @@ export function extractOptionFacts(input) {
|
|
|
335
366
|
tradeoffs.push(value);
|
|
336
367
|
}
|
|
337
368
|
};
|
|
338
|
-
|
|
369
|
+
/**
|
|
370
|
+
* A fact of the section of the option belongs to it by position: the
|
|
371
|
+
* section writes about that option, and a paragraph that names it with
|
|
372
|
+
* a pronoun ("it must actually connect") is still about it. A paragraph
|
|
373
|
+
* that names another option belongs to that one.
|
|
374
|
+
*/
|
|
375
|
+
const addSectionFact = (text) => {
|
|
376
|
+
const value = stripMarkdown(text);
|
|
377
|
+
if (value.length === 0)
|
|
378
|
+
return;
|
|
379
|
+
if (mentionsAny(value.slice(0, MENTION_WINDOW_CHARS), otherMentionAnchors)) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
recordFact(value);
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* A fact from outside the section has to name the option, and it must
|
|
386
|
+
* not name another one: "Caveat for B: ..." is about B.
|
|
387
|
+
*/
|
|
388
|
+
const addNamedFact = (text) => {
|
|
389
|
+
const value = stripMarkdown(text);
|
|
390
|
+
if (value.length === 0)
|
|
391
|
+
return;
|
|
392
|
+
if (!belongsToOption(value, mentionAnchors, otherMentionAnchors))
|
|
393
|
+
return;
|
|
394
|
+
recordFact(value);
|
|
395
|
+
};
|
|
396
|
+
// The paragraphs of the section after the description.
|
|
339
397
|
for (const paragraph of region.slice(1)) {
|
|
340
|
-
|
|
398
|
+
addSectionFact(paragraph.text);
|
|
341
399
|
}
|
|
342
400
|
// A caveat that names the option belongs to the option, even when it
|
|
343
|
-
// stands outside the
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
if (paragraph.start <= regionStart)
|
|
401
|
+
// stands outside the section: "Caveat for B: ..." is about B.
|
|
402
|
+
for (const [paragraphIndex, paragraph] of paragraphs.entries()) {
|
|
403
|
+
if (covered.has(paragraphIndex))
|
|
347
404
|
continue;
|
|
348
|
-
|
|
405
|
+
addNamedFact(paragraph.text);
|
|
349
406
|
}
|
|
350
407
|
return {
|
|
351
408
|
description,
|
|
@@ -353,6 +410,7 @@ export function extractOptionFacts(input) {
|
|
|
353
410
|
constraints,
|
|
354
411
|
found: description.length > 0,
|
|
355
412
|
headerIndex,
|
|
413
|
+
descriptionConstraint: statesConstraint(description),
|
|
356
414
|
};
|
|
357
415
|
}
|
|
358
416
|
/**
|
|
@@ -401,7 +459,15 @@ export function buildChoiceDecisionContext(input) {
|
|
|
401
459
|
}
|
|
402
460
|
const source = input.contextText ?? "";
|
|
403
461
|
const primarySets = alternatives.map((alternative) => derivePrimaryAnchors(alternative));
|
|
404
|
-
const headerSets = alternatives.map((alternative) =>
|
|
462
|
+
const headerSets = alternatives.map((alternative, index) => {
|
|
463
|
+
// A token that is the primary label of another option belongs to
|
|
464
|
+
// that option and to no other: the header of "A+B" is not the header
|
|
465
|
+
// of the option "A", whatever the order of the alternatives is.
|
|
466
|
+
const otherPrimaries = primarySets
|
|
467
|
+
.flat()
|
|
468
|
+
.filter((token) => !primarySets[index]?.includes(token));
|
|
469
|
+
return deriveOptionAnchors(alternative).filter((token) => !otherPrimaries.includes(token));
|
|
470
|
+
});
|
|
405
471
|
// The mention anchors of every option: a part of a combination belongs
|
|
406
472
|
// to the option that names it and to no other.
|
|
407
473
|
const mentionSets = primarySets.map((primaries) => deriveMentionAnchors(primaries, primarySets
|
|
@@ -417,6 +483,7 @@ export function buildChoiceDecisionContext(input) {
|
|
|
417
483
|
const claimed = new Set();
|
|
418
484
|
let derivedFromStructured = 0;
|
|
419
485
|
let derivedFromMessage = 0;
|
|
486
|
+
let derivedFromBoth = 0;
|
|
420
487
|
let missingMeaning = false;
|
|
421
488
|
const readFacts = (values, fallback) => {
|
|
422
489
|
const list = Array.isArray(values)
|
|
@@ -430,6 +497,33 @@ export function buildChoiceDecisionContext(input) {
|
|
|
430
497
|
});
|
|
431
498
|
return { facts, cut: list.length > MAX_OPTION_FACTS };
|
|
432
499
|
};
|
|
500
|
+
/**
|
|
501
|
+
* The facts of an option: the supplied ones come first, the facts of the
|
|
502
|
+
* source follow. A fact that is in both lists is kept once.
|
|
503
|
+
*
|
|
504
|
+
* The result is undefined when the supplied facts are not a list: the
|
|
505
|
+
* facts of the source are then the only ones, and the caller reports
|
|
506
|
+
* the malformed facts itself.
|
|
507
|
+
*/
|
|
508
|
+
const mergeFacts = (supplied, sourceFacts) => {
|
|
509
|
+
if (!Array.isArray(supplied))
|
|
510
|
+
return undefined;
|
|
511
|
+
const merged = [];
|
|
512
|
+
for (const value of supplied) {
|
|
513
|
+
if (typeof value !== "string")
|
|
514
|
+
continue;
|
|
515
|
+
const trimmed = value.trim();
|
|
516
|
+
if (trimmed.length === 0)
|
|
517
|
+
continue;
|
|
518
|
+
if (!merged.includes(trimmed))
|
|
519
|
+
merged.push(trimmed);
|
|
520
|
+
}
|
|
521
|
+
for (const fact of sourceFacts) {
|
|
522
|
+
if (!merged.includes(fact))
|
|
523
|
+
merged.push(fact);
|
|
524
|
+
}
|
|
525
|
+
return merged;
|
|
526
|
+
};
|
|
433
527
|
for (const [index, alternative] of alternatives.entries()) {
|
|
434
528
|
const id = `option_${index + 1}`;
|
|
435
529
|
const label = alternative.trim();
|
|
@@ -457,29 +551,51 @@ export function buildChoiceDecisionContext(input) {
|
|
|
457
551
|
if (supplied && supplied.description !== undefined && !suppliedDescription) {
|
|
458
552
|
uncertainties.push(`${id} (${label}): the supplied description is empty or malformed, the message was used instead`);
|
|
459
553
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
554
|
+
// The extraction always runs. A supplied description is the meaning
|
|
555
|
+
// of the option, not a replacement for the facts of the message: a
|
|
556
|
+
// caveat that only the message carries has to survive it.
|
|
557
|
+
const extracted = extractOptionFacts({
|
|
558
|
+
source,
|
|
559
|
+
headerCandidates,
|
|
560
|
+
mentionAnchors,
|
|
561
|
+
otherHeaderCandidates,
|
|
562
|
+
otherMentionAnchors,
|
|
563
|
+
claimed,
|
|
564
|
+
question: input.question,
|
|
565
|
+
});
|
|
566
|
+
if (extracted.headerIndex >= 0) {
|
|
472
567
|
claimed.add(extracted.headerIndex);
|
|
473
568
|
}
|
|
474
569
|
let description = suppliedDescription.length > 0
|
|
475
570
|
? suppliedDescription
|
|
476
|
-
:
|
|
571
|
+
: extracted.description;
|
|
477
572
|
if (description.length > MAX_OPTION_DESCRIPTION_CHARS) {
|
|
478
573
|
description = description.slice(0, MAX_OPTION_DESCRIPTION_CHARS);
|
|
479
574
|
omitted.push(`${id} (${label}): the description was cut at ${MAX_OPTION_DESCRIPTION_CHARS} characters`);
|
|
480
575
|
}
|
|
481
|
-
|
|
482
|
-
|
|
576
|
+
// The wording of the source for the option survives a supplied
|
|
577
|
+
// description: it can carry the caveat of the option ("it must
|
|
578
|
+
// actually connect").
|
|
579
|
+
const sourceWording = suppliedDescription.length > 0 &&
|
|
580
|
+
extracted.description.length > 0 &&
|
|
581
|
+
extracted.description !== suppliedDescription
|
|
582
|
+
? extracted.description
|
|
583
|
+
: "";
|
|
584
|
+
const sourceConstraints = [
|
|
585
|
+
...(sourceWording.length > 0 && extracted.descriptionConstraint
|
|
586
|
+
? [sourceWording]
|
|
587
|
+
: []),
|
|
588
|
+
...extracted.constraints,
|
|
589
|
+
];
|
|
590
|
+
const sourceTradeoffs = [
|
|
591
|
+
...(sourceWording.length > 0 && !extracted.descriptionConstraint
|
|
592
|
+
? [sourceWording]
|
|
593
|
+
: []),
|
|
594
|
+
...extracted.tradeoffs,
|
|
595
|
+
];
|
|
596
|
+
const sourceFacts = sourceConstraints.length > 0 || sourceTradeoffs.length > 0;
|
|
597
|
+
const tradeoffsResult = readFacts(mergeFacts(supplied?.tradeoffs, sourceTradeoffs), sourceTradeoffs);
|
|
598
|
+
const constraintsResult = readFacts(mergeFacts(supplied?.constraints, sourceConstraints), sourceConstraints);
|
|
483
599
|
if (tradeoffsResult.cut || constraintsResult.cut) {
|
|
484
600
|
omitted.push(`${id} (${label}): facts beyond the limit of ${MAX_OPTION_FACTS} did not reach the evaluation`);
|
|
485
601
|
}
|
|
@@ -487,10 +603,15 @@ export function buildChoiceDecisionContext(input) {
|
|
|
487
603
|
constraintsResult.facts.some((fact) => fact.length === MAX_OPTION_FACT_CHARS)) {
|
|
488
604
|
omitted.push(`${id} (${label}): a fact was cut at ${MAX_OPTION_FACT_CHARS} characters`);
|
|
489
605
|
}
|
|
490
|
-
if (suppliedDescription.length > 0) {
|
|
606
|
+
if (suppliedDescription.length > 0 && sourceFacts) {
|
|
607
|
+
// The meaning comes from the structure, the facts of the message
|
|
608
|
+
// are merged with it: the provenance is mixed.
|
|
609
|
+
derivedFromBoth += 1;
|
|
610
|
+
}
|
|
611
|
+
else if (suppliedDescription.length > 0) {
|
|
491
612
|
derivedFromStructured += 1;
|
|
492
613
|
}
|
|
493
|
-
else if (extracted
|
|
614
|
+
else if (extracted.found) {
|
|
494
615
|
derivedFromMessage += 1;
|
|
495
616
|
}
|
|
496
617
|
else {
|
|
@@ -553,7 +674,8 @@ export function buildChoiceDecisionContext(input) {
|
|
|
553
674
|
uncertainties.push(note);
|
|
554
675
|
omitted.push(note);
|
|
555
676
|
}
|
|
556
|
-
const derived =
|
|
677
|
+
const derived = derivedFromBoth > 0 ||
|
|
678
|
+
(derivedFromStructured > 0 && derivedFromMessage > 0)
|
|
557
679
|
? "mixed"
|
|
558
680
|
: derivedFromStructured > 0
|
|
559
681
|
? "structured"
|