@unson/brainbase-mcp 0.50.31 → 0.51.1
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/contracts/canonical-task/store-schema.sql +3 -0
- package/dist/antigravity-judgment-hook.d.ts +5 -0
- package/dist/antigravity-judgment-hook.js +344 -27
- package/dist/automation-run.js +3 -2
- package/dist/canonical-task-postgres.js +3 -0
- package/dist/canonical-task-service.d.ts +6 -0
- package/dist/canonical-task-service.js +40 -1
- package/dist/company-os-learning-adoption.d.ts +9 -0
- package/dist/company-os-learning-adoption.js +50 -1
- package/dist/durable-waits.d.ts +30 -0
- package/dist/durable-waits.js +100 -94
- package/dist/foundation-public-provider.d.ts +3 -1
- package/dist/foundation-public-provider.js +2 -2
- package/dist/graph-corrections.d.ts +46 -1
- package/dist/graph-corrections.js +172 -1
- package/dist/judgment-event-outbox.d.ts +24 -2
- package/dist/judgment-event-outbox.js +92 -10
- package/dist/judgment-frame.js +2 -2
- package/dist/judgment-host.d.ts +4 -1
- package/dist/judgment-host.js +126 -14
- package/dist/judgment-task-progress.d.ts +41 -0
- package/dist/judgment-task-progress.js +18 -0
- package/dist/knowledge-continuation.js +7 -1
- package/dist/knowledge-lookup.js +43 -58
- package/dist/mcp-runtime.d.ts +9 -0
- package/dist/mcp-runtime.js +12 -4
- package/dist/meeting-automation-runtime.d.ts +52 -0
- package/dist/meeting-automation-runtime.js +46 -0
- package/dist/queue-task-tools.js +2 -2
- package/dist/routine-liveness.js +0 -1
- package/dist/routine-runtime.js +1 -1
- package/dist/server.d.ts +59 -85
- package/dist/server.js +44 -36
- package/dist/ssot.js +1 -1
- package/dist/testing/queue-task-tools-contract.js +1 -1
- package/dist/world-model-impact-index.d.ts +132 -0
- package/dist/world-model-impact-index.js +901 -0
- package/package.json +6 -18
- package/ui/judgment-history.css +13 -0
- package/ui/objective-editor.css +19 -2
- package/ui/objective-editor.js +6 -3
- package/ui/project-workspace.css +33 -26
- package/ui/workspace-kit.js +9 -7
- package/ui/world/world-view.css +65 -46
- package/ui/world/world-view.js +27 -18
- package/dist/execution-authority-http.d.ts +0 -30
- package/dist/execution-authority-http.js +0 -454
- package/dist/execution-authority.d.ts +0 -282
- package/dist/execution-authority.js +0 -867
- package/dist/resource-reservation-http.d.ts +0 -31
- package/dist/resource-reservation-http.js +0 -371
- package/dist/resource-reservations.d.ts +0 -221
- package/dist/resource-reservations.js +0 -577
|
@@ -6,6 +6,7 @@ import { stableHash } from './import-extract.js';
|
|
|
6
6
|
import { canonicalPortableJson } from './portable-graph.js';
|
|
7
7
|
import { getCanonicalRelation } from './relation-registry.js';
|
|
8
8
|
import { loadPersonalOs, mutatePersonalOsWithSidecar, readPersonalOsSidecar } from './ssot.js';
|
|
9
|
+
import { analyzeWorldModelImpact, canReadFoundationAcl, formatWorldModelDependencyPath, redactWorldModelDependencyPath, resolveLatestCatalogRecord } from './world-model-impact-index.js';
|
|
9
10
|
/**
|
|
10
11
|
* Owner corrections for the canonical local Graph v2.
|
|
11
12
|
*
|
|
@@ -149,6 +150,16 @@ export async function applyGraphCorrection(dataDir, input, options = {}) {
|
|
|
149
150
|
throw new GraphCorrectionError('readback_mismatch', 'readback_mismatch', 'The correction history line was not found after saving');
|
|
150
151
|
}
|
|
151
152
|
const digest = graphRecordDigest(stored);
|
|
153
|
+
let worldModelImpact = { worldModelReviewHints: [], affectedModelRefs: [] };
|
|
154
|
+
try {
|
|
155
|
+
worldModelImpact = findGraphCorrectionWorldModelHints(reloaded.graph, outcome.recordType, stored, {
|
|
156
|
+
principal: options.principal
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
// The Graph correction and history sidecar are already committed and verified;
|
|
161
|
+
// omit optional world-model review hints rather than failing the saved correction.
|
|
162
|
+
}
|
|
152
163
|
return {
|
|
153
164
|
status: 'saved',
|
|
154
165
|
correction: outcome.record,
|
|
@@ -156,8 +167,168 @@ export async function applyGraphCorrection(dataDir, input, options = {}) {
|
|
|
156
167
|
record: stored,
|
|
157
168
|
digest,
|
|
158
169
|
readback: { verified: true, digest, historyRecorded: true },
|
|
159
|
-
appliesTo: GRAPH_CORRECTION_APPLIES_TO
|
|
170
|
+
appliesTo: GRAPH_CORRECTION_APPLIES_TO,
|
|
171
|
+
...(worldModelImpact.worldModelReviewHints.length > 0
|
|
172
|
+
? { worldModelReviewHints: worldModelImpact.worldModelReviewHints }
|
|
173
|
+
: {}),
|
|
174
|
+
...(worldModelImpact.affectedModelRefs.length > 0
|
|
175
|
+
? { affectedModelRefs: worldModelImpact.affectedModelRefs }
|
|
176
|
+
: {})
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Pure helper that bridges a local Graph v2 entity/edge correction to the
|
|
181
|
+
* canonical `foundation` world model. It locates `VariableDefinition` and
|
|
182
|
+
* `ModelDefinition` entries referencing the corrected entity or edge endpoints
|
|
183
|
+
* (directly via scope/subject/relation, and transitively via world-model
|
|
184
|
+
* dependencies) so callers can trigger world-model review instead of stopping
|
|
185
|
+
* at a local patch.
|
|
186
|
+
*
|
|
187
|
+
* Enforces Foundation ACL read checks against `options.principal ?? graph.owner?.id`
|
|
188
|
+
* so unauthorized `private` Foundation definitions are never exposed in hints,
|
|
189
|
+
* `affectedModelRefs`, `dependencyPath`, or `reason`.
|
|
190
|
+
*/
|
|
191
|
+
export function findGraphCorrectionWorldModelHints(graph, recordType, record, options = {}) {
|
|
192
|
+
const catalog = graph.foundation;
|
|
193
|
+
if (!catalog || catalog.records.length === 0) {
|
|
194
|
+
return { worldModelReviewHints: [], affectedModelRefs: [] };
|
|
195
|
+
}
|
|
196
|
+
const effectivePrincipal = options.principal ?? graph.owner?.id;
|
|
197
|
+
const touchedIds = recordType === 'entity'
|
|
198
|
+
? [record.id]
|
|
199
|
+
: [...new Set([record.id, record.fromId, record.toId])].sort((a, b) => a.localeCompare(b, 'en'));
|
|
200
|
+
const touchedSet = new Set(touchedIds);
|
|
201
|
+
const latestWorldRecords = new Map();
|
|
202
|
+
const directSeedRefs = new Map();
|
|
203
|
+
const logicalKeys = new Set();
|
|
204
|
+
for (const item of catalog.records) {
|
|
205
|
+
if (item.definition.type === 'variable' || item.definition.type === 'model') {
|
|
206
|
+
logicalKeys.add(JSON.stringify([item.definition.type, item.definition.id]));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
for (const logicalKey of [...logicalKeys].sort((a, b) => a.localeCompare(b, 'en'))) {
|
|
210
|
+
const [type, id] = JSON.parse(logicalKey);
|
|
211
|
+
const latest = resolveLatestCatalogRecord(catalog, type, id);
|
|
212
|
+
if (!latest || (latest.definition.type !== 'variable' && latest.definition.type !== 'model'))
|
|
213
|
+
continue;
|
|
214
|
+
const ref = {
|
|
215
|
+
type: latest.definition.type,
|
|
216
|
+
id: latest.definition.id,
|
|
217
|
+
revision: latest.definition.revision,
|
|
218
|
+
digest: latest.digest
|
|
219
|
+
};
|
|
220
|
+
const readable = canReadFoundationAcl(latest.definition.acl, effectivePrincipal);
|
|
221
|
+
latestWorldRecords.set(logicalKey, { ref, readable });
|
|
222
|
+
const matchedByScope = new Set();
|
|
223
|
+
const matchedBySubject = new Set();
|
|
224
|
+
for (const subjectId of latest.definition.scope.subjectIds) {
|
|
225
|
+
if (touchedSet.has(subjectId))
|
|
226
|
+
matchedByScope.add(subjectId);
|
|
227
|
+
}
|
|
228
|
+
if (latest.definition.type === 'variable') {
|
|
229
|
+
for (const touchedId of touchedIds) {
|
|
230
|
+
if (latest.definition.subject === touchedId || latest.definition.subject.startsWith(`${touchedId}/`)) {
|
|
231
|
+
matchedBySubject.add(touchedId);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
for (const subjectId of latest.definition.applicability.subjectIds) {
|
|
237
|
+
if (touchedSet.has(subjectId))
|
|
238
|
+
matchedByScope.add(subjectId);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const matchedIds = [...new Set([...matchedByScope, ...matchedBySubject])].sort((a, b) => a.localeCompare(b, 'en'));
|
|
242
|
+
if (matchedIds.length > 0) {
|
|
243
|
+
const matchKind = matchedByScope.size > 0 ? 'direct_scope' : 'direct_subject';
|
|
244
|
+
directSeedRefs.set(logicalKey, {
|
|
245
|
+
ref,
|
|
246
|
+
matchedEntityIds: matchedIds,
|
|
247
|
+
matchKind,
|
|
248
|
+
reason: `${ref.type}/${ref.id}@${ref.revision} references corrected ${recordType} node(s): ${matchedIds.join(', ')}`,
|
|
249
|
+
readable
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
for (const relation of catalog.relations) {
|
|
254
|
+
const pairs = [
|
|
255
|
+
[relation.source, relation.target],
|
|
256
|
+
[relation.target, relation.source]
|
|
257
|
+
];
|
|
258
|
+
for (const [candidate, counterpart] of pairs) {
|
|
259
|
+
if ((candidate.type !== 'variable' && candidate.type !== 'model') || !touchedSet.has(counterpart.id))
|
|
260
|
+
continue;
|
|
261
|
+
const logicalKey = JSON.stringify([candidate.type, candidate.id]);
|
|
262
|
+
const entry = latestWorldRecords.get(logicalKey);
|
|
263
|
+
if (!entry || directSeedRefs.has(logicalKey))
|
|
264
|
+
continue;
|
|
265
|
+
const matchedIds = [counterpart.id];
|
|
266
|
+
directSeedRefs.set(logicalKey, {
|
|
267
|
+
ref: entry.ref,
|
|
268
|
+
matchedEntityIds: matchedIds,
|
|
269
|
+
matchKind: 'direct_relation',
|
|
270
|
+
reason: `${entry.ref.type}/${entry.ref.id}@${entry.ref.revision} is linked via ${relation.relation} to corrected node ${counterpart.id}`,
|
|
271
|
+
readable: entry.readable
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const hintsByKey = new Map();
|
|
276
|
+
for (const [logicalKey, seed] of directSeedRefs) {
|
|
277
|
+
if (!seed.readable)
|
|
278
|
+
continue;
|
|
279
|
+
hintsByKey.set(logicalKey, {
|
|
280
|
+
status: 'needs_review',
|
|
281
|
+
targetRef: seed.ref,
|
|
282
|
+
matchedEntityIds: seed.matchedEntityIds,
|
|
283
|
+
matchKind: seed.matchKind,
|
|
284
|
+
reason: seed.reason
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
const isNodeReadable = (ref) => {
|
|
288
|
+
if (ref.kind === 'redacted')
|
|
289
|
+
return false;
|
|
290
|
+
if (ref.kind === 'objective' || ref.kind === 'variable' || ref.kind === 'model' || ref.kind === 'constraint') {
|
|
291
|
+
const latest = resolveLatestCatalogRecord(catalog, ref.kind, ref.id);
|
|
292
|
+
return latest ? canReadFoundationAcl(latest.definition.acl, effectivePrincipal) : false;
|
|
293
|
+
}
|
|
294
|
+
return false;
|
|
160
295
|
};
|
|
296
|
+
if (directSeedRefs.size > 0) {
|
|
297
|
+
const seedRefs = [...directSeedRefs.values()].map((seed) => ({
|
|
298
|
+
kind: seed.ref.type,
|
|
299
|
+
id: seed.ref.id,
|
|
300
|
+
revision: seed.ref.revision
|
|
301
|
+
}));
|
|
302
|
+
const impact = analyzeWorldModelImpact({ catalog, changedRefs: seedRefs });
|
|
303
|
+
for (const item of impact.affectedItems) {
|
|
304
|
+
if (item.affectedRef.kind !== 'variable' && item.affectedRef.kind !== 'model')
|
|
305
|
+
continue;
|
|
306
|
+
const logicalKey = JSON.stringify([item.affectedRef.kind, item.affectedRef.id]);
|
|
307
|
+
if (hintsByKey.has(logicalKey))
|
|
308
|
+
continue;
|
|
309
|
+
const entry = latestWorldRecords.get(logicalKey);
|
|
310
|
+
if (!entry || !entry.readable)
|
|
311
|
+
continue;
|
|
312
|
+
const sourceKey = JSON.stringify([item.sourceRef.kind, item.sourceRef.id]);
|
|
313
|
+
const matchedEntityIds = directSeedRefs.get(sourceKey)?.matchedEntityIds ?? touchedIds;
|
|
314
|
+
const redactedPath = redactWorldModelDependencyPath(item.dependencyPath, isNodeReadable);
|
|
315
|
+
hintsByKey.set(logicalKey, {
|
|
316
|
+
status: 'needs_review',
|
|
317
|
+
targetRef: entry.ref,
|
|
318
|
+
matchedEntityIds,
|
|
319
|
+
matchKind: 'transitive_dependency',
|
|
320
|
+
dependencyPath: redactedPath,
|
|
321
|
+
reason: `needs_review: ${formatWorldModelDependencyPath(redactedPath)}`
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
const worldModelReviewHints = [...hintsByKey.values()].sort((left, right) => left.targetRef.type.localeCompare(right.targetRef.type, 'en')
|
|
326
|
+
|| left.targetRef.id.localeCompare(right.targetRef.id, 'en')
|
|
327
|
+
|| left.targetRef.revision.localeCompare(right.targetRef.revision, 'en'));
|
|
328
|
+
const affectedModelRefs = worldModelReviewHints
|
|
329
|
+
.filter((hint) => hint.targetRef.type === 'model')
|
|
330
|
+
.map((hint) => hint.targetRef);
|
|
331
|
+
return { worldModelReviewHints, affectedModelRefs };
|
|
161
332
|
}
|
|
162
333
|
/**
|
|
163
334
|
* Reads the correction history in append order. A missing file means no
|
|
@@ -42,7 +42,9 @@ export interface JudgmentOutboxStorage {
|
|
|
42
42
|
export declare function resolveJudgmentKnowledgeEventOutboxPaths(options?: ResolveJudgmentOutboxPathsOptions): JudgmentOutboxPaths;
|
|
43
43
|
export interface JudgmentOutboxPostAck {
|
|
44
44
|
event_id: string;
|
|
45
|
-
candidate_id: string;
|
|
45
|
+
candidate_id: string | null;
|
|
46
|
+
candidate_created?: boolean;
|
|
47
|
+
target_tier?: string;
|
|
46
48
|
http_status?: number | null;
|
|
47
49
|
received_at: string;
|
|
48
50
|
[key: string]: unknown;
|
|
@@ -50,12 +52,32 @@ export interface JudgmentOutboxPostAck {
|
|
|
50
52
|
export interface JudgmentOutboxReadback {
|
|
51
53
|
schema_version: typeof JUDGMENT_EVENT_READBACK_SCHEMA_VERSION;
|
|
52
54
|
event_id: string;
|
|
53
|
-
candidate_id: string;
|
|
55
|
+
candidate_id: string | null;
|
|
56
|
+
candidate_created?: boolean;
|
|
57
|
+
target_tier?: string;
|
|
54
58
|
processing_stage: 'retrievable';
|
|
55
59
|
semantic_state: 'active';
|
|
56
60
|
readback_at: string;
|
|
57
61
|
[key: string]: unknown;
|
|
58
62
|
}
|
|
63
|
+
export interface JudgmentOutboxCandidateIdCheckInput {
|
|
64
|
+
readonly subjectType: string | null | undefined;
|
|
65
|
+
readonly postCandidateId: string | null | undefined;
|
|
66
|
+
readonly readbackCandidateId: string | null | undefined;
|
|
67
|
+
readonly postCandidateCreated?: unknown;
|
|
68
|
+
readonly postTargetTier?: unknown;
|
|
69
|
+
readonly readbackCandidateCreated?: unknown;
|
|
70
|
+
readonly readbackTargetTier?: unknown;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* RFC-002 Layer C PR-3 Contract 1: conditional `candidate_id: null` guard.
|
|
74
|
+
*
|
|
75
|
+
* `candidate_id === null` is accepted only when `subjectType === 'episode'`,
|
|
76
|
+
* both post and readback report `null`, and any explicit `candidate_created`
|
|
77
|
+
* or `target_tier` flags are consistent (`false` / `'episode'`). Non-episode
|
|
78
|
+
* subjects always require identical non-empty string `candidate_id` values.
|
|
79
|
+
*/
|
|
80
|
+
export declare function isValidJudgmentOutboxCandidateIdPair(input: JudgmentOutboxCandidateIdCheckInput): boolean;
|
|
59
81
|
/**
|
|
60
82
|
* Runtime adapters own HTTP/auth/org/Task concerns. The common core only
|
|
61
83
|
* asks an adapter to post and to perform the canonical readback.
|
|
@@ -44,6 +44,48 @@ export function resolveJudgmentKnowledgeEventOutboxPaths(options = {}) {
|
|
|
44
44
|
lockPath: options.lockPath ?? `${outboxDir}.sender.lock`
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
+
function isNonEmptyCandidateId(value) {
|
|
48
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
49
|
+
}
|
|
50
|
+
function hasConsistentEpisodeNullFlags(record) {
|
|
51
|
+
if (record.candidate_created !== undefined && record.candidate_created !== false) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
if (record.target_tier !== undefined && record.target_tier !== 'episode') {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
function isValidPostAckCandidateId(subjectType, post) {
|
|
60
|
+
if (post.candidate_id === null) {
|
|
61
|
+
return subjectType === 'episode' && hasConsistentEpisodeNullFlags(post);
|
|
62
|
+
}
|
|
63
|
+
return isNonEmptyCandidateId(post.candidate_id);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* RFC-002 Layer C PR-3 Contract 1: conditional `candidate_id: null` guard.
|
|
67
|
+
*
|
|
68
|
+
* `candidate_id === null` is accepted only when `subjectType === 'episode'`,
|
|
69
|
+
* both post and readback report `null`, and any explicit `candidate_created`
|
|
70
|
+
* or `target_tier` flags are consistent (`false` / `'episode'`). Non-episode
|
|
71
|
+
* subjects always require identical non-empty string `candidate_id` values.
|
|
72
|
+
*/
|
|
73
|
+
export function isValidJudgmentOutboxCandidateIdPair(input) {
|
|
74
|
+
if (input.postCandidateId !== input.readbackCandidateId)
|
|
75
|
+
return false;
|
|
76
|
+
if (input.postCandidateId === null) {
|
|
77
|
+
if (input.subjectType !== 'episode')
|
|
78
|
+
return false;
|
|
79
|
+
return hasConsistentEpisodeNullFlags({
|
|
80
|
+
candidate_created: input.postCandidateCreated,
|
|
81
|
+
target_tier: input.postTargetTier
|
|
82
|
+
}) && hasConsistentEpisodeNullFlags({
|
|
83
|
+
candidate_created: input.readbackCandidateCreated,
|
|
84
|
+
target_tier: input.readbackTargetTier
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return isNonEmptyCandidateId(input.postCandidateId);
|
|
88
|
+
}
|
|
47
89
|
function jsonFiles(directory, storage) {
|
|
48
90
|
try {
|
|
49
91
|
return storage.readdir(directory).filter((name) => name.endsWith(JSON_SUFFIX)).sort();
|
|
@@ -174,24 +216,47 @@ function errorStatus(error) {
|
|
|
174
216
|
const status = error && typeof error === 'object' && 'httpStatus' in error ? error.httpStatus : null;
|
|
175
217
|
return typeof status === 'number' && Number.isInteger(status) ? status : null;
|
|
176
218
|
}
|
|
177
|
-
function
|
|
219
|
+
function eventSubjectType(event) {
|
|
220
|
+
if (!event || typeof event !== 'object' || Array.isArray(event))
|
|
221
|
+
return null;
|
|
222
|
+
const subject = event.subject;
|
|
223
|
+
if (!subject || typeof subject !== 'object' || Array.isArray(subject))
|
|
224
|
+
return null;
|
|
225
|
+
const type = subject.type;
|
|
226
|
+
return typeof type === 'string' && type.length > 0 ? type : null;
|
|
227
|
+
}
|
|
228
|
+
function confirmedReceipt(value, eventId, candidateId, projectCode, subjectType) {
|
|
178
229
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
179
230
|
return false;
|
|
180
231
|
const receipt = value;
|
|
181
|
-
const post = receipt.post && typeof receipt.post === 'object'
|
|
182
|
-
|
|
232
|
+
const post = receipt.post && typeof receipt.post === 'object' && !Array.isArray(receipt.post)
|
|
233
|
+
? receipt.post
|
|
234
|
+
: null;
|
|
235
|
+
const readback = receipt.readback && typeof receipt.readback === 'object' && !Array.isArray(receipt.readback)
|
|
183
236
|
? receipt.readback
|
|
184
237
|
: null;
|
|
238
|
+
if (!post || !readback)
|
|
239
|
+
return false;
|
|
240
|
+
const validCandidatePair = isValidJudgmentOutboxCandidateIdPair({
|
|
241
|
+
subjectType,
|
|
242
|
+
postCandidateId: post.candidate_id,
|
|
243
|
+
readbackCandidateId: readback.candidate_id,
|
|
244
|
+
postCandidateCreated: post.candidate_created,
|
|
245
|
+
postTargetTier: post.target_tier,
|
|
246
|
+
readbackCandidateCreated: readback.candidate_created,
|
|
247
|
+
readbackTargetTier: readback.target_tier
|
|
248
|
+
});
|
|
185
249
|
return receipt.schema_version === JUDGMENT_EVENT_DELIVERY_RECEIPT_SCHEMA_VERSION
|
|
186
250
|
&& receipt.status === 'confirmed'
|
|
187
251
|
&& receipt.event_id === eventId
|
|
188
252
|
&& receipt.candidate_id === candidateId
|
|
189
253
|
&& receipt.project_code === projectCode
|
|
190
|
-
&& post
|
|
254
|
+
&& post.event_id === eventId
|
|
191
255
|
&& post.candidate_id === candidateId
|
|
192
|
-
&& readback
|
|
256
|
+
&& readback.schema_version === JUDGMENT_EVENT_READBACK_SCHEMA_VERSION
|
|
193
257
|
&& readback.event_id === eventId
|
|
194
258
|
&& readback.candidate_id === candidateId
|
|
259
|
+
&& validCandidatePair
|
|
195
260
|
&& readback.processing_stage === 'retrievable'
|
|
196
261
|
&& readback.semantic_state === 'active';
|
|
197
262
|
}
|
|
@@ -230,9 +295,9 @@ function eventProjectCodes(event) {
|
|
|
230
295
|
invalid: false
|
|
231
296
|
};
|
|
232
297
|
}
|
|
233
|
-
function readConfirmedReceipt(path, eventId, candidateId, code, storage) {
|
|
298
|
+
function readConfirmedReceipt(path, eventId, candidateId, code, subjectType, storage) {
|
|
234
299
|
try {
|
|
235
|
-
return confirmedReceipt(parseJson(path, storage), eventId, candidateId, code);
|
|
300
|
+
return confirmedReceipt(parseJson(path, storage), eventId, candidateId, code, subjectType);
|
|
236
301
|
}
|
|
237
302
|
catch {
|
|
238
303
|
return false;
|
|
@@ -322,6 +387,7 @@ function deliverCore(options) {
|
|
|
322
387
|
}
|
|
323
388
|
processed += 1;
|
|
324
389
|
const eventId = queued.event.event_id;
|
|
390
|
+
const subjectType = eventSubjectType(queued.event);
|
|
325
391
|
const postAck = queued.delivery.post_ack;
|
|
326
392
|
const attempt = queued.delivery.attempt || 1;
|
|
327
393
|
const readbackAttempt = queued.delivery.readback_attempt || 1;
|
|
@@ -332,7 +398,9 @@ function deliverCore(options) {
|
|
|
332
398
|
continue;
|
|
333
399
|
}
|
|
334
400
|
const receiptPath = join(options.paths.deliveryReceiptDir, `${eventId}.json`);
|
|
335
|
-
if (postAck
|
|
401
|
+
if (postAck
|
|
402
|
+
&& isValidPostAckCandidateId(subjectType, postAck)
|
|
403
|
+
&& readConfirmedReceipt(receiptPath, eventId, postAck.candidate_id, code, subjectType, storage)) {
|
|
336
404
|
try {
|
|
337
405
|
storage.unlink(target);
|
|
338
406
|
delivered += 1;
|
|
@@ -350,7 +418,7 @@ function deliverCore(options) {
|
|
|
350
418
|
if (!confirmedPost) {
|
|
351
419
|
failureKind = 'post';
|
|
352
420
|
confirmedPost = await delivery.post(queued.event);
|
|
353
|
-
if (confirmedPost.event_id !== eventId || !confirmedPost
|
|
421
|
+
if (confirmedPost.event_id !== eventId || !isValidPostAckCandidateId(subjectType, confirmedPost)) {
|
|
354
422
|
const error = new Error('knowledge_event_delivery_ack_identity_mismatch');
|
|
355
423
|
error.code = 'knowledge_event_delivery_ack_identity_mismatch';
|
|
356
424
|
error.phase = 'post';
|
|
@@ -371,11 +439,25 @@ function deliverCore(options) {
|
|
|
371
439
|
atomicWrite(target, ackQueued, storage);
|
|
372
440
|
queued = ackQueued;
|
|
373
441
|
}
|
|
442
|
+
else if (confirmedPost.event_id !== eventId || !isValidPostAckCandidateId(subjectType, confirmedPost)) {
|
|
443
|
+
const error = new Error('knowledge_event_delivery_ack_identity_mismatch');
|
|
444
|
+
error.code = 'knowledge_event_delivery_ack_identity_mismatch';
|
|
445
|
+
error.phase = 'post';
|
|
446
|
+
throw error;
|
|
447
|
+
}
|
|
374
448
|
failureKind = 'readback';
|
|
375
449
|
const readback = await delivery.readback({ event: queued.event, post: confirmedPost });
|
|
376
450
|
if (readback.schema_version !== JUDGMENT_EVENT_READBACK_SCHEMA_VERSION
|
|
377
451
|
|| readback.event_id !== eventId
|
|
378
|
-
||
|
|
452
|
+
|| !isValidJudgmentOutboxCandidateIdPair({
|
|
453
|
+
subjectType,
|
|
454
|
+
postCandidateId: confirmedPost.candidate_id,
|
|
455
|
+
readbackCandidateId: readback.candidate_id,
|
|
456
|
+
postCandidateCreated: confirmedPost.candidate_created,
|
|
457
|
+
postTargetTier: confirmedPost.target_tier,
|
|
458
|
+
readbackCandidateCreated: readback.candidate_created,
|
|
459
|
+
readbackTargetTier: readback.target_tier
|
|
460
|
+
})
|
|
379
461
|
|| readback.processing_stage !== 'retrievable'
|
|
380
462
|
|| readback.semantic_state !== 'active') {
|
|
381
463
|
const error = new Error('knowledge_event_readback_identity_or_state_mismatch');
|
package/dist/judgment-frame.js
CHANGED
|
@@ -633,7 +633,7 @@ export const judgmentFrameTools = [{
|
|
|
633
633
|
type: 'object',
|
|
634
634
|
additionalProperties: false,
|
|
635
635
|
properties: {
|
|
636
|
-
record_version: { type: 'string',
|
|
636
|
+
record_version: { type: 'string', enum: [JUDGMENT_FRAME_RECORD_VERSION] },
|
|
637
637
|
catalog_digest: { type: 'string', pattern: '^sha256:[a-f0-9]{64}$' },
|
|
638
638
|
selections: {
|
|
639
639
|
type: 'array',
|
|
@@ -781,7 +781,7 @@ export const judgmentModelOutcomeTools = [{
|
|
|
781
781
|
type: 'object',
|
|
782
782
|
additionalProperties: false,
|
|
783
783
|
properties: {
|
|
784
|
-
record_version: { type: 'string',
|
|
784
|
+
record_version: { type: 'string', enum: [JUDGMENT_MODEL_OUTCOME_RECORD_VERSION] },
|
|
785
785
|
catalog_digest: { type: 'string', pattern: '^sha256:[a-f0-9]{64}$' },
|
|
786
786
|
model: {
|
|
787
787
|
type: 'object',
|
package/dist/judgment-host.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { JudgmentKnowledgeEventSink } from './judgment-event-outbox.js';
|
|
|
3
3
|
import { canonicalJson } from './judgment-resolution-contract.js';
|
|
4
4
|
import { AUDIT_LINE_STRIP_PREFIX, COMPACT_FOUR_BLOCK_GATE_PROMPT_V2, COMPACT_FOUR_BLOCK_GATE_PROMPT_V3, REASONING_GATE_MODES, resolveReasoningGateMode, shouldApplyReasoningGate, type ReasoningGateHostConfig, type ReasoningGateMode } from './judgment-reasoning-gate-prompt.js';
|
|
5
5
|
import { DEFAULT_SESSION_WORLD_MODEL_UPDATE_TIMEOUT_MS, SESSION_MINI_WORLD_MODEL_SCHEMA_VERSION_V2, SESSION_WORLD_MODEL_FILENAME, SESSION_WORLD_MODEL_LOCK_FILENAME, WM_V2_LIMITS, parseSessionMiniWorldModelV2, readSessionMiniWorldModelV2, renderSessionMiniWorldModelPinV2, sessionWorldModelPaths, toLearningCandidateEvidenceDraftFromSessionWMV2, withSessionWorldModelLock, writeSessionMiniWorldModelV2, type SessionMiniWorldModelV2, type SessionWMLearningEvidenceDraftResultV2, type SessionWMLearningEvidenceDraftV2, type SessionWorldModelPaths, type SessionWorldModelUpdateEventV2, type SessionWorldModelUpdaterV2, type SessionWorldModelWriteResult } from './judgment-session-world-model.js';
|
|
6
|
+
import { taskProgressScopeSchema, type JudgmentTaskProgressAdapter } from './judgment-task-progress.js';
|
|
6
7
|
export { AUDIT_LINE_STRIP_PREFIX, COMPACT_FOUR_BLOCK_GATE_PROMPT_V2, COMPACT_FOUR_BLOCK_GATE_PROMPT_V3, DEFAULT_SESSION_WORLD_MODEL_UPDATE_TIMEOUT_MS, REASONING_GATE_MODES, SESSION_MINI_WORLD_MODEL_SCHEMA_VERSION_V2, SESSION_WORLD_MODEL_FILENAME, SESSION_WORLD_MODEL_LOCK_FILENAME, WM_V2_LIMITS, parseSessionMiniWorldModelV2, readSessionMiniWorldModelV2, renderSessionMiniWorldModelPinV2, resolveReasoningGateMode, sessionWorldModelPaths, shouldApplyReasoningGate, toLearningCandidateEvidenceDraftFromSessionWMV2, withSessionWorldModelLock, writeSessionMiniWorldModelV2, type ReasoningGateHostConfig, type ReasoningGateMode, type SessionMiniWorldModelV2, type SessionWMLearningEvidenceDraftResultV2, type SessionWMLearningEvidenceDraftV2, type SessionWorldModelPaths, type SessionWorldModelUpdateEventV2, type SessionWorldModelUpdaterV2, type SessionWorldModelWriteResult };
|
|
7
8
|
type Environment = Record<string, string | undefined>;
|
|
8
9
|
export interface ConversationMessage {
|
|
@@ -130,6 +131,7 @@ export interface ReasoningGateTelemetryEvent {
|
|
|
130
131
|
}
|
|
131
132
|
export interface JudgmentHostOptions {
|
|
132
133
|
env?: Environment;
|
|
134
|
+
taskProgress?: JudgmentTaskProgressAdapter;
|
|
133
135
|
resolver?: (request: JudgmentRequest) => Promise<JudgmentReceipt>;
|
|
134
136
|
/** Expected resolver binding; defaults to the built-in local adapter. */
|
|
135
137
|
expectedHostBinding?: JudgmentHostBinding;
|
|
@@ -192,6 +194,7 @@ export interface JudgmentEpisode {
|
|
|
192
194
|
zero_call_display_line: string | null;
|
|
193
195
|
zero_call_display_line_digest: string | null;
|
|
194
196
|
};
|
|
197
|
+
task_progress_scope?: ReturnType<typeof taskProgressScopeSchema.parse>;
|
|
195
198
|
episode_digest: string;
|
|
196
199
|
}
|
|
197
200
|
export interface JudgmentToolEvent {
|
|
@@ -242,7 +245,7 @@ export interface JudgmentAutonomyReceipt {
|
|
|
242
245
|
}
|
|
243
246
|
export interface JudgmentStopBlock {
|
|
244
247
|
decision: 'block';
|
|
245
|
-
block_kind?: 'autonomy_continue' | 'audit_repair';
|
|
248
|
+
block_kind?: 'autonomy_continue' | 'audit_repair' | 'semantic_replan';
|
|
246
249
|
reason: string;
|
|
247
250
|
}
|
|
248
251
|
export { canonicalJson };
|
package/dist/judgment-host.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { execFileSync } from 'node:child_process';
|
|
2
3
|
import { closeSync, constants as fsConstants, fsyncSync, linkSync, mkdirSync, openSync, readdirSync, readFileSync, realpathSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
3
4
|
import { homedir } from 'node:os';
|
|
4
5
|
import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
@@ -8,6 +9,7 @@ import { containsJudgmentFrameCredential } from './judgment-frame.js';
|
|
|
8
9
|
import { canonicalJson } from './judgment-resolution-contract.js';
|
|
9
10
|
import { AUDIT_LINE_STRIP_PREFIX, COMPACT_FOUR_BLOCK_GATE_PROMPT_V2, COMPACT_FOUR_BLOCK_GATE_PROMPT_V3, REASONING_GATE_MODES, resolveReasoningGateMode, shouldApplyReasoningGate } from './judgment-reasoning-gate-prompt.js';
|
|
10
11
|
import { DEFAULT_SESSION_WORLD_MODEL_UPDATE_TIMEOUT_MS, SESSION_MINI_WORLD_MODEL_SCHEMA_VERSION_V2, SESSION_WORLD_MODEL_FILENAME, SESSION_WORLD_MODEL_LOCK_FILENAME, WM_V2_LIMITS, parseSessionMiniWorldModelV2, readSessionMiniWorldModelV2, renderSessionMiniWorldModelPinV2, sessionWorldModelPaths, toLearningCandidateEvidenceDraftFromSessionWMV2, withSessionWorldModelLock, writeSessionMiniWorldModelV2 } from './judgment-session-world-model.js';
|
|
12
|
+
import { taskProgressScopeSchema, taskProgressObservationSchema } from './judgment-task-progress.js';
|
|
11
13
|
export { AUDIT_LINE_STRIP_PREFIX, COMPACT_FOUR_BLOCK_GATE_PROMPT_V2, COMPACT_FOUR_BLOCK_GATE_PROMPT_V3, DEFAULT_SESSION_WORLD_MODEL_UPDATE_TIMEOUT_MS, REASONING_GATE_MODES, SESSION_MINI_WORLD_MODEL_SCHEMA_VERSION_V2, SESSION_WORLD_MODEL_FILENAME, SESSION_WORLD_MODEL_LOCK_FILENAME, WM_V2_LIMITS, parseSessionMiniWorldModelV2, readSessionMiniWorldModelV2, renderSessionMiniWorldModelPinV2, resolveReasoningGateMode, sessionWorldModelPaths, shouldApplyReasoningGate, toLearningCandidateEvidenceDraftFromSessionWMV2, withSessionWorldModelLock, writeSessionMiniWorldModelV2 };
|
|
12
14
|
const DEFAULT_HOST_BINDING = Object.freeze({
|
|
13
15
|
adapter_id: 'brainbase-local',
|
|
@@ -247,22 +249,26 @@ function readCanonicalTranscript(payload, env, trustedConversationMessages) {
|
|
|
247
249
|
};
|
|
248
250
|
}
|
|
249
251
|
function findRepoRoot(start) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
252
|
+
try {
|
|
253
|
+
const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith('GIT_')));
|
|
254
|
+
return execFileSync('git', ['-C', resolve(start), 'rev-parse', '--show-toplevel'], {
|
|
255
|
+
encoding: 'utf8',
|
|
256
|
+
env: { ...env, LC_ALL: 'C' },
|
|
257
|
+
timeout: 2000,
|
|
258
|
+
stdio: ['ignore', 'pipe', 'pipe']
|
|
259
|
+
}).replace(/\r?\n$/u, '') || null;
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
const stderr = error instanceof Error && 'stderr' in error ? String(error.stderr) : '';
|
|
263
|
+
const reason = stderr.includes('dubious ownership') ? 'unsafe_repository'
|
|
264
|
+
: error instanceof Error && 'code' in error && error.code === 'ETIMEDOUT' ? 'timeout' : null;
|
|
265
|
+
if (reason) {
|
|
266
|
+
process.stderr.write(`${JSON.stringify({ event: 'judgment_repository_discovery_failed', reason })}\n`);
|
|
261
267
|
}
|
|
268
|
+
return null;
|
|
262
269
|
}
|
|
263
270
|
}
|
|
264
|
-
function instructionBindings(cwd) {
|
|
265
|
-
const discoveredRoot = findRepoRoot(cwd);
|
|
271
|
+
function instructionBindings(cwd, discoveredRoot) {
|
|
266
272
|
if (!discoveredRoot)
|
|
267
273
|
return [];
|
|
268
274
|
const root = realpathSync(discoveredRoot);
|
|
@@ -432,7 +438,7 @@ export function buildJudgmentRequest(payload, { env = process.env, trustedConver
|
|
|
432
438
|
permission_mode: typeof payload.permission_mode === 'string' && payload.permission_mode ? payload.permission_mode : null,
|
|
433
439
|
project_binding: projectBinding
|
|
434
440
|
},
|
|
435
|
-
instruction_bindings: instructionBindings(cwd),
|
|
441
|
+
instruction_bindings: instructionBindings(cwd, repoRoot),
|
|
436
442
|
completeness: transcript.complete ? 'complete' : 'partial'
|
|
437
443
|
};
|
|
438
444
|
return {
|
|
@@ -1216,6 +1222,7 @@ export async function runJudgmentHost(payload, options = {}) {
|
|
|
1216
1222
|
request_text_digest: sha256(request.request),
|
|
1217
1223
|
initial_receipt_digest: sha256(canonicalJson(adoption.receipt)),
|
|
1218
1224
|
adoption,
|
|
1225
|
+
...(options.taskProgress ? { task_progress_scope: taskProgressScopeSchema.parse(options.taskProgress.scope) } : {}),
|
|
1219
1226
|
audit_contract: {
|
|
1220
1227
|
schema_version: 'brainbase-owner-audit-contract-v1',
|
|
1221
1228
|
repair_body_policy: 'preserve',
|
|
@@ -1519,6 +1526,108 @@ async function autonomyStopSnapshot(payload, env, expectedHostBinding = DEFAULT_
|
|
|
1519
1526
|
};
|
|
1520
1527
|
});
|
|
1521
1528
|
}
|
|
1529
|
+
async function evaluateTaskProgressStop(payload, env, options) {
|
|
1530
|
+
const { sessionRef, turnId } = hookIdentity(payload);
|
|
1531
|
+
const paths = journalPaths(sessionRef, turnId, env);
|
|
1532
|
+
return withTurnLock(paths.lock, async () => {
|
|
1533
|
+
let episode;
|
|
1534
|
+
try {
|
|
1535
|
+
episode = readEpisode(paths.episode);
|
|
1536
|
+
}
|
|
1537
|
+
catch (error) {
|
|
1538
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
|
|
1539
|
+
throw new Error('judgment_orphan_stop');
|
|
1540
|
+
}
|
|
1541
|
+
throw error;
|
|
1542
|
+
}
|
|
1543
|
+
verifyEpisodeAdoption(episode, paths.target, options.expectedHostBinding);
|
|
1544
|
+
if (!episode.task_progress_scope)
|
|
1545
|
+
return null;
|
|
1546
|
+
const scope = taskProgressScopeSchema.parse(episode.task_progress_scope);
|
|
1547
|
+
const adapter = options.taskProgress;
|
|
1548
|
+
if (!adapter || canonicalJson(taskProgressScopeSchema.parse(adapter.scope)) !== canonicalJson(scope)) {
|
|
1549
|
+
throw new Error('judgment_task_progress_binding_changed');
|
|
1550
|
+
}
|
|
1551
|
+
try {
|
|
1552
|
+
readFinal(paths.final);
|
|
1553
|
+
return null;
|
|
1554
|
+
}
|
|
1555
|
+
catch (error) {
|
|
1556
|
+
if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT'))
|
|
1557
|
+
throw error;
|
|
1558
|
+
}
|
|
1559
|
+
const events = readEvents(paths.events);
|
|
1560
|
+
const snapshot = {
|
|
1561
|
+
episode_digest: episode.episode_digest,
|
|
1562
|
+
event_set_digest: sha256(canonicalJson(events)),
|
|
1563
|
+
request: episode.adoption.request.request,
|
|
1564
|
+
events
|
|
1565
|
+
};
|
|
1566
|
+
const scopeRef = sha256(canonicalJson(scope));
|
|
1567
|
+
const directory = join(journalRoot(env), 'task-progress', scopeRef);
|
|
1568
|
+
return withTurnLock(`${directory}.lock`, async () => {
|
|
1569
|
+
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
1570
|
+
const entries = readdirSync(directory).sort().map((name) => {
|
|
1571
|
+
const entry = readJsonArtifact(join(directory, name));
|
|
1572
|
+
if (entry.entry_digest !== artifactDigest(entry, 'entry_digest')) {
|
|
1573
|
+
throw new Error('judgment_task_progress_journal_corrupt');
|
|
1574
|
+
}
|
|
1575
|
+
return entry;
|
|
1576
|
+
});
|
|
1577
|
+
let preparationCount = 0;
|
|
1578
|
+
let previousDigest = null;
|
|
1579
|
+
for (const entry of entries) {
|
|
1580
|
+
if (entry.scope_ref !== scopeRef || entry.previous_digest !== previousDigest) {
|
|
1581
|
+
throw new Error('judgment_task_progress_chain_corrupt');
|
|
1582
|
+
}
|
|
1583
|
+
const observation = taskProgressObservationSchema.parse(entry.observation);
|
|
1584
|
+
if (observation.kind === 'preparation_only')
|
|
1585
|
+
preparationCount += 1;
|
|
1586
|
+
if (observation.kind === 'verified_outcome')
|
|
1587
|
+
preparationCount = 0;
|
|
1588
|
+
previousDigest = entry.entry_digest;
|
|
1589
|
+
}
|
|
1590
|
+
const snapshotRef = sha256(canonicalJson({ episode: snapshot.episode_digest, events: snapshot.event_set_digest }));
|
|
1591
|
+
const replay = entries.find((entry) => entry.snapshot_ref === snapshotRef);
|
|
1592
|
+
if (replay) {
|
|
1593
|
+
if (replay.replan_required !== true)
|
|
1594
|
+
return null;
|
|
1595
|
+
throw new Error('judgment_task_progress_replan_requires_new_evidence');
|
|
1596
|
+
}
|
|
1597
|
+
const successfulIds = new Set(events.filter((event) => event.success).map((event) => event.tool_use_id));
|
|
1598
|
+
const observation = taskProgressObservationSchema.parse(await adapter.assess(snapshot));
|
|
1599
|
+
if (observation.kind !== 'waiting'
|
|
1600
|
+
&& !observation.evidence_tool_use_ids.every((id) => successfulIds.has(id))) {
|
|
1601
|
+
throw new Error('judgment_task_progress_evidence_not_in_episode');
|
|
1602
|
+
}
|
|
1603
|
+
if (observation.kind === 'verified_outcome') {
|
|
1604
|
+
if (entries.some((entry) => {
|
|
1605
|
+
const prior = taskProgressObservationSchema.parse(entry.observation);
|
|
1606
|
+
return prior.kind === 'verified_outcome' && prior.verification_ref === observation.verification_ref;
|
|
1607
|
+
}))
|
|
1608
|
+
throw new Error('judgment_task_progress_outcome_repeated');
|
|
1609
|
+
if (!await adapter.verifyOutcome({ ...snapshot, observation })) {
|
|
1610
|
+
throw new Error('judgment_task_progress_outcome_unverified');
|
|
1611
|
+
}
|
|
1612
|
+
preparationCount = 0;
|
|
1613
|
+
}
|
|
1614
|
+
if (observation.kind === 'preparation_only')
|
|
1615
|
+
preparationCount += 1;
|
|
1616
|
+
const replanRequired = observation.kind === 'preparation_only' && preparationCount >= 2;
|
|
1617
|
+
const entry = {
|
|
1618
|
+
scope_ref: scopeRef, snapshot_ref: snapshotRef, previous_digest: previousDigest,
|
|
1619
|
+
observation, replan_required: replanRequired
|
|
1620
|
+
};
|
|
1621
|
+
writeImmutableJson(join(directory, `${String(entries.length + 1).padStart(8, '0')}.json`), {
|
|
1622
|
+
...entry, entry_digest: sha256(canonicalJson(entry))
|
|
1623
|
+
});
|
|
1624
|
+
return replanRequired ? {
|
|
1625
|
+
decision: 'block', block_kind: 'semantic_replan',
|
|
1626
|
+
reason: '同じ完了条件について準備だけの反復を検出しました。資料を増やす継続を止め、業務成果または新しい否定結果を検証できる方針へ切り替えてください。完了・本人受入とは扱いません。'
|
|
1627
|
+
} : null;
|
|
1628
|
+
});
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1522
1631
|
async function evaluateAutonomyStop(payload, env, options) {
|
|
1523
1632
|
const config = resolveAutonomyMode(options, env);
|
|
1524
1633
|
if (config.mode === 'off')
|
|
@@ -1804,6 +1913,9 @@ export async function processJudgmentHook(payload, options = {}) {
|
|
|
1804
1913
|
return event ? { systemMessage: event.display_line } : {};
|
|
1805
1914
|
}
|
|
1806
1915
|
if (eventName === 'Stop') {
|
|
1916
|
+
const progressBlock = await evaluateTaskProgressStop(payload, env, options);
|
|
1917
|
+
if (progressBlock)
|
|
1918
|
+
return progressBlock;
|
|
1807
1919
|
const autonomyBlock = await evaluateAutonomyStop(payload, env, options);
|
|
1808
1920
|
if (autonomyBlock)
|
|
1809
1921
|
return autonomyBlock;
|