@telora/daemon 0.15.24 → 0.15.26
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/build-info.json +2 -2
- package/dist/ai-inspection-context.d.ts +7 -0
- package/dist/ai-inspection-context.d.ts.map +1 -1
- package/dist/ai-inspection-context.js +79 -0
- package/dist/ai-inspection-context.js.map +1 -1
- package/dist/ai-inspection-runner.d.ts.map +1 -1
- package/dist/ai-inspection-runner.js +1 -0
- package/dist/ai-inspection-runner.js.map +1 -1
- package/dist/assembly-resolvers.js +270 -12
- package/dist/assembly-resolvers.js.map +1 -1
- package/dist/focus-completion.d.ts.map +1 -1
- package/dist/focus-completion.js +1 -0
- package/dist/focus-completion.js.map +1 -1
- package/dist/queries/deliveries.d.ts.map +1 -1
- package/dist/queries/deliveries.js +1 -0
- package/dist/queries/deliveries.js.map +1 -1
- package/dist/queries/focuses.d.ts.map +1 -1
- package/dist/queries/focuses.js +1 -0
- package/dist/queries/focuses.js.map +1 -1
- package/dist/queries/schemas.d.ts +4 -0
- package/dist/queries/schemas.d.ts.map +1 -1
- package/dist/queries/schemas.js +2 -0
- package/dist/queries/schemas.js.map +1 -1
- package/dist/trigger-executor.d.ts +28 -0
- package/dist/trigger-executor.d.ts.map +1 -1
- package/dist/trigger-executor.js +84 -0
- package/dist/trigger-executor.js.map +1 -1
- package/dist/types/delivery.d.ts +5 -0
- package/dist/types/delivery.d.ts.map +1 -1
- package/dist/types/focus.d.ts +1 -0
- package/dist/types/focus.d.ts.map +1 -1
- package/package.json +2 -2
package/build-info.json
CHANGED
|
@@ -35,6 +35,13 @@ export interface AiInspectionInputs {
|
|
|
35
35
|
deliveryDiff: string;
|
|
36
36
|
/** Worktree CWD for spawning Read/Grep — null if unresolved. */
|
|
37
37
|
worktreePath: string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Pre-rendered "Previously dismissed drift proposals for this focus" markdown
|
|
40
|
+
* section. Empty string when there are no dismissals OR when the fetch
|
|
41
|
+
* failed (fail-soft). Empty-case choice: section ABSENT (we render no header
|
|
42
|
+
* at all), keeping the prompt tight and consistent with crtDumpMarkdown.
|
|
43
|
+
*/
|
|
44
|
+
dismissedProposalsSection: string;
|
|
38
45
|
}
|
|
39
46
|
export interface AiInspectionContextDeps {
|
|
40
47
|
callApi: typeof callApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-inspection-context.d.ts","sourceRoot":"","sources":["../src/ai-inspection-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"ai-inspection-context.d.ts","sourceRoot":"","sources":["../src/ai-inspection-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAuBrE,MAAM,WAAW,sBAAsB;IACrC,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,uEAAuE;IACvE,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,8DAA8D;IAC9D,SAAS,EAAE,sBAAsB,CAAC;IAClC,yDAAyD;IACzD,eAAe,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,YAAY,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;;;OAKG;IACH,yBAAyB,EAAE,MAAM,CAAC;CACnC;AAwFD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,wDAAwD;IACxD,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,KAAK,MAAM,CAAC;IACjD,0CAA0C;IAC1C,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAyED;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC7C,CAAC,EAAE,mBAAmB,EACtB,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAwCpC"}
|
|
@@ -15,6 +15,78 @@
|
|
|
15
15
|
* @module ai-inspection-context
|
|
16
16
|
*/
|
|
17
17
|
import { CRT_DUMP_BUDGET_CHARS, getGitDiff, renderRealityTreeDump, } from './assembly-resolvers.js';
|
|
18
|
+
/** Max number of previously-dismissed drift proposals to surface in the audit-gate prompt. */
|
|
19
|
+
const MAX_DISMISSED_PROPOSALS_IN_PROMPT = 20;
|
|
20
|
+
/** Per-field truncation cap for dismissed proposal strings (observedState, proposedCorrection). */
|
|
21
|
+
const DISMISSED_PROPOSAL_TRUNCATION_CHARS = 500;
|
|
22
|
+
/** Instruction the audit-gate AI is shown alongside the dismissed-proposal list. */
|
|
23
|
+
const DISMISSED_PROPOSALS_INSTRUCTION = "When you would propose drift that matches one of these dismissed proposals, " +
|
|
24
|
+
"either suppress the proposal or include 'Re-proposing despite prior dismissal because [reason]' in observedState.";
|
|
25
|
+
function truncate(value, max) {
|
|
26
|
+
if (value.length <= max)
|
|
27
|
+
return value;
|
|
28
|
+
// Reserve room for the ellipsis indicator so the rendered field stays
|
|
29
|
+
// <= max (the test allows a modest margin for the indicator).
|
|
30
|
+
return value.slice(0, max - 3) + '...';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Render the dismissed-proposal markdown section. Returns '' when there are
|
|
34
|
+
* no dismissals so the caller can simply omit the section (empty-case choice
|
|
35
|
+
* documented on AiInspectionInputs.dismissedProposalsSection).
|
|
36
|
+
*/
|
|
37
|
+
function renderDismissedProposalsSection(rows) {
|
|
38
|
+
if (rows.length === 0)
|
|
39
|
+
return '';
|
|
40
|
+
const entries = rows.slice(0, MAX_DISMISSED_PROPOSALS_IN_PROMPT).map((row, idx) => {
|
|
41
|
+
const observed = truncate(row.observedState ?? '', DISMISSED_PROPOSAL_TRUNCATION_CHARS);
|
|
42
|
+
const correction = truncate(row.proposedCorrection ?? '', DISMISSED_PROPOSAL_TRUNCATION_CHARS);
|
|
43
|
+
return [
|
|
44
|
+
`### ${idx + 1}. ${row.proposalKind} (${row.createdAt})`,
|
|
45
|
+
'',
|
|
46
|
+
'**observedState:**',
|
|
47
|
+
observed,
|
|
48
|
+
'',
|
|
49
|
+
'**proposedCorrection:**',
|
|
50
|
+
correction,
|
|
51
|
+
].join('\n');
|
|
52
|
+
});
|
|
53
|
+
return [
|
|
54
|
+
'## Previously dismissed drift proposals for this focus',
|
|
55
|
+
'',
|
|
56
|
+
DISMISSED_PROPOSALS_INSTRUCTION,
|
|
57
|
+
'',
|
|
58
|
+
...entries,
|
|
59
|
+
].join('\n');
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Fetch previously-dismissed drift proposals for the focus and render them
|
|
63
|
+
* as a markdown section. Fail-soft: on any error, log via console.warn and
|
|
64
|
+
* return '' so the rest of the prompt is unaffected.
|
|
65
|
+
*/
|
|
66
|
+
async function fetchDismissedProposalsSection(deps, focusId) {
|
|
67
|
+
try {
|
|
68
|
+
const resp = await deps.callApi('crt_drift_proposal_list', {
|
|
69
|
+
focusId,
|
|
70
|
+
status: 'dismissed',
|
|
71
|
+
});
|
|
72
|
+
const items = resp.items ?? [];
|
|
73
|
+
// The list endpoint already orders by created_at DESC; cap client-side
|
|
74
|
+
// in case the server returns more than our prompt budget.
|
|
75
|
+
const rows = items
|
|
76
|
+
.slice(0, MAX_DISMISSED_PROPOSALS_IN_PROMPT)
|
|
77
|
+
.map(row => ({
|
|
78
|
+
createdAt: row.createdAt,
|
|
79
|
+
proposalKind: row.proposalKind,
|
|
80
|
+
observedState: row.observedState,
|
|
81
|
+
proposedCorrection: row.proposedCorrection,
|
|
82
|
+
}));
|
|
83
|
+
return renderDismissedProposalsSection(rows);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
console.warn('[ai-inspection-context] dismissed-proposals fetch failed:', err);
|
|
87
|
+
return '';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
18
90
|
/**
|
|
19
91
|
* Fetch the injection node directly. Returns frtStatement (falling back to
|
|
20
92
|
* the CRT statement when no overlay is set so the runner always has a
|
|
@@ -93,6 +165,12 @@ export async function resolveAiInspectionInputs(v, deps) {
|
|
|
93
165
|
console.warn(`[ai-inspection-context] CRT dump fetch failed for focus ${v.focusId}: ${err.message}`);
|
|
94
166
|
}
|
|
95
167
|
}
|
|
168
|
+
let dismissedProposalsSection = '';
|
|
169
|
+
if (v.focusId) {
|
|
170
|
+
// fetchDismissedProposalsSection is fail-soft internally; it returns ''
|
|
171
|
+
// on error so the rest of the prompt is unaffected.
|
|
172
|
+
dismissedProposalsSection = await fetchDismissedProposalsSection(deps, v.focusId);
|
|
173
|
+
}
|
|
96
174
|
let deliveryDiff = '';
|
|
97
175
|
try {
|
|
98
176
|
deliveryDiff = getGitDiff(worktreePath, deps.integrationBranch);
|
|
@@ -105,6 +183,7 @@ export async function resolveAiInspectionInputs(v, deps) {
|
|
|
105
183
|
crtDumpMarkdown,
|
|
106
184
|
deliveryDiff,
|
|
107
185
|
worktreePath,
|
|
186
|
+
dismissedProposalsSection,
|
|
108
187
|
};
|
|
109
188
|
}
|
|
110
189
|
//# sourceMappingURL=ai-inspection-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-inspection-context.js","sourceRoot":"","sources":["../src/ai-inspection-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,qBAAqB,GAOtB,MAAM,yBAAy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D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,KAAK,YAAY,CAAC;IACzE,uDAAuD;IACvD,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,UAAU,SAAS;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AA0DD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAsDxE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,CAa1F;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,kBAAkB,EAC1B,IAAI,GAAE,aAAkB,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAqF3B"}
|
|
@@ -61,6 +61,7 @@ function buildSystemPrompt(inputs) {
|
|
|
61
61
|
`## CRT Original Statement (pre-injection)\n\n${inputs.injection.crtStatement}\n`,
|
|
62
62
|
dissolves,
|
|
63
63
|
inputs.crtDumpMarkdown ? `${inputs.crtDumpMarkdown}\n` : '',
|
|
64
|
+
inputs.dismissedProposalsSection ? `${inputs.dismissedProposalsSection}\n` : '',
|
|
64
65
|
].filter(Boolean).join('\n');
|
|
65
66
|
}
|
|
66
67
|
function buildUserMessage(inputs) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-inspection-runner.js","sourceRoot":"","sources":["../src/ai-inspection-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,KAAK,EA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,CAAC;QAEH,IAAI,CAAC;YACH,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;YAChC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC;QACrB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC;gBACN,OAAO,EAAE,cAAc;gBACvB,SAAS,EAAE,qCAAsC,GAAa,CAAC,OAAO,EAAE;gBACxE,iBAAiB,EAAE,EAAE;aACtB,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1005,17 +1005,275 @@ registerSourceResolver('focus.reality_tree', async (context) => {
|
|
|
1005
1005
|
return '';
|
|
1006
1006
|
}
|
|
1007
1007
|
});
|
|
1008
|
-
// ──
|
|
1008
|
+
// ── Per-delivery FRT context resolvers (loop.*) ─────────────────────
|
|
1009
1009
|
//
|
|
1010
|
-
//
|
|
1011
|
-
//
|
|
1012
|
-
//
|
|
1013
|
-
//
|
|
1014
|
-
//
|
|
1015
|
-
//
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1010
|
+
// These resolvers operate per-delivery: they look up each delivery in
|
|
1011
|
+
// context.deliveryIds, follow its delivery.injection_id to the
|
|
1012
|
+
// reality-tree injection node, and render the surrounding FRT context
|
|
1013
|
+
// the agent needs to know "what FRT statement this delivery is meant
|
|
1014
|
+
// to flip, and which UDEs flip upstream as a result."
|
|
1015
|
+
//
|
|
1016
|
+
// All resolvers fail-soft: errors return '' and log to console.warn.
|
|
1017
|
+
// When a delivery has no injection link (injectionId is null/empty),
|
|
1018
|
+
// it contributes nothing to the output -- the resolver returns ''
|
|
1019
|
+
// rather than rendering an empty section.
|
|
1020
|
+
/** Maximum BFS depth for upstream UDE walk in loop.upstream_udes. */
|
|
1021
|
+
const MAX_UPSTREAM_DEPTH = 3;
|
|
1022
|
+
/**
|
|
1023
|
+
* Walk context.deliveryIds, return [deliveryId, injectionId] pairs for those
|
|
1024
|
+
* with non-empty injection links. Empty array on lookup failure.
|
|
1025
|
+
*/
|
|
1026
|
+
async function getDeliveryInjectionPairs(context) {
|
|
1027
|
+
const deliveries = await getFocusDeliveries(context.focusId);
|
|
1028
|
+
const wantedIds = new Set(context.deliveryIds);
|
|
1029
|
+
return deliveries
|
|
1030
|
+
.filter((d) => wantedIds.has(d.id))
|
|
1031
|
+
.filter((d) => typeof d.injectionId === 'string' && d.injectionId.length > 0)
|
|
1032
|
+
.map((d) => ({ deliveryId: d.id, deliveryName: d.name, injectionId: d.injectionId }));
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Fetch a batch of injection nodes by their IDs via reality_tree_injection_context.
|
|
1036
|
+
* Returns a Map keyed by injection node id.
|
|
1037
|
+
*/
|
|
1038
|
+
async function fetchInjectionBundles(injectionIds) {
|
|
1039
|
+
const out = new Map();
|
|
1040
|
+
if (injectionIds.length === 0)
|
|
1041
|
+
return out;
|
|
1042
|
+
const resp = await callApi('reality_tree_injection_context', {
|
|
1043
|
+
nodeIds: injectionIds,
|
|
1044
|
+
});
|
|
1045
|
+
for (const item of resp.items ?? []) {
|
|
1046
|
+
out.set(item.injection.id, item);
|
|
1047
|
+
}
|
|
1048
|
+
return out;
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* loop.injection
|
|
1052
|
+
*
|
|
1053
|
+
* For each delivery in context.deliveryIds with a linked injection, render
|
|
1054
|
+
* the injection node: statement, lifecycle status, what obstacle it
|
|
1055
|
+
* dissolves. Plain markdown; no upstream/downstream walk (that lives in
|
|
1056
|
+
* loop.upstream_udes / loop.expected_effects).
|
|
1057
|
+
*/
|
|
1058
|
+
registerSourceResolver('loop.injection', async (context) => {
|
|
1059
|
+
try {
|
|
1060
|
+
const pairs = await getDeliveryInjectionPairs(context);
|
|
1061
|
+
if (pairs.length === 0)
|
|
1062
|
+
return '';
|
|
1063
|
+
const bundles = await fetchInjectionBundles(pairs.map((p) => p.injectionId));
|
|
1064
|
+
if (bundles.size === 0)
|
|
1065
|
+
return '';
|
|
1066
|
+
const sections = [];
|
|
1067
|
+
for (const { deliveryName, injectionId } of pairs) {
|
|
1068
|
+
const bundle = bundles.get(injectionId);
|
|
1069
|
+
if (!bundle)
|
|
1070
|
+
continue;
|
|
1071
|
+
const inj = bundle.injection;
|
|
1072
|
+
const statusTag = inj.injectionStatus ? ` [${inj.injectionStatus}]` : '';
|
|
1073
|
+
const dissolvesLine = inj.dissolvesObstacle
|
|
1074
|
+
? `- **Dissolves obstacle:** ${inj.dissolvesObstacle}`
|
|
1075
|
+
: null;
|
|
1076
|
+
const lines = [
|
|
1077
|
+
`### ${deliveryName}`,
|
|
1078
|
+
'',
|
|
1079
|
+
`- **Injection:** ${inj.statement}${statusTag}`,
|
|
1080
|
+
`- **Injection status:** ${inj.injectionStatus ?? '_not set_'}`,
|
|
1081
|
+
];
|
|
1082
|
+
if (dissolvesLine)
|
|
1083
|
+
lines.push(dissolvesLine);
|
|
1084
|
+
sections.push(lines.join('\n'));
|
|
1085
|
+
}
|
|
1086
|
+
if (sections.length === 0)
|
|
1087
|
+
return '';
|
|
1088
|
+
return `## Loop Injection (per delivery)\n\n${sections.join('\n\n')}`;
|
|
1089
|
+
}
|
|
1090
|
+
catch (err) {
|
|
1091
|
+
console.warn(`[assembly] loop.injection failed: ${err.message}`);
|
|
1092
|
+
return '';
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
1095
|
+
/**
|
|
1096
|
+
* loop.frt_statement
|
|
1097
|
+
*
|
|
1098
|
+
* Returns the linked injection's frt_statement field as plain text
|
|
1099
|
+
* (no markdown headers). When multiple deliveries are in scope, the
|
|
1100
|
+
* statements are joined with blank lines so the agent sees each
|
|
1101
|
+
* delivery's target state. Empty string when no delivery has an
|
|
1102
|
+
* injection link or no injection has an FRT statement set.
|
|
1103
|
+
*/
|
|
1104
|
+
registerSourceResolver('loop.frt_statement', async (context) => {
|
|
1105
|
+
try {
|
|
1106
|
+
const pairs = await getDeliveryInjectionPairs(context);
|
|
1107
|
+
if (pairs.length === 0)
|
|
1108
|
+
return '';
|
|
1109
|
+
const bundles = await fetchInjectionBundles(pairs.map((p) => p.injectionId));
|
|
1110
|
+
if (bundles.size === 0)
|
|
1111
|
+
return '';
|
|
1112
|
+
const lines = [];
|
|
1113
|
+
for (const { injectionId } of pairs) {
|
|
1114
|
+
const bundle = bundles.get(injectionId);
|
|
1115
|
+
if (!bundle)
|
|
1116
|
+
continue;
|
|
1117
|
+
const frt = bundle.injection.frtStatement;
|
|
1118
|
+
if (typeof frt !== 'string' || frt.trim().length === 0)
|
|
1119
|
+
continue;
|
|
1120
|
+
lines.push(frt.trim());
|
|
1121
|
+
}
|
|
1122
|
+
if (lines.length === 0)
|
|
1123
|
+
return '';
|
|
1124
|
+
return lines.join('\n\n');
|
|
1125
|
+
}
|
|
1126
|
+
catch (err) {
|
|
1127
|
+
console.warn(`[assembly] loop.frt_statement failed: ${err.message}`);
|
|
1128
|
+
return '';
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
/**
|
|
1132
|
+
* loop.expected_effects
|
|
1133
|
+
*
|
|
1134
|
+
* For each delivery with a linked injection, walk the 'targets' edges
|
|
1135
|
+
* from injection -> targeted UDE/obstacle nodes; for each target with an
|
|
1136
|
+
* FRT overlay (frt_statement and/or frt_node_type), render its current
|
|
1137
|
+
* statement and what it becomes in the FRT. Targets lacking overlays are
|
|
1138
|
+
* skipped (no expected effect to advertise).
|
|
1139
|
+
*/
|
|
1140
|
+
registerSourceResolver('loop.expected_effects', async (context) => {
|
|
1141
|
+
try {
|
|
1142
|
+
const pairs = await getDeliveryInjectionPairs(context);
|
|
1143
|
+
if (pairs.length === 0)
|
|
1144
|
+
return '';
|
|
1145
|
+
const bundles = await fetchInjectionBundles(pairs.map((p) => p.injectionId));
|
|
1146
|
+
if (bundles.size === 0)
|
|
1147
|
+
return '';
|
|
1148
|
+
const sections = [];
|
|
1149
|
+
for (const { deliveryName, injectionId } of pairs) {
|
|
1150
|
+
const bundle = bundles.get(injectionId);
|
|
1151
|
+
if (!bundle)
|
|
1152
|
+
continue;
|
|
1153
|
+
// Fetch nodes + edges for this injection's tree so we can walk
|
|
1154
|
+
// targets edges and inspect the targeted nodes' overlays.
|
|
1155
|
+
const treeId = bundle.injection.realityTreeId;
|
|
1156
|
+
const [nodesResp, edgesResp] = await Promise.all([
|
|
1157
|
+
callApi('reality_tree_node_list', { treeId, status: 'active' }),
|
|
1158
|
+
callApi('reality_tree_edge_list', { treeId }),
|
|
1159
|
+
]);
|
|
1160
|
+
const nodes = nodesResp.items ?? [];
|
|
1161
|
+
const edges = edgesResp.items ?? [];
|
|
1162
|
+
const nodeById = new Map();
|
|
1163
|
+
for (const n of nodes)
|
|
1164
|
+
nodeById.set(n.id, n);
|
|
1165
|
+
const targetIds = edges
|
|
1166
|
+
.filter((e) => e.edgeType === 'targets' && e.fromNodeId === injectionId)
|
|
1167
|
+
.map((e) => e.toNodeId);
|
|
1168
|
+
const targetLines = [];
|
|
1169
|
+
for (const targetId of targetIds) {
|
|
1170
|
+
const node = nodeById.get(targetId);
|
|
1171
|
+
if (!node)
|
|
1172
|
+
continue;
|
|
1173
|
+
const hasOverlay = (node.frtStatement && node.frtStatement.trim().length > 0)
|
|
1174
|
+
|| (node.frtNodeType && node.frtNodeType.trim().length > 0);
|
|
1175
|
+
if (!hasOverlay)
|
|
1176
|
+
continue;
|
|
1177
|
+
const currentType = node.nodeType;
|
|
1178
|
+
const frtType = node.frtNodeType ?? currentType;
|
|
1179
|
+
const frtStatement = node.frtStatement ?? node.statement;
|
|
1180
|
+
targetLines.push(`- #${node.seq} **Current (${currentType}):** ${node.statement}\n **FRT (${frtType}):** ${frtStatement}`);
|
|
1181
|
+
}
|
|
1182
|
+
if (targetLines.length === 0)
|
|
1183
|
+
continue;
|
|
1184
|
+
sections.push(`### ${deliveryName}\n\n${targetLines.join('\n')}`);
|
|
1185
|
+
}
|
|
1186
|
+
if (sections.length === 0)
|
|
1187
|
+
return '';
|
|
1188
|
+
return `## Expected Effects (per delivery)\n\n${sections.join('\n\n')}`;
|
|
1189
|
+
}
|
|
1190
|
+
catch (err) {
|
|
1191
|
+
console.warn(`[assembly] loop.expected_effects failed: ${err.message}`);
|
|
1192
|
+
return '';
|
|
1193
|
+
}
|
|
1194
|
+
});
|
|
1195
|
+
/**
|
|
1196
|
+
* loop.upstream_udes
|
|
1197
|
+
*
|
|
1198
|
+
* For each delivery's injection, find the nodes that the injection
|
|
1199
|
+
* targets (via 'targets' edges), then BFS upstream from those targets
|
|
1200
|
+
* along causal edges ('sufficient' and 'and' edge kinds) up to
|
|
1201
|
+
* MAX_UPSTREAM_DEPTH hops. Returns a markdown list of upstream UDE/
|
|
1202
|
+
* entity nodes the injection is indirectly meant to address. Cycle-safe.
|
|
1203
|
+
*/
|
|
1204
|
+
registerSourceResolver('loop.upstream_udes', async (context) => {
|
|
1205
|
+
try {
|
|
1206
|
+
const pairs = await getDeliveryInjectionPairs(context);
|
|
1207
|
+
if (pairs.length === 0)
|
|
1208
|
+
return '';
|
|
1209
|
+
const bundles = await fetchInjectionBundles(pairs.map((p) => p.injectionId));
|
|
1210
|
+
if (bundles.size === 0)
|
|
1211
|
+
return '';
|
|
1212
|
+
const sections = [];
|
|
1213
|
+
for (const { deliveryName, injectionId } of pairs) {
|
|
1214
|
+
const bundle = bundles.get(injectionId);
|
|
1215
|
+
if (!bundle)
|
|
1216
|
+
continue;
|
|
1217
|
+
const treeId = bundle.injection.realityTreeId;
|
|
1218
|
+
const [nodesResp, edgesResp] = await Promise.all([
|
|
1219
|
+
callApi('reality_tree_node_list', { treeId, status: 'active' }),
|
|
1220
|
+
callApi('reality_tree_edge_list', { treeId }),
|
|
1221
|
+
]);
|
|
1222
|
+
const nodes = nodesResp.items ?? [];
|
|
1223
|
+
const edges = edgesResp.items ?? [];
|
|
1224
|
+
const nodeById = new Map();
|
|
1225
|
+
for (const n of nodes)
|
|
1226
|
+
nodeById.set(n.id, n);
|
|
1227
|
+
// Seed: the nodes the injection targets directly.
|
|
1228
|
+
const seeds = edges
|
|
1229
|
+
.filter((e) => e.edgeType === 'targets' && e.fromNodeId === injectionId)
|
|
1230
|
+
.map((e) => e.toNodeId);
|
|
1231
|
+
if (seeds.length === 0)
|
|
1232
|
+
continue;
|
|
1233
|
+
// BFS upstream along causal edges: walk edges where to_node_id is
|
|
1234
|
+
// in the current frontier; the from_node_id of those edges is the
|
|
1235
|
+
// upstream node. Bounded by MAX_UPSTREAM_DEPTH and cycle-safe via
|
|
1236
|
+
// visited set. Seeds themselves are excluded from output (we want
|
|
1237
|
+
// their upstream, not the seeds).
|
|
1238
|
+
const visited = new Set(seeds);
|
|
1239
|
+
const collected = [];
|
|
1240
|
+
let frontier = new Set(seeds);
|
|
1241
|
+
for (let depth = 0; depth < MAX_UPSTREAM_DEPTH; depth++) {
|
|
1242
|
+
if (frontier.size === 0)
|
|
1243
|
+
break;
|
|
1244
|
+
const next = new Set();
|
|
1245
|
+
for (const edge of edges) {
|
|
1246
|
+
if (edge.edgeType !== 'sufficient' && edge.edgeType !== 'and')
|
|
1247
|
+
continue;
|
|
1248
|
+
if (!frontier.has(edge.toNodeId))
|
|
1249
|
+
continue;
|
|
1250
|
+
const upId = edge.fromNodeId;
|
|
1251
|
+
if (visited.has(upId))
|
|
1252
|
+
continue;
|
|
1253
|
+
visited.add(upId);
|
|
1254
|
+
next.add(upId);
|
|
1255
|
+
const upNode = nodeById.get(upId);
|
|
1256
|
+
if (upNode)
|
|
1257
|
+
collected.push(upNode);
|
|
1258
|
+
}
|
|
1259
|
+
frontier = next;
|
|
1260
|
+
}
|
|
1261
|
+
if (collected.length === 0)
|
|
1262
|
+
continue;
|
|
1263
|
+
collected.sort((a, b) => a.seq - b.seq);
|
|
1264
|
+
const lines = collected.map((n) => {
|
|
1265
|
+
const typeTag = n.nodeType !== 'entity' ? ` [${n.nodeType}]` : '';
|
|
1266
|
+
return `- #${n.seq} ${n.statement}${typeTag}`;
|
|
1267
|
+
});
|
|
1268
|
+
sections.push(`### ${deliveryName}\n\n${lines.join('\n')}`);
|
|
1269
|
+
}
|
|
1270
|
+
if (sections.length === 0)
|
|
1271
|
+
return '';
|
|
1272
|
+
return `## Upstream UDEs (per delivery, max depth ${MAX_UPSTREAM_DEPTH})\n\n${sections.join('\n\n')}`;
|
|
1273
|
+
}
|
|
1274
|
+
catch (err) {
|
|
1275
|
+
console.warn(`[assembly] loop.upstream_udes failed: ${err.message}`);
|
|
1276
|
+
return '';
|
|
1277
|
+
}
|
|
1278
|
+
});
|
|
1021
1279
|
//# sourceMappingURL=assembly-resolvers.js.map
|