wicked-crew 0.18.5 → 0.18.7
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/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +3 -1
- package/dist/api/routes.js.map +1 -1
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +9 -1
- package/dist/api/server.js.map +1 -1
- package/dist/cli/service.js +1 -1
- package/dist/cli/service.js.map +1 -1
- package/dist/core/adapter.d.ts +15 -0
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +18 -1
- package/dist/core/adapter.js.map +1 -1
- package/dist/core/exec.d.ts +3 -0
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js.map +1 -1
- package/dist/core/vault-bin.js +1 -1
- package/dist/core/vault-bin.js.map +1 -1
- package/dist/interactive/chat-events.js +1 -1
- package/dist/interactive/chat-events.js.map +1 -1
- package/dist/interactive/draft-events.js +1 -1
- package/dist/interactive/draft-events.js.map +1 -1
- package/dist/interactive/edit-events.js +1 -1
- package/dist/interactive/edit-events.js.map +1 -1
- package/dist/projects/auto-refresh.d.ts +6 -1
- package/dist/projects/auto-refresh.d.ts.map +1 -1
- package/dist/projects/auto-refresh.js +19 -3
- package/dist/projects/auto-refresh.js.map +1 -1
- package/dist/projects/graph.d.ts +27 -2
- package/dist/projects/graph.d.ts.map +1 -1
- package/dist/projects/graph.js +277 -8
- package/dist/projects/graph.js.map +1 -1
- package/dist/projects/repo-watch.d.ts +4 -1
- package/dist/projects/repo-watch.d.ts.map +1 -1
- package/dist/projects/repo-watch.js +89 -19
- package/dist/projects/repo-watch.js.map +1 -1
- package/endpoint-manifest.json +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-refresh.d.ts","sourceRoot":"","sources":["../../src/projects/auto-refresh.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"auto-refresh.d.ts","s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CAAC,CAmD7B"}
|
|
@@ -27,13 +27,20 @@
|
|
|
27
27
|
* onto the in-flight refresh of the same project (`refreshProjectGraph`'s single-writer rule).
|
|
28
28
|
* Coalescing has one gap: a completion that joins a refresh already past its repo is served a
|
|
29
29
|
* manifest without it — so when the repo is still missing afterwards the hook runs ONE more
|
|
30
|
-
* refresh, which finds only that repo to index. Never a third
|
|
30
|
+
* refresh, which finds only that repo to index. Never a third, and never after a member's index
|
|
31
|
+
* ran past its budget in the first (wicked-crew#1481): the second round would run that
|
|
32
|
+
* over-budget index again (its manifest row did not move), a full index budget per event. The
|
|
33
|
+
* repo watcher owes and retries the refresh, backed off, instead.
|
|
31
34
|
* - Every start / outcome / failure goes to the log; a failure never touches the run.
|
|
32
35
|
*/
|
|
33
36
|
import { refreshProjectGraph, refreshProjectGraphAfter } from './graph.js';
|
|
34
37
|
function message(err) {
|
|
35
38
|
return err instanceof Error ? err.message : String(err);
|
|
36
39
|
}
|
|
40
|
+
/** Some member's index ran past its budget: a second round would repeat it (this repo's, or a sibling's; codex r1). */
|
|
41
|
+
function anyTimedOut(result) {
|
|
42
|
+
return (result.repos ?? []).some((r) => r.action === 'failed' && r.timedOut === true);
|
|
43
|
+
}
|
|
37
44
|
/** Whether the refresh's answer shows `repoId` in the graph (indexed now, or skipped as already current). */
|
|
38
45
|
function holdsRepo(result, repoId) {
|
|
39
46
|
const row = (result.repos ?? []).find((r) => r.repoId === repoId);
|
|
@@ -59,14 +66,23 @@ export async function refreshProjectGraphsForRepo(adapter, repoId, deps) {
|
|
|
59
66
|
try {
|
|
60
67
|
let result = await refresh(projectId);
|
|
61
68
|
let rounds = 1;
|
|
62
|
-
if (!holdsRepo(result, repoId)) {
|
|
69
|
+
if (!holdsRepo(result, repoId) && !anyTimedOut(result)) {
|
|
63
70
|
// Coalesced onto a refresh that had already passed this repo: one more, which skips every
|
|
64
71
|
// unchanged member and indexes only what is missing.
|
|
65
72
|
result = await refresh(projectId);
|
|
66
73
|
rounds = 2;
|
|
67
74
|
}
|
|
68
75
|
const failed = result.failed.map((f) => f.label);
|
|
69
|
-
|
|
76
|
+
const linkFailed = result.link?.error ??
|
|
77
|
+
((result.link?.incomplete?.length ?? 0) > 0 ? `incomplete: ${result.link.incomplete.join(', ')}` : undefined);
|
|
78
|
+
out.refreshed.push({
|
|
79
|
+
projectId,
|
|
80
|
+
rounds,
|
|
81
|
+
indexed: result.indexed,
|
|
82
|
+
skipped: result.skipped,
|
|
83
|
+
failed,
|
|
84
|
+
...(linkFailed === undefined ? {} : { linkFailed }),
|
|
85
|
+
});
|
|
70
86
|
deps.log(`[projects] auto-refresh: project ${projectId} graph is ${result.status.state} ` +
|
|
71
87
|
`(indexed ${result.indexed.length}, skipped ${result.skipped.length}, failed ${failed.length}` +
|
|
72
88
|
`${rounds === 2 ? ', second round after a coalesced refresh missed the repo' : ''})`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-refresh.js","sourceRoot":"","sources":["../../src/projects/auto-refresh.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"auto-refresh.js","sourceRoot":"","sources":["../../src/projects/auto-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAIH,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAgC3E,SAAS,OAAO,CAAC,GAAY;IAC3B,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC;AAED,uHAAuH;AACvH,SAAS,WAAW,CAAC,MAAiC;IACpD,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,C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C,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;aACpD,CAAC,CAAC;YACH,IAAI,CAAC,GAAG,CACN,oCAAoC,SAAS,aAAa,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG;gBAC9E,YAAY,MAAM,CAAC,OAAO,CAAC,MAAM,aAAa,MAAM,CAAC,OAAO,CAAC,MAAM,YAAY,MAAM,CAAC,MAAM,EAAE;gBAC9F,GAAG,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,0DAA0D,CAAC,CAAC,CAAC,EAAE,GAAG,CACvF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,GAAG,CAAC,oCAAoC,SAAS,0BAA0B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClG,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/projects/graph.d.ts
CHANGED
|
@@ -39,9 +39,16 @@
|
|
|
39
39
|
* estate's own R3 rule exists to prevent, and it is the failure FINDING-069 actually shipped.
|
|
40
40
|
*/
|
|
41
41
|
import type { CoreAdapter } from '../core/adapter.js';
|
|
42
|
-
import type { ProjectBlastRadius, ProjectGraphAction, ProjectGraphHit, ProjectGraphRefreshResult, ProjectGraphRepoCount, ProjectGraphSearch, ProjectGraphStatus } from '../core/types.js';
|
|
42
|
+
import type { ProjectBlastRadius, ProjectGraphAction, ProjectGraphHit, ProjectGraphRefreshResult, ProjectGraphRefreshState, ProjectGraphRepoCount, ProjectGraphSearch, ProjectGraphStatus } from '../core/types.js';
|
|
43
43
|
/** The sentence every project-graph response carries. Stated on the wire, not just in this file. */
|
|
44
44
|
export declare const CO_LOCATION_NOTE: string;
|
|
45
|
+
/**
|
|
46
|
+
* The sentence an answer carries when it traversed a cross-repo package link (wicked-estate >= 0.34.0,
|
|
47
|
+
* slice X1): the crossings are proven from package identity and listed, the rest are per-repo hits.
|
|
48
|
+
*/
|
|
49
|
+
export declare const LINKED_NOTE: string;
|
|
50
|
+
/** Added to {@link LINKED_NOTE} when the project's link generation predates the current indexes. */
|
|
51
|
+
export declare const LINK_STALE_NOTE: string;
|
|
45
52
|
/**
|
|
46
53
|
* The second sentence `/graph/search` carries, and only it.
|
|
47
54
|
*
|
|
@@ -67,6 +74,18 @@ export declare function parseEstateTotals(stdout: string): {
|
|
|
67
74
|
edges: number;
|
|
68
75
|
files: number;
|
|
69
76
|
} | undefined;
|
|
77
|
+
/** `760035` → `12 min 40 s`; `6037500` → `1 h 40 min`: a budget in the words a person reads. */
|
|
78
|
+
export declare function formatBudget(ms: number): string;
|
|
79
|
+
/** Calls `fire` once `ms` have passed, in timer steps Node can hold; the returned function disarms it. */
|
|
80
|
+
export declare function armDeadline(ms: number, fire: () => void, maxStep?: number): () => void;
|
|
81
|
+
/** The project's refresh state, ABSENT when no refresh ran since the daemon started. */
|
|
82
|
+
export declare function projectGraphRefreshState(projectId: string): ProjectGraphRefreshState | undefined;
|
|
83
|
+
/** `diagnostics.projectGraphRefresh`: every project refreshed since the daemon started. */
|
|
84
|
+
export declare function projectGraphRefreshDiagnostics(): Array<{
|
|
85
|
+
projectId: string;
|
|
86
|
+
} & ProjectGraphRefreshState>;
|
|
87
|
+
/** Test seam: forget every refresh state. */
|
|
88
|
+
export declare function resetProjectGraphRefreshStates(): void;
|
|
70
89
|
/**
|
|
71
90
|
* Does the `wicked-estate` that will actually run support `--repo`?
|
|
72
91
|
*
|
|
@@ -75,6 +94,12 @@ export declare function parseEstateTotals(stdout: string): {
|
|
|
75
94
|
* likes. The usage banner is printed by the same binary that would do the indexing.
|
|
76
95
|
*/
|
|
77
96
|
export declare function estateSupportsMultiRepo(env?: NodeJS.ProcessEnv): Promise<boolean>;
|
|
97
|
+
/**
|
|
98
|
+
* Does the `wicked-estate` that will run support `link --project` (wicked-estate >= 0.34.0, slice X1)?
|
|
99
|
+
* Probed from `--help`, like `--repo`: an older binary has no `link`, and the refresh stays
|
|
100
|
+
* co-located.
|
|
101
|
+
*/
|
|
102
|
+
export declare function estateSupportsLink(env?: NodeJS.ProcessEnv): Promise<boolean>;
|
|
78
103
|
/**
|
|
79
104
|
* The evidence check failed: the binary took `--repo` and dropped it.
|
|
80
105
|
*
|
|
@@ -163,7 +188,7 @@ export interface ResolveBindingOptions {
|
|
|
163
188
|
*
|
|
164
189
|
* # This never indexes
|
|
165
190
|
*
|
|
166
|
-
* A refresh is `wicked-estate index` per member repo, bounded
|
|
191
|
+
* A refresh is `wicked-estate index` per member repo, bounded by its index budget EACH (#1481). Doing that
|
|
167
192
|
* inside a launch would turn "start a run" into an unannounced multi-repo indexing job that blocks
|
|
168
193
|
* the response, and the first thing an operator would learn about it is a request that appears to
|
|
169
194
|
* hang. So a missing or stale graph DEGRADES the run to the per-repo graph and says so; refreshing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/projects/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAMH,OAAO,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/projects/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,oBAAoB,CAAC;AAGnE,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAGlB,eAAe,EAEf,yBAAyB,EACzB,wBAAwB,EAExB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAEnB,MAAM,kBAAkB,CAAC;AAG1B,oGAAoG;AACpG,eAAO,MAAM,gBAAgB,QAEkE,CAAC;AAEh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CAuBlC;AAED,iGAAiG;AACjG,wBAAsB,kBAAkB,CACtC,CAAC,EAAE,OAAO,CAAC,SAAS,EAAE;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC,EACnC,IAAI,EAAE,MAAM,EACZ,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,kBAAkB,CAAC,CAmE7B;AAED;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,CAAC,EAAE,OAAO,CAAC,SAAS,EAAE;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC,EACnC,IAAI,EAAE,MAAM,EACZ,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,kBAAkB,CAAC,CAe7B"}
|
package/dist/projects/graph.js
CHANGED
|
@@ -47,6 +47,17 @@ import { projectGraphDb, projectGraphManifest, repoLabel } from './graph-paths.j
|
|
|
47
47
|
/** The sentence every project-graph response carries. Stated on the wire, not just in this file. */
|
|
48
48
|
export const CO_LOCATION_NOTE = 'Co-located, not linked: each repo is indexed under its own label and edges do not resolve ' +
|
|
49
49
|
'across repos. Results are per-repo hits gathered into one answer, never a cross-repo trace.';
|
|
50
|
+
/**
|
|
51
|
+
* The sentence an answer carries when it traversed a cross-repo package link (wicked-estate >= 0.34.0,
|
|
52
|
+
* slice X1): the crossings are proven from package identity and listed, the rest are per-repo hits.
|
|
53
|
+
*/
|
|
54
|
+
export const LINKED_NOTE = 'Linked: this answer crossed from one repo into another through package links that ' +
|
|
55
|
+
'wicked-estate proved from package identity (listed in `crossings`; each dependent reached ' +
|
|
56
|
+
'through one names it in `via_crossing`). Other hits are per-repo results, and a dependency the ' +
|
|
57
|
+
'linker could not prove is not followed.';
|
|
58
|
+
/** Added to {@link LINKED_NOTE} when the project's link generation predates the current indexes. */
|
|
59
|
+
export const LINK_STALE_NOTE = 'The links are from an earlier refresh and some repos changed since (`link_stale_labels`): ' +
|
|
60
|
+
'refresh the code graph to relink.';
|
|
50
61
|
/**
|
|
51
62
|
* The second sentence `/graph/search` carries, and only it.
|
|
52
63
|
*
|
|
@@ -77,9 +88,94 @@ export function parseEstateTotals(stdout) {
|
|
|
77
88
|
return undefined;
|
|
78
89
|
return { nodes: Number(m[1]), edges: Number(m[2]), files: Number(m[3]) };
|
|
79
90
|
}
|
|
80
|
-
/** Queries are interactive; a full repo index is not. Both are bounded — neither hangs the daemon.
|
|
91
|
+
/** Queries are interactive; a full repo index is not. Both are bounded — neither hangs the daemon. A member repo's
|
|
92
|
+
* index is bounded by its own index budget, sized by the ENGINE from its file count (`adapter.indexBudget`,
|
|
93
|
+
* wicked-crew#1481); this file keeps no copy of the formula. */
|
|
81
94
|
const QUERY_TIMEOUT_MS = 30_000;
|
|
82
|
-
|
|
95
|
+
/** `760035` → `12 min 40 s`; `6037500` → `1 h 40 min`: a budget in the words a person reads. */
|
|
96
|
+
export function formatBudget(ms) {
|
|
97
|
+
const total = Math.max(0, Math.round(ms / 1000));
|
|
98
|
+
const h = Math.floor(total / 3600);
|
|
99
|
+
const m = Math.floor((total % 3600) / 60);
|
|
100
|
+
const sec = total % 60;
|
|
101
|
+
if (h > 0)
|
|
102
|
+
return m > 0 ? `${h} h ${m} min` : `${h} h`;
|
|
103
|
+
if (m > 0)
|
|
104
|
+
return sec > 0 ? `${m} min ${sec} s` : `${m} min`;
|
|
105
|
+
return `${sec} s`;
|
|
106
|
+
}
|
|
107
|
+
/** Node's timers cap at 2^31 - 1 ms (24.8 days; a larger delay becomes 1 ms, codex r1): a longer deadline is chained. */
|
|
108
|
+
const NODE_TIMER_MAX_MS = 2_147_483_647;
|
|
109
|
+
/** Calls `fire` once `ms` have passed, in timer steps Node can hold; the returned function disarms it. */
|
|
110
|
+
export function armDeadline(ms, fire, maxStep = NODE_TIMER_MAX_MS) {
|
|
111
|
+
let timer;
|
|
112
|
+
let left = Math.max(0, ms);
|
|
113
|
+
const step = () => {
|
|
114
|
+
const now = Math.min(left, maxStep);
|
|
115
|
+
left -= now;
|
|
116
|
+
timer = setTimeout(left > 0 ? step : fire, now);
|
|
117
|
+
};
|
|
118
|
+
step();
|
|
119
|
+
return () => clearTimeout(timer);
|
|
120
|
+
}
|
|
121
|
+
/** A member's index ran past its budget: it was killed when the deadline fired, whatever it then exited with. */
|
|
122
|
+
class IndexBudgetExceeded extends Error {
|
|
123
|
+
label;
|
|
124
|
+
budget;
|
|
125
|
+
constructor(label, budget) {
|
|
126
|
+
super(`wicked-estate index of ${label} ran past its budget (${budgetWords(budget)}) and was stopped`);
|
|
127
|
+
this.label = label;
|
|
128
|
+
this.budget = budget;
|
|
129
|
+
this.name = 'IndexBudgetExceeded';
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* `wicked-estate index`, bounded by the member's index budget (wicked-crew#1481). The deadline is crew's own (chained
|
|
134
|
+
* past Node's timer cap) and aborts the child with SIGKILL, as the engine's own indexes are killed: a child that traps
|
|
135
|
+
* SIGTERM and exits 0, or with a code, still reads as over budget (codex r1/r2), never as an index that landed.
|
|
136
|
+
*/
|
|
137
|
+
async function indexWithinBudget(file, args, cwd, label, budget) {
|
|
138
|
+
const ctl = new AbortController();
|
|
139
|
+
let over = false;
|
|
140
|
+
const disarm = armDeadline(budget.budgetMs, () => {
|
|
141
|
+
over = true;
|
|
142
|
+
ctl.abort();
|
|
143
|
+
});
|
|
144
|
+
try {
|
|
145
|
+
const out = await execCapped(file, args, { cwd, signal: ctl.signal, killSignal: 'SIGKILL' });
|
|
146
|
+
if (over)
|
|
147
|
+
throw new IndexBudgetExceeded(label, budget);
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
if (over)
|
|
152
|
+
throw new IndexBudgetExceeded(label, budget);
|
|
153
|
+
throw err;
|
|
154
|
+
}
|
|
155
|
+
finally {
|
|
156
|
+
disarm();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/** Which budget an index hit, in the words its failure says. */
|
|
160
|
+
function budgetWords(b) {
|
|
161
|
+
return `${formatBudget(b.budgetMs)}${b.trackedFiles === null ? '' : `, sized from ${b.trackedFiles} files`}`;
|
|
162
|
+
}
|
|
163
|
+
// ── Refresh state (wicked-crew#1481) ──────────────────────────────────────────
|
|
164
|
+
/** Per project, the refresh as this daemon runs it (in memory: a restart forgets it, the manifest does not). */
|
|
165
|
+
const refreshStates = new Map();
|
|
166
|
+
/** The project's refresh state, ABSENT when no refresh ran since the daemon started. */
|
|
167
|
+
export function projectGraphRefreshState(projectId) {
|
|
168
|
+
const st = refreshStates.get(projectId);
|
|
169
|
+
return st === undefined ? undefined : { ...st, lastFailure: st.lastFailure === null ? null : { ...st.lastFailure } };
|
|
170
|
+
}
|
|
171
|
+
/** `diagnostics.projectGraphRefresh`: every project refreshed since the daemon started. */
|
|
172
|
+
export function projectGraphRefreshDiagnostics() {
|
|
173
|
+
return [...refreshStates.keys()].map((projectId) => ({ projectId, ...projectGraphRefreshState(projectId) }));
|
|
174
|
+
}
|
|
175
|
+
/** Test seam: forget every refresh state. */
|
|
176
|
+
export function resetProjectGraphRefreshStates() {
|
|
177
|
+
refreshStates.clear();
|
|
178
|
+
}
|
|
83
179
|
function message(err) {
|
|
84
180
|
return err instanceof Error ? err.message : String(err);
|
|
85
181
|
}
|
|
@@ -170,6 +266,61 @@ export async function estateSupportsMultiRepo(env = process.env) {
|
|
|
170
266
|
return typeof out === 'string' && /index <path>[^\n]*--repo <name>/.test(out);
|
|
171
267
|
}
|
|
172
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Does the `wicked-estate` that will run support `link --project` (wicked-estate >= 0.34.0, slice X1)?
|
|
271
|
+
* Probed from `--help`, like `--repo`: an older binary has no `link`, and the refresh stays
|
|
272
|
+
* co-located.
|
|
273
|
+
*/
|
|
274
|
+
export async function estateSupportsLink(env = process.env) {
|
|
275
|
+
const probe = /^\s*wicked-estate link --project <id>/m;
|
|
276
|
+
try {
|
|
277
|
+
const { stdout } = await execCapped(estateExe(env), ['--help'], { timeout: 10_000 });
|
|
278
|
+
return probe.test(stdout);
|
|
279
|
+
}
|
|
280
|
+
catch (err) {
|
|
281
|
+
const out = err.stdout;
|
|
282
|
+
return typeof out === 'string' && probe.test(out);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/** Upper bound on one `wicked-estate link` run (it reads the stored inputs; it does not re-index). */
|
|
286
|
+
const LINK_TIMEOUT_MS = 10 * 60_000;
|
|
287
|
+
/**
|
|
288
|
+
* The refresh's last step: link the CURRENT member labels (leaving a removed member out retracts
|
|
289
|
+
* its links). Never throws: a failed link leaves the co-located graph as it always was, and the
|
|
290
|
+
* failure is reported on the refresh result.
|
|
291
|
+
*/
|
|
292
|
+
async function linkMembers(projectId, dbPath, labels, env, log) {
|
|
293
|
+
if (labels.length === 0 || !(await estateSupportsLink(env)))
|
|
294
|
+
return undefined;
|
|
295
|
+
try {
|
|
296
|
+
const { stdout } = await execCapped(estateExe(env), ['link', '--db', dbPath, '--project', projectId, '--labels', labels.join(','), '--json'], { timeout: LINK_TIMEOUT_MS });
|
|
297
|
+
const r = JSON.parse(stdout);
|
|
298
|
+
const num = (k) => (typeof r[k] === 'number' ? r[k] : undefined);
|
|
299
|
+
const counts = (k) => {
|
|
300
|
+
const v = r[k];
|
|
301
|
+
return v !== null && typeof v === 'object' && !Array.isArray(v) ? v : undefined;
|
|
302
|
+
};
|
|
303
|
+
const generation = num('generation');
|
|
304
|
+
const links = num('links');
|
|
305
|
+
const byIdentity = counts('links_by_identity');
|
|
306
|
+
const byReason = counts('boundaries_by_reason');
|
|
307
|
+
return {
|
|
308
|
+
...(generation === undefined ? {} : { generation }),
|
|
309
|
+
...(links === undefined ? {} : { links }),
|
|
310
|
+
...(typeof r['replayed'] === 'boolean' ? { replayed: r['replayed'] } : {}),
|
|
311
|
+
...(byIdentity === undefined ? {} : { links_by_identity: byIdentity }),
|
|
312
|
+
...(byReason === undefined ? {} : { boundaries_by_reason: byReason }),
|
|
313
|
+
incomplete: Array.isArray(r['incomplete'])
|
|
314
|
+
? r['incomplete'].filter((x) => typeof x === 'string')
|
|
315
|
+
: [],
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
catch (err) {
|
|
319
|
+
const error = err instanceof ExecOutputTooLarge ? err.message : message(err);
|
|
320
|
+
log?.(`wicked-estate link (project ${projectId}) failed: ${error}`);
|
|
321
|
+
return { error };
|
|
322
|
+
}
|
|
323
|
+
}
|
|
173
324
|
/**
|
|
174
325
|
* Confirm from the DATABASE that the label landed, after the first repo goes in.
|
|
175
326
|
*
|
|
@@ -226,6 +377,10 @@ async function cleanHead(rootPath) {
|
|
|
226
377
|
return null;
|
|
227
378
|
}
|
|
228
379
|
}
|
|
380
|
+
function refreshField(projectId) {
|
|
381
|
+
const refresh = projectGraphRefreshState(projectId);
|
|
382
|
+
return refresh === undefined ? {} : { refresh };
|
|
383
|
+
}
|
|
229
384
|
function buildStatus({ projectId, members, manifest, dbExists, env }) {
|
|
230
385
|
const dbPath = projectGraphDb(projectId, env);
|
|
231
386
|
const indexedBy = new Map((manifest?.repos ?? []).map((r) => [r.label, r]));
|
|
@@ -306,6 +461,7 @@ function buildStatus({ projectId, members, manifest, dbExists, env }) {
|
|
|
306
461
|
updatedAt: manifest === null || !dbExists
|
|
307
462
|
? null
|
|
308
463
|
: manifest.repos.reduce((max, r) => Math.max(max, r.indexedAt), 0) || null,
|
|
464
|
+
...refreshField(projectId),
|
|
309
465
|
};
|
|
310
466
|
// Customer copy (F-2R2-008, crew#1036): every `detail` below is shown to a person on the project
|
|
311
467
|
// page and a chat's scope card, so it says "this project" — never the raw project id or a route.
|
|
@@ -416,6 +572,7 @@ export async function projectGraphStatus(adapter, projectId, env = process.env)
|
|
|
416
572
|
linkage: 'co-located',
|
|
417
573
|
note: CO_LOCATION_NOTE,
|
|
418
574
|
updatedAt: null,
|
|
575
|
+
...refreshField(projectId),
|
|
419
576
|
};
|
|
420
577
|
}
|
|
421
578
|
const dbPath = projectGraphDb(projectId, env);
|
|
@@ -464,7 +621,61 @@ function stderrTail(stderr, max = STDERR_TAIL_BYTES) {
|
|
|
464
621
|
const trimmed = stderr.trim();
|
|
465
622
|
return trimmed.length <= max ? trimmed : `…${trimmed.slice(trimmed.length - max)}`;
|
|
466
623
|
}
|
|
624
|
+
/**
|
|
625
|
+
* One refresh, with its state kept for the project page and diagnostics (wicked-crew#1481): `refreshing` from the
|
|
626
|
+
* start, its budget once the members are sized, the member being indexed; `idle` at the end with the last failure
|
|
627
|
+
* (a member's, or the refresh's own error), cleared by a refresh that lands with none.
|
|
628
|
+
*/
|
|
467
629
|
async function doRefresh(adapter, projectId, env, force, log) {
|
|
630
|
+
const prior = refreshStates.get(projectId);
|
|
631
|
+
const st = {
|
|
632
|
+
state: 'refreshing',
|
|
633
|
+
startedAt: Date.now(),
|
|
634
|
+
finishedAt: prior?.finishedAt ?? null,
|
|
635
|
+
budgetMs: null,
|
|
636
|
+
repoId: null,
|
|
637
|
+
repoStartedAt: null,
|
|
638
|
+
repoBudgetMs: null,
|
|
639
|
+
lastFailure: prior?.lastFailure ?? null,
|
|
640
|
+
};
|
|
641
|
+
refreshStates.set(projectId, st);
|
|
642
|
+
let lastFailure = null;
|
|
643
|
+
let result;
|
|
644
|
+
try {
|
|
645
|
+
result = await refreshOnce(adapter, projectId, env, force, st, log);
|
|
646
|
+
const failedRow = [...(result.repos ?? [])].reverse().find((r) => r.action === 'failed');
|
|
647
|
+
const linkFailed = result.link?.error ?? ((result.link?.incomplete?.length ?? 0) > 0 ? `incomplete: ${result.link.incomplete.join(', ')}` : undefined);
|
|
648
|
+
if (failedRow === undefined && linkFailed !== undefined) {
|
|
649
|
+
// The indexes landed but the link step did not publish (codex r1): still a failure, owed by the watcher.
|
|
650
|
+
lastFailure = { at: Date.now(), repoId: null, label: null, error: `the link step did not publish: ${linkFailed}`, timedOut: false, budgetMs: null };
|
|
651
|
+
}
|
|
652
|
+
if (failedRow !== undefined) {
|
|
653
|
+
lastFailure = {
|
|
654
|
+
at: Date.now(),
|
|
655
|
+
repoId: failedRow.repoId,
|
|
656
|
+
label: failedRow.label,
|
|
657
|
+
error: failedRow.error ?? 'the index failed',
|
|
658
|
+
timedOut: failedRow.timedOut === true,
|
|
659
|
+
budgetMs: failedRow.budget?.budgetMs ?? null,
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
catch (err) {
|
|
664
|
+
lastFailure = { at: Date.now(), repoId: null, label: null, error: message(err), timedOut: false, budgetMs: null };
|
|
665
|
+
throw err;
|
|
666
|
+
}
|
|
667
|
+
finally {
|
|
668
|
+
st.state = 'idle';
|
|
669
|
+
st.finishedAt = Date.now();
|
|
670
|
+
st.repoId = null;
|
|
671
|
+
st.repoStartedAt = null;
|
|
672
|
+
st.repoBudgetMs = null;
|
|
673
|
+
st.lastFailure = lastFailure;
|
|
674
|
+
}
|
|
675
|
+
// The status the result carries was read mid-refresh; it reports the refresh as it ended.
|
|
676
|
+
return { ...result, status: { ...result.status, ...refreshField(projectId) } };
|
|
677
|
+
}
|
|
678
|
+
async function refreshOnce(adapter, projectId, env, force, st, log) {
|
|
468
679
|
const members = await resolveMembers(adapter, projectId);
|
|
469
680
|
assertEngineFresh(members.repos);
|
|
470
681
|
const dbPath = projectGraphDb(projectId, env);
|
|
@@ -491,6 +702,13 @@ async function doRefresh(adapter, projectId, env, force, log) {
|
|
|
491
702
|
`would silently overwrite the one before it. Upgrade that binary, or point ` +
|
|
492
703
|
`WICKED_ESTATE_EXE at a build that has it.`);
|
|
493
704
|
}
|
|
705
|
+
// Every member's index budget, sized by the engine (wicked-crew#1481): the refresh's budget is their sum. Each
|
|
706
|
+
// member is sized AGAIN right before its own index (its checkout may have moved while earlier members indexed,
|
|
707
|
+
// codex r1). An addon that cannot size one refuses the refresh rather than guess a bound.
|
|
708
|
+
const budgets = new Map();
|
|
709
|
+
for (const m of members.repos)
|
|
710
|
+
budgets.set(m.label, await adapter.indexBudget(m.repo.root_path));
|
|
711
|
+
st.budgetMs = [...budgets.values()].reduce((sum, b) => sum + b.budgetMs, 0);
|
|
494
712
|
await mkdir(dirname(dbPath), { recursive: true });
|
|
495
713
|
const dbExisted = existsSync(dbPath);
|
|
496
714
|
const prior = dbExisted ? await readManifest(projectId, env) : null;
|
|
@@ -536,8 +754,15 @@ async function doRefresh(adapter, projectId, env, force, log) {
|
|
|
536
754
|
repoRows.push({ repoId: m.repoId, label: m.label, action: 'skipped-head-unchanged' });
|
|
537
755
|
continue;
|
|
538
756
|
}
|
|
757
|
+
const sized = budgets.get(m.label);
|
|
758
|
+
const budget = await adapter.indexBudget(m.repo.root_path);
|
|
759
|
+
st.budgetMs = (st.budgetMs ?? 0) - sized.budgetMs + budget.budgetMs;
|
|
760
|
+
const budgetInfo = { budgetMs: budget.budgetMs, trackedFiles: budget.trackedFiles };
|
|
761
|
+
st.repoId = m.repoId;
|
|
762
|
+
st.repoStartedAt = Date.now();
|
|
763
|
+
st.repoBudgetMs = budget.budgetMs;
|
|
539
764
|
try {
|
|
540
|
-
const { stderr } = await
|
|
765
|
+
const { stderr } = await indexWithinBudget(estateExe(env), [
|
|
541
766
|
'index',
|
|
542
767
|
m.repo.root_path,
|
|
543
768
|
'--db',
|
|
@@ -547,7 +772,7 @@ async function doRefresh(adapter, projectId, env, force, log) {
|
|
|
547
772
|
// estate's own digest skip would otherwise no-op an unchanged repo, leaving the very rows
|
|
548
773
|
// a forced refresh exists to rewrite.
|
|
549
774
|
...(force ? ['--force'] : []),
|
|
550
|
-
],
|
|
775
|
+
], m.repo.root_path, m.label, budget);
|
|
551
776
|
// The index child's stderr used to be discarded here, which swallowed estate's id_scheme
|
|
552
777
|
// migration notice — the ONE signal explaining why a one-second incremental refresh suddenly
|
|
553
778
|
// ran for minutes. Bounded tail on the repo's row, full-line through the logger.
|
|
@@ -580,6 +805,7 @@ async function doRefresh(adapter, projectId, env, force, log) {
|
|
|
580
805
|
label: m.label,
|
|
581
806
|
action: 'indexed',
|
|
582
807
|
...(tail === '' ? {} : { stderrTail: tail }),
|
|
808
|
+
budget: budgetInfo,
|
|
583
809
|
});
|
|
584
810
|
}
|
|
585
811
|
catch (err) {
|
|
@@ -599,6 +825,8 @@ async function doRefresh(adapter, projectId, env, force, log) {
|
|
|
599
825
|
await writeManifest(projectId, { version: 1, projectId, repos: [] }, env);
|
|
600
826
|
throw err;
|
|
601
827
|
}
|
|
828
|
+
// Only the index itself can run past its budget; the label check's own stats query is not it (codex r2).
|
|
829
|
+
const timedOut = err instanceof IndexBudgetExceeded;
|
|
602
830
|
const error = err instanceof ExecOutputTooLarge ? err.message : message(err);
|
|
603
831
|
failed.push({ repoId: m.repoId, label: m.label, error });
|
|
604
832
|
// execFile errors carry the child's stderr; the failure tail is worth as much as a success's.
|
|
@@ -612,17 +840,27 @@ async function doRefresh(adapter, projectId, env, force, log) {
|
|
|
612
840
|
action: 'failed',
|
|
613
841
|
error,
|
|
614
842
|
...(tail === '' ? {} : { stderrTail: tail }),
|
|
843
|
+
...(timedOut ? { timedOut: true } : {}),
|
|
844
|
+
budget: budgetInfo,
|
|
615
845
|
});
|
|
616
846
|
}
|
|
847
|
+
finally {
|
|
848
|
+
st.repoId = null;
|
|
849
|
+
st.repoStartedAt = null;
|
|
850
|
+
st.repoBudgetMs = null;
|
|
851
|
+
}
|
|
617
852
|
}
|
|
618
853
|
const manifest = { version: 1, projectId, repos: rows };
|
|
619
854
|
await writeManifest(projectId, manifest, env);
|
|
855
|
+
// X1: link LAST, over the current members, once every index of this refresh has finished.
|
|
856
|
+
const link = await linkMembers(projectId, dbPath, members.repos.map((m) => m.label), env, log);
|
|
620
857
|
return {
|
|
621
858
|
status: buildStatus({ projectId, members, manifest, dbExists: existsSync(dbPath), env }),
|
|
622
859
|
indexed,
|
|
623
860
|
skipped,
|
|
624
861
|
failed,
|
|
625
862
|
repos: repoRows,
|
|
863
|
+
...(link === undefined ? {} : { link }),
|
|
626
864
|
};
|
|
627
865
|
}
|
|
628
866
|
/**
|
|
@@ -660,7 +898,7 @@ function degradedTo(repoRef, subject) {
|
|
|
660
898
|
*
|
|
661
899
|
* # This never indexes
|
|
662
900
|
*
|
|
663
|
-
* A refresh is `wicked-estate index` per member repo, bounded
|
|
901
|
+
* A refresh is `wicked-estate index` per member repo, bounded by its index budget EACH (#1481). Doing that
|
|
664
902
|
* inside a launch would turn "start a run" into an unannounced multi-repo indexing job that blocks
|
|
665
903
|
* the response, and the first thing an operator would learn about it is a request that appears to
|
|
666
904
|
* hang. So a missing or stale graph DEGRADES the run to the per-repo graph and says so; refreshing
|
|
@@ -837,6 +1075,8 @@ function toHit(raw, labels) {
|
|
|
837
1075
|
kind: typeof raw.kind === 'string' ? raw.kind : '',
|
|
838
1076
|
file: where.file,
|
|
839
1077
|
line: typeof raw.line === 'number' ? raw.line : 0,
|
|
1078
|
+
...(typeof raw.via_crossing === 'string' ? { via_crossing: raw.via_crossing } : {}),
|
|
1079
|
+
...(raw.via_crossing_omitted === true ? { via_crossing_omitted: true } : {}),
|
|
840
1080
|
};
|
|
841
1081
|
}
|
|
842
1082
|
/** Safety stop for following estate's blast-radius cursor: a server that kept issuing cursors would
|
|
@@ -882,7 +1122,30 @@ export async function readBlastRadiusPages(exe, name, dbPath, opts) {
|
|
|
882
1122
|
/** Dependents of a symbol across every member repo, each hit attributed to the repo it is in. */
|
|
883
1123
|
export async function projectBlastRadius(q, name, env = process.env) {
|
|
884
1124
|
const raw = (await readBlastRadiusPages(estateExe(env), name, q.dbPath, { timeout: QUERY_TIMEOUT_MS }));
|
|
885
|
-
const { hits, byRepo } = attributeHits(raw.dependents, q.labels);
|
|
1125
|
+
const { hits: allHits, byRepo } = attributeHits(raw.dependents, q.labels);
|
|
1126
|
+
// X1: estate lists the same (shallowest, capped) crossings on every page; the last page's list.
|
|
1127
|
+
// Only crossings between CURRENT members count: a removed member's links stay in the database
|
|
1128
|
+
// until the next refresh relinks without it, and must not make an answer read `linked`.
|
|
1129
|
+
const members = new Set(q.labels.keys());
|
|
1130
|
+
const listed = Array.isArray(raw.crossings) ? raw.crossings : [];
|
|
1131
|
+
const crossings = listed.filter((c) => members.has(c.from?.repo) && members.has(c.to?.repo));
|
|
1132
|
+
const dropped = new Set(listed.filter((c) => !crossings.includes(c)).map((c) => c.id));
|
|
1133
|
+
// A hit reached through a dropped crossing loses its provenance claim along with the crossing.
|
|
1134
|
+
const hits = allHits.map((h) => {
|
|
1135
|
+
if (h.via_crossing === undefined || !dropped.has(h.via_crossing))
|
|
1136
|
+
return h;
|
|
1137
|
+
const kept = { ...h };
|
|
1138
|
+
delete kept.via_crossing;
|
|
1139
|
+
delete kept.via_crossing_omitted;
|
|
1140
|
+
return kept;
|
|
1141
|
+
});
|
|
1142
|
+
const linked = crossings.length > 0;
|
|
1143
|
+
// estate's per-project link state: stale when a member moved since the link was validated.
|
|
1144
|
+
const state = (Array.isArray(raw.link) ? raw.link : []);
|
|
1145
|
+
const stale = state.some((s) => s.stale === true);
|
|
1146
|
+
const staleLabels = state
|
|
1147
|
+
.flatMap((s) => (Array.isArray(s.stale_labels) ? s.stale_labels : []))
|
|
1148
|
+
.filter((l) => typeof l === 'string');
|
|
886
1149
|
// crew#751: estate's completeness causes (wicked-estate#222), carried through verbatim when the
|
|
887
1150
|
// installed estate reports them, and ABSENT when it does not — never a fabricated `false`, which
|
|
888
1151
|
// would read as "the walk was complete" on an estate that cannot say.
|
|
@@ -904,8 +1167,14 @@ export async function projectBlastRadius(q, name, env = process.env) {
|
|
|
904
1167
|
unresolved: typeof raw.unresolved === 'number' ? raw.unresolved : 0,
|
|
905
1168
|
reposSearched: [...q.labels.keys()].sort(),
|
|
906
1169
|
missingRepos: q.status.missingRepos,
|
|
907
|
-
linkage: 'co-located',
|
|
908
|
-
note: CO_LOCATION_NOTE,
|
|
1170
|
+
linkage: linked ? 'linked' : 'co-located',
|
|
1171
|
+
note: linked ? (stale ? `${LINKED_NOTE} ${LINK_STALE_NOTE}` : LINKED_NOTE) : CO_LOCATION_NOTE,
|
|
1172
|
+
...(Array.isArray(raw.crossings) ? { crossings } : {}),
|
|
1173
|
+
...(typeof raw.crossings_total === 'number'
|
|
1174
|
+
? { crossings_total: Math.max(crossings.length, raw.crossings_total - dropped.size) }
|
|
1175
|
+
: {}),
|
|
1176
|
+
...(raw.crossings_truncated === true ? { crossings_truncated: true } : {}),
|
|
1177
|
+
...(linked && stale ? { link_stale: true, link_stale_labels: [...new Set(staleLabels)].sort() } : {}),
|
|
909
1178
|
};
|
|
910
1179
|
}
|
|
911
1180
|
/**
|