@farmslot/agent-runtime 0.29.1 → 0.29.2
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 +5 -0
- package/package.json +3 -3
- package/scripts/acceptance-ledger.cjs +77 -5
- package/scripts/claim-review-gate.mjs +57 -29
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
- Active-development baseline; add user-facing changes here before release or package publication.
|
|
6
6
|
|
|
7
|
+
## 0.29.2 - 2026-10-18
|
|
8
|
+
|
|
9
|
+
- A QA task's acceptance ledger merges its case executions by criterion instead of keeping only the last case: a passing execution replaces the rows it proves and leaves the others, and each row names its case execution. The evidence review completion check binds each row to its own case package. Needs gateway 0.24.0 or later; deploy it first.
|
|
10
|
+
- Moves to `@farmslot/protocol` 0.55.0 and `@farmslot/adapter-sdk` 0.18.2.
|
|
11
|
+
|
|
7
12
|
## 0.29.1 - 2026-10-17
|
|
8
13
|
|
|
9
14
|
- Align with `@farmslot/adapter-sdk` 0.18.1 and `@farmslot/recipe-runner` 0.39.1 (network capture summaries redact credential-like path segments).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farmslot/agent-runtime",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"test:branch-maintenance-live": "node --import tsx --test test/branch-maintenance-live.mts"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@farmslot/adapter-sdk": "0.18.
|
|
64
|
-
"@farmslot/protocol": "0.
|
|
63
|
+
"@farmslot/adapter-sdk": "0.18.2",
|
|
64
|
+
"@farmslot/protocol": "0.55.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/node": "^22.0.0",
|
|
@@ -7,7 +7,8 @@ const { atomicWrite, readJson } = require('./mark-io.cjs');
|
|
|
7
7
|
// and docs/reference/task-directory-contract.md).
|
|
8
8
|
//
|
|
9
9
|
// The engine derives schema-2 verdicts. This module transfers the selected engine
|
|
10
|
-
// ledger into the task namespace
|
|
10
|
+
// ledger into the task namespace (a QA task merges its case executions by claim
|
|
11
|
+
// id); `farmslot-agent ac` only reads it. Retained
|
|
11
12
|
// schema-1 ledgers remain display input, never current completion proof. The ids
|
|
12
13
|
// come from task init in inputs/handoff.json; this module never invents one.
|
|
13
14
|
//
|
|
@@ -22,6 +23,7 @@ const {
|
|
|
22
23
|
ACCEPTANCE_CRITERION_ID_PATTERN,
|
|
23
24
|
acceptanceCriterionId,
|
|
24
25
|
acceptanceCriteriaMatch,
|
|
26
|
+
acceptanceRowExecution,
|
|
25
27
|
registeredAcceptanceCriteria,
|
|
26
28
|
validateAcceptanceStatusLedger,
|
|
27
29
|
acceptanceCriteriaView,
|
|
@@ -143,10 +145,15 @@ function assertEvidencePath(taskDir, rawPath) {
|
|
|
143
145
|
return normalized;
|
|
144
146
|
}
|
|
145
147
|
|
|
146
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* Transfer one engine-owned execution. Never aggregate sibling attempts of one
|
|
150
|
+
* recipe. A QA task records one package per case, so its ledger merges instead:
|
|
151
|
+
* see `mergeCaseClaims`.
|
|
152
|
+
*/
|
|
147
153
|
function setDerivedClaims(taskDir, claims) {
|
|
148
154
|
if (claims.schemaVersion !== 2) throw new AcceptanceRefusal('Derived claims require schema 2.');
|
|
149
|
-
const
|
|
155
|
+
const handoff = readJson(path.join(taskDir, HANDOFF_INPUT));
|
|
156
|
+
const registered = criteriaFromHandoff(handoff);
|
|
150
157
|
for (const criterion of registered) {
|
|
151
158
|
const claim = claims.criteria.find((entry) => entry.id === criterion.id);
|
|
152
159
|
if (!claim || claim.text !== criterion.text)
|
|
@@ -162,8 +169,71 @@ function setDerivedClaims(taskDir, claims) {
|
|
|
162
169
|
throw new AcceptanceRefusal(`Unknown task claim ${claim.id}.`);
|
|
163
170
|
for (const file of claim.evidence) assertEvidencePath(taskDir, file);
|
|
164
171
|
}
|
|
165
|
-
|
|
166
|
-
|
|
172
|
+
const ledger = handoff.flow === 'qa' ? mergeCaseClaims(taskDir, registered, claims) : claims;
|
|
173
|
+
writeAcceptanceLedger(taskDir, ledger);
|
|
174
|
+
return ledger;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The retained package a task row came from: the directory of its transported
|
|
179
|
+
* trace whose engine claims still name the row's execution, or null.
|
|
180
|
+
*/
|
|
181
|
+
function rowPackageDir(taskDir, row, execution) {
|
|
182
|
+
for (const file of row.evidence ?? []) {
|
|
183
|
+
if (path.posix.basename(file) !== 'trace.json') continue;
|
|
184
|
+
const dir = path.join(taskDir, path.posix.dirname(file));
|
|
185
|
+
let claims;
|
|
186
|
+
try {
|
|
187
|
+
claims = JSON.parse(fs.readFileSync(path.join(dir, 'acceptance-status.json'), 'utf8'));
|
|
188
|
+
} catch (err) {
|
|
189
|
+
// A directory without readable engine claims is not a package of this row.
|
|
190
|
+
if (err.code === 'ENOENT' || err instanceof SyntaxError) continue;
|
|
191
|
+
throw err;
|
|
192
|
+
}
|
|
193
|
+
if (isRecord(claims) && claims.recipeRunId === execution) return dir;
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* One QA ledger keyed by claim id. A row the new execution addresses (a selected
|
|
200
|
+
* node proves it) replaces the stored row; every other stored row keeps the case
|
|
201
|
+
* execution it came from. Each row names its execution, so the gate can bind it
|
|
202
|
+
* to that case's package.
|
|
203
|
+
*/
|
|
204
|
+
function mergeCaseClaims(taskDir, registered, claims) {
|
|
205
|
+
let stored;
|
|
206
|
+
try {
|
|
207
|
+
stored = readAcceptanceLedger(taskDir);
|
|
208
|
+
} catch (err) {
|
|
209
|
+
// An unreadable stored ledger holds no row to keep; this execution replaces it.
|
|
210
|
+
if (!(err instanceof AcceptanceRefusal)) throw err;
|
|
211
|
+
stored = null;
|
|
212
|
+
}
|
|
213
|
+
const kept = new Map();
|
|
214
|
+
if (stored?.schemaVersion === 2 && validateAcceptanceStatusLedger(stored).length === 0) {
|
|
215
|
+
for (const row of stored.criteria) {
|
|
216
|
+
const registration = registered.find(({ id }) => id === row.id);
|
|
217
|
+
if (ACCEPTANCE_CRITERION_ID_PATTERN.test(row.id) && registration?.text !== row.text) continue;
|
|
218
|
+
const execution = acceptanceRowExecution(stored, row);
|
|
219
|
+
// A row whose evidence is gone, or whose case directory now holds another
|
|
220
|
+
// execution, has nothing left to bind; the new row stands.
|
|
221
|
+
if (
|
|
222
|
+
!row.evidence.every((file) => fs.existsSync(path.join(taskDir, file))) ||
|
|
223
|
+
!rowPackageDir(taskDir, row, execution)
|
|
224
|
+
)
|
|
225
|
+
continue;
|
|
226
|
+
kept.set(row.id, { ...row, recipeRunId: execution });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const criteria = claims.criteria.map((row) =>
|
|
230
|
+
row.recipeNodes.length === 0 && kept.has(row.id)
|
|
231
|
+
? kept.get(row.id)
|
|
232
|
+
: { ...row, recipeRunId: claims.recipeRunId },
|
|
233
|
+
);
|
|
234
|
+
const ids = new Set(criteria.map(({ id }) => id));
|
|
235
|
+
for (const row of kept.values()) if (!ids.has(row.id)) criteria.push(row);
|
|
236
|
+
return { ...claims, criteria };
|
|
167
237
|
}
|
|
168
238
|
|
|
169
239
|
/** Every handoff criterion with its current verdict, or null when unrecorded. */
|
|
@@ -297,11 +367,13 @@ module.exports = {
|
|
|
297
367
|
AcceptanceRefusal,
|
|
298
368
|
acceptanceContractIssues,
|
|
299
369
|
acceptanceCriterionId,
|
|
370
|
+
acceptanceRowExecution,
|
|
300
371
|
acceptanceStatusList,
|
|
301
372
|
handoffAcceptanceCriteria,
|
|
302
373
|
requireHandoffAcceptanceCriteria,
|
|
303
374
|
readAcceptanceLedger,
|
|
304
375
|
renderAcceptanceCoverage,
|
|
376
|
+
rowPackageDir,
|
|
305
377
|
setDerivedClaims,
|
|
306
378
|
summarizeAcceptanceStatus,
|
|
307
379
|
validateAcceptanceStatusLedger,
|
|
@@ -7,43 +7,71 @@ import {
|
|
|
7
7
|
validateRecordedEvidencePackage,
|
|
8
8
|
} from '@farmslot/adapter-sdk/evidence';
|
|
9
9
|
|
|
10
|
+
import ledgerModule from './acceptance-ledger.cjs';
|
|
10
11
|
import attemptSelection from './retained-recipe-attempt.cjs';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
const BOUND_CLAIM_KEYS = [
|
|
14
|
+
'id',
|
|
15
|
+
'text',
|
|
16
|
+
'kind',
|
|
17
|
+
'parentId',
|
|
18
|
+
'proofMode',
|
|
19
|
+
'verdict',
|
|
20
|
+
'recipeNodes',
|
|
21
|
+
'assertionIndices',
|
|
22
|
+
'moments',
|
|
23
|
+
'retainedFrom',
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The existing reader verifies bytes; this only binds the task transport to the
|
|
28
|
+
* selected execution, and each QA case row to the case package that recorded it.
|
|
29
|
+
*/
|
|
13
30
|
export async function pendingClaimReviewIssues(taskDir, ledger) {
|
|
14
31
|
const pointer = attemptSelection.readRecipeAttemptSelection(taskDir);
|
|
15
32
|
if (!pointer) return ['Human evidence review requires a selected successful recipe attempt.'];
|
|
33
|
+
const packages = new Map();
|
|
34
|
+
const readPackage = async (root) => {
|
|
35
|
+
if (!packages.has(root)) {
|
|
36
|
+
const { input, checks } = await readRecordedEvidencePackage(root);
|
|
37
|
+
const errors = checks
|
|
38
|
+
.filter((check) => check.status === 'fail')
|
|
39
|
+
.map((check) => check.message);
|
|
40
|
+
errors.push(
|
|
41
|
+
...validateRecordedEvidencePackage(input)
|
|
42
|
+
.findings.filter((finding) => finding.severity === 'error')
|
|
43
|
+
.map((finding) => finding.message),
|
|
44
|
+
);
|
|
45
|
+
packages.set(root, { input, errors });
|
|
46
|
+
}
|
|
47
|
+
return packages.get(root);
|
|
48
|
+
};
|
|
16
49
|
const root = path.join(taskDir, 'artifacts', pointer.relativeArtifactRoot);
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
...validateRecordedEvidencePackage(input)
|
|
21
|
-
.findings.filter((finding) => finding.severity === 'error')
|
|
22
|
-
.map((finding) => finding.message),
|
|
23
|
-
);
|
|
24
|
-
if (errors.length) return errors;
|
|
25
|
-
if (!input.claims || input.claims.recipeRunId !== ledger.recipeRunId)
|
|
50
|
+
const selected = await readPackage(root);
|
|
51
|
+
if (selected.errors.length) return selected.errors;
|
|
52
|
+
if (!selected.input.claims || selected.input.claims.recipeRunId !== ledger.recipeRunId)
|
|
26
53
|
return ['Task verdicts belong to another recipe execution.'];
|
|
27
|
-
|
|
28
|
-
const selected = selectedRecipeClaims(input);
|
|
54
|
+
const errors = [];
|
|
29
55
|
for (const row of ledger.criteria) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
56
|
+
const execution = ledgerModule.acceptanceRowExecution(ledger, row);
|
|
57
|
+
const source =
|
|
58
|
+
execution === ledger.recipeRunId ? root : ledgerModule.rowPackageDir(taskDir, row, execution);
|
|
59
|
+
if (!source) {
|
|
60
|
+
errors.push(`Task claim ${row.id} has no retained package for its execution.`);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const { input, errors: packageErrors } = await readPackage(source);
|
|
64
|
+
if (packageErrors.length) {
|
|
65
|
+
errors.push(...packageErrors);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
// A repair transports the engine selection: retained rows keep their original execution.
|
|
69
|
+
const claim =
|
|
70
|
+
input.claims?.recipeRunId === execution
|
|
71
|
+
? selectedRecipeClaims(input).find(({ id }) => id === row.id)
|
|
72
|
+
: undefined;
|
|
73
|
+
if (!claim || BOUND_CLAIM_KEYS.some((key) => !isDeepStrictEqual(row[key], claim[key])))
|
|
46
74
|
errors.push(`Task claim ${row.id} differs from its selected engine claim.`);
|
|
47
75
|
}
|
|
48
|
-
return errors;
|
|
76
|
+
return [...new Set(errors)];
|
|
49
77
|
}
|