kibi-cli 2.17.0 → 2.18.0
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/cli-register-proof.js +9 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +9 -3
- package/dist/commands/sync/untracked-targets.d.ts.map +1 -1
- package/dist/commands/sync/untracked-targets.js +39 -9
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +26 -5
- package/dist/engine.d.ts +4 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +40 -10
- package/dist/operations/modeling/predicate-applicability.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applicability.js +5 -2
- package/dist/operations/modeling/predicate-catalog-4.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-catalog-4.js +4 -0
- package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-loader.js +3 -0
- package/dist/operations/modeling/predicate-score-3.js +1 -1
- package/dist/operations/modeling/predicate-types.d.ts +5 -0
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
- package/dist/operations/mutation/source-authoring.d.ts +9 -0
- package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
- package/dist/operations/mutation/source-authoring.js +38 -2
- package/dist/operations/planning/apply-plan.d.ts.map +1 -1
- package/dist/operations/planning/apply-plan.js +10 -1
- package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/clauses.js +7 -1
- package/dist/prolog/store-lock.d.ts +22 -0
- package/dist/prolog/store-lock.d.ts.map +1 -1
- package/dist/prolog/store-lock.js +45 -1
- package/dist/prolog.d.ts +7 -1
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +21 -3
- package/dist/proof/inspect.d.ts +7 -0
- package/dist/proof/inspect.d.ts.map +1 -1
- package/dist/proof/inspect.js +10 -0
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +3 -0
- package/dist/public/operations/discovery-executors.d.ts +14 -1
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +57 -7
- package/dist/public/operations/migration-plan.d.ts +2 -0
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +31 -0
- package/dist/public/operations/source-relationship-parity.d.ts.map +1 -1
- package/dist/public/operations/source-relationship-parity.js +55 -1
- package/dist/public/skills/kibi-usage/SKILL.md +12 -3
- package/dist/public/skills/kibi-usage/resources/proof.md +23 -0
- package/dist/utils/branch-store.d.ts +8 -0
- package/dist/utils/branch-store.d.ts.map +1 -1
- package/dist/utils/branch-store.js +27 -1
- package/dist/utils/content-freshness.d.ts +13 -0
- package/dist/utils/content-freshness.d.ts.map +1 -0
- package/dist/utils/content-freshness.js +161 -0
- package/package.json +2 -2
- package/src/public/operations/contracts.ts +3 -0
- package/src/public/operations/discovery-executors.ts +84 -6
- package/src/public/operations/migration-plan.ts +44 -0
- package/src/public/operations/source-relationship-parity.ts +60 -3
- package/src/public/skills/kibi-usage/SKILL.md +12 -3
- package/src/public/skills/kibi-usage/resources/proof.md +23 -0
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
|
|
2
|
+
// An explicit grant ("are allowed to", "is permitted to") asserts a
|
|
3
|
+
// permission just as "denied"/"forbidden" assert a prohibition. Bare "can" and
|
|
4
|
+
// "may" are accepted by the predicate applicability gate but not here: stored
|
|
5
|
+
// clause roles are derived from this pattern, and "it can be restricted to …"
|
|
6
|
+
// style capability prose would turn existing descriptive inventories into
|
|
7
|
+
// unmodeled normative clauses.
|
|
8
|
+
const NORMATIVE_ASSERTION_PATTERN = /\b(?:must|shall|should|required|requires?|may\s+only|(?:is|are)\s+(?:not\s+)?(?:allowed|permitted)\s+to|permitted|may\s+(?:not\s+)?(?:be\s+)?\w+\s+only\b|may\s+(?:have\s+)?(?:at\s+most|at\s+least|exactly|no\s+more\s+than|up\s+to)|only\s+.+?\s+(?:may|can)|must\s+not|shall\s+not|cannot|can't|denied|forbidden|prohibited|(?:is|are|be|become|becomes|remain|remains)\s+(?:invalid|rejected|prohibited|forbidden)|(?:reject|rejects|rejected|rejection)\s+(?:invalid|unresolved|ambiguous)|fail(?:s|ed)?\s+(?:clearly|explicitly|with)|expires?\s+(?:after|within|in)|failure\s+(?:behavior|policy|outcome)|error\s+(?:handling|behavior|policy|outcome)|required\s+outcome|defaults?\s+to)\b/i;
|
|
3
9
|
// Conditional/temporal cues help discover clauses but do not by themselves
|
|
4
10
|
// turn explanatory or subjective context into an asserted obligation.
|
|
5
11
|
const NORMATIVE_PATTERN = new RegExp(`${NORMATIVE_ASSERTION_PATTERN.source}|\\b(?:before|unless|when|if)\\b`, "i");
|
|
@@ -21,6 +21,28 @@ export declare function readStoreLockOwner(storePath: string): {
|
|
|
21
21
|
* lives at the branch-store root (older builds kept it beside the lock).
|
|
22
22
|
*/
|
|
23
23
|
export declare function breakStoreLock(rdfDirectory: string): void;
|
|
24
|
+
/** Store-root record of the last stale-lock takeover (see below). */
|
|
25
|
+
export declare const STORE_LOCK_TAKEOVER_FILE = ".kibi-lock-takeover.json";
|
|
26
|
+
/**
|
|
27
|
+
* How long a takeover stays visible in kb_status and kibi doctor. A takeover
|
|
28
|
+
* happens inside a detached engine whose output nobody reads, so the record
|
|
29
|
+
* outlives that engine (which may idle out within minutes) long enough to be
|
|
30
|
+
* seen on the next working session; the next takeover replaces it.
|
|
31
|
+
*/
|
|
32
|
+
export declare const STORE_LOCK_TAKEOVER_VISIBLE_MS: number;
|
|
33
|
+
export type StoreLockTakeoverRecord = Readonly<{
|
|
34
|
+
brokenPid: number | null;
|
|
35
|
+
reason: string;
|
|
36
|
+
at: string;
|
|
37
|
+
path: string;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Record that a stale branch-store lock is about to be broken. Best effort:
|
|
41
|
+
* the record is diagnostic and must never block the takeover itself.
|
|
42
|
+
*/
|
|
43
|
+
export declare function recordStoreLockTakeover(storePath: string, brokenPid: number | null, reason: string, at?: Date): void;
|
|
44
|
+
/** The last takeover record of a branch store, or null when none is readable. */
|
|
45
|
+
export declare function readStoreLockTakeover(storePath: string): StoreLockTakeoverRecord | null;
|
|
24
46
|
export interface StoreLockTakeoverDecision {
|
|
25
47
|
readonly action: "break" | "surface";
|
|
26
48
|
readonly reason: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-lock.d.ts","sourceRoot":"","sources":["../../src/prolog/store-lock.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAqB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAgBhF,8EAA8E;AAC9E,wBAAgB,aAAa,IAAI,MAAM,GAAG,IAAI,CAa7C;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAUnD;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEzE,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,oBAAoB,GAAG,IAAI,GACjC,oBAAoB,CAYtB;AAED;;;;;GAKG;AAEH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,GAChB;IAAE,KAAK,EAAE,oBAAoB,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA4B7D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAWzD;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,oBAAoB,GAAG,IAAI,GAC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,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAEH;;;GAGG;AAEH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,MAAM,EAAE,MAAM,EACd,EAAE,GAAE,IAAiB,GACpB,IAAI,CAUN;AAED,iFAAiF;AAEjF,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,GAChB,uBAAuB,GAAG,IAAI,CAmBhC;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,oBAAoB,GAAG,IAAI,GACjC,yBAAyB,CAoB3B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CACxD;AAED;;;;;;GAMG;AAEH,wBAAsB,iCAAiC,CACrD,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,WAAW,CAAC,CAiCtB"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
You should have received a copy of the GNU Affero General Public License
|
|
16
16
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
|
-
import { existsSync, rmSync } from "node:fs";
|
|
18
|
+
import { existsSync, rmSync, writeFileSync } from "node:fs";
|
|
19
19
|
import { readFileSync } from "node:fs";
|
|
20
20
|
import { dirname, join } from "node:path";
|
|
21
21
|
import { escapeAtom } from "./codec.js";
|
|
@@ -133,6 +133,49 @@ export function breakStoreLock(rdfDirectory) {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
+
/** Store-root record of the last stale-lock takeover (see below). */
|
|
137
|
+
export const STORE_LOCK_TAKEOVER_FILE = ".kibi-lock-takeover.json";
|
|
138
|
+
/**
|
|
139
|
+
* How long a takeover stays visible in kb_status and kibi doctor. A takeover
|
|
140
|
+
* happens inside a detached engine whose output nobody reads, so the record
|
|
141
|
+
* outlives that engine (which may idle out within minutes) long enough to be
|
|
142
|
+
* seen on the next working session; the next takeover replaces it.
|
|
143
|
+
*/
|
|
144
|
+
export const STORE_LOCK_TAKEOVER_VISIBLE_MS = 24 * 60 * 60 * 1000;
|
|
145
|
+
/**
|
|
146
|
+
* Record that a stale branch-store lock is about to be broken. Best effort:
|
|
147
|
+
* the record is diagnostic and must never block the takeover itself.
|
|
148
|
+
*/
|
|
149
|
+
// implements REQ-core-journaled-engine-persistence
|
|
150
|
+
export function recordStoreLockTakeover(storePath, brokenPid, reason, at = new Date()) {
|
|
151
|
+
try {
|
|
152
|
+
writeFileSync(join(storePath, STORE_LOCK_TAKEOVER_FILE), `${JSON.stringify({ brokenPid, reason, at: at.toISOString() })}\n`, { mode: 0o600 });
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
// A read-only or vanished store still gets its lock broken.
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/** The last takeover record of a branch store, or null when none is readable. */
|
|
159
|
+
// implements REQ-core-journaled-engine-persistence
|
|
160
|
+
export function readStoreLockTakeover(storePath) {
|
|
161
|
+
const recordPath = join(storePath, STORE_LOCK_TAKEOVER_FILE);
|
|
162
|
+
if (!existsSync(recordPath))
|
|
163
|
+
return null;
|
|
164
|
+
try {
|
|
165
|
+
const parsed = JSON.parse(readFileSync(recordPath, "utf8"));
|
|
166
|
+
if (typeof parsed.at !== "string" || Number.isNaN(Date.parse(parsed.at)))
|
|
167
|
+
return null;
|
|
168
|
+
return {
|
|
169
|
+
brokenPid: typeof parsed.brokenPid === "number" ? parsed.brokenPid : null,
|
|
170
|
+
reason: typeof parsed.reason === "string" ? parsed.reason : "",
|
|
171
|
+
at: parsed.at,
|
|
172
|
+
path: recordPath,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
136
179
|
/**
|
|
137
180
|
* Decide whether a store-locked failure may be auto-healed. Only a provably
|
|
138
181
|
* dead holder (or a holder from a previous boot) is broken; live or unknown
|
|
@@ -186,6 +229,7 @@ Store lock holder: ${holderSummary}. Close that session, or run 'kibi engine sto
|
|
|
186
229
|
const lockDirectory = storeLocked.lockDirectory !== ""
|
|
187
230
|
? storeLocked.lockDirectory
|
|
188
231
|
: join(kbPath, "rdf");
|
|
232
|
+
recordStoreLockTakeover(kbPath, storeLocked.owner?.pid ?? null, decision.reason);
|
|
189
233
|
breakStoreLock(lockDirectory);
|
|
190
234
|
const retried = await prolog.query(`kb_attach('${escapeAtom(kbPath)}')`);
|
|
191
235
|
if (retried.success) {
|
package/dist/prolog.d.ts
CHANGED
|
@@ -122,6 +122,12 @@ export declare class PrologProcess {
|
|
|
122
122
|
isRunning(): boolean;
|
|
123
123
|
getPid(): number;
|
|
124
124
|
private lostProcessError;
|
|
125
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Stop the Prolog child. `graceMs` lets the interactive toplevel halt on
|
|
127
|
+
* stdin EOF (running its at_halt hooks) before it is signalled.
|
|
128
|
+
*/
|
|
129
|
+
terminate(options?: {
|
|
130
|
+
graceMs?: number;
|
|
131
|
+
}): Promise<void>;
|
|
126
132
|
}
|
|
127
133
|
//# sourceMappingURL=prolog.d.ts.map
|
package/dist/prolog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prolog.d.ts","sourceRoot":"","sources":["../src/prolog.ts"],"names":[],"mappings":"AA2BA,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,aAAa,EAGnB,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C;CAqCnE"}
|
package/dist/prolog.js
CHANGED
|
@@ -826,7 +826,7 @@ export class PrologProcess {
|
|
|
826
826
|
// The child may have exited between the group and direct kill attempts.
|
|
827
827
|
}
|
|
828
828
|
}
|
|
829
|
-
async terminateProcessTree(child) {
|
|
829
|
+
async terminateProcessTree(child, graceMs = 0) {
|
|
830
830
|
let closed = false;
|
|
831
831
|
const exited = new Promise((resolve) => {
|
|
832
832
|
const markExited = () => {
|
|
@@ -836,6 +836,20 @@ export class PrologProcess {
|
|
|
836
836
|
child.once("close", markExited);
|
|
837
837
|
child.once("error", markExited);
|
|
838
838
|
});
|
|
839
|
+
if (graceMs > 0 && child.exitCode === null && child.signalCode === null) {
|
|
840
|
+
// implements REQ-core-journaled-engine-persistence
|
|
841
|
+
let graceTimer;
|
|
842
|
+
await Promise.race([
|
|
843
|
+
exited,
|
|
844
|
+
new Promise((resolve) => {
|
|
845
|
+
graceTimer = setTimeout(resolve, graceMs);
|
|
846
|
+
}),
|
|
847
|
+
]);
|
|
848
|
+
if (graceTimer)
|
|
849
|
+
clearTimeout(graceTimer);
|
|
850
|
+
if (closed)
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
839
853
|
if (child.exitCode === null)
|
|
840
854
|
this.signalProcessTree(child, "SIGTERM");
|
|
841
855
|
await Promise.race([
|
|
@@ -992,7 +1006,11 @@ export class PrologProcess {
|
|
|
992
1006
|
}
|
|
993
1007
|
return new PrologProcessTerminatedError(this.terminationReason ?? "process exited");
|
|
994
1008
|
}
|
|
995
|
-
|
|
1009
|
+
/**
|
|
1010
|
+
* Stop the Prolog child. `graceMs` lets the interactive toplevel halt on
|
|
1011
|
+
* stdin EOF (running its at_halt hooks) before it is signalled.
|
|
1012
|
+
*/
|
|
1013
|
+
async terminate(options = {}) {
|
|
996
1014
|
if (this.interactiveStarted) {
|
|
997
1015
|
this.terminationReason ??= "terminated";
|
|
998
1016
|
}
|
|
@@ -1012,7 +1030,7 @@ export class PrologProcess {
|
|
|
1012
1030
|
this.terminationPromise = (async () => {
|
|
1013
1031
|
if (current) {
|
|
1014
1032
|
current.stdin?.end();
|
|
1015
|
-
await this.terminateProcessTree(current);
|
|
1033
|
+
await this.terminateProcessTree(current, options.graceMs ?? 0);
|
|
1016
1034
|
}
|
|
1017
1035
|
await Promise.all(oneShots.map((child) => this.terminateProcessTree(child)));
|
|
1018
1036
|
})();
|
package/dist/proof/inspect.d.ts
CHANGED
|
@@ -5,7 +5,14 @@ export type ProofInspection = Readonly<{
|
|
|
5
5
|
buildSystems: readonly string[];
|
|
6
6
|
detectedRunners: readonly string[];
|
|
7
7
|
ciWorkflows: readonly string[];
|
|
8
|
+
/** Comma-joined ids of the configured integrations (kept for compatibility). */
|
|
8
9
|
currentIntegration: string | null;
|
|
10
|
+
/** Each configured integration with the producer and command it runs. */
|
|
11
|
+
currentIntegrations: readonly Readonly<{
|
|
12
|
+
id: string;
|
|
13
|
+
producer: string;
|
|
14
|
+
command: readonly string[];
|
|
15
|
+
}>[];
|
|
9
16
|
recommendation: string;
|
|
10
17
|
missing: readonly string[];
|
|
11
18
|
/** The integration Kibi proposes for the detected runner, if any. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/proof/inspect.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,uBAAuB,CAAC;AAM/B,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,SAA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,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;KAC5B,CAAC,EAAE,CAAC;IACL,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,qEAAqE;IACrE,mBAAmB,EAAE,mBAAmB,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;IAC/D,6EAA6E;IAC7E,gBAAgB,EAAE,mBAAmB,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC;IACjE;;;OAGG;IACH,eAAe,EAAE,aAAa,GAAG,IAAI,CAAC;IACtC,sDAAsD;IACtD,qBAAqB,EAAE,MAAM,CAAC;CAC/B,CAAC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B,CAAC,CAAC;AAwIH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GACZ,OAAO,CAMT;AA2BD,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,sBAA2B,GACnC,eAAe,CA0GjB"}
|
package/dist/proof/inspect.js
CHANGED
|
@@ -208,6 +208,15 @@ export function inspectProofEnvironment(root, options = {}) {
|
|
|
208
208
|
const currentIntegration = integrations.available
|
|
209
209
|
? integrations.integrations.integrations.map((entry) => entry.id).join(", ")
|
|
210
210
|
: null;
|
|
211
|
+
// implements REQ-kibi-verification-evidence-contract
|
|
212
|
+
// The id alone does not say what `kibi prove` will run; expose the command.
|
|
213
|
+
const currentIntegrations = integrations.available
|
|
214
|
+
? integrations.integrations.integrations.map((entry) => ({
|
|
215
|
+
id: entry.id,
|
|
216
|
+
producer: entry.producer,
|
|
217
|
+
command: [...entry.command],
|
|
218
|
+
}))
|
|
219
|
+
: [];
|
|
211
220
|
const planned = buildProofIntegrationPlan(root, options);
|
|
212
221
|
const applyHint = "review integrationPlan, then apply it with kb_apply_plan (or `kibi apply-plan --input -`) passing plan, approvedPlanHash = plan.planHash and approvedActionIds";
|
|
213
222
|
let recommendation;
|
|
@@ -235,6 +244,7 @@ export function inspectProofEnvironment(root, options = {}) {
|
|
|
235
244
|
detectedRunners: runners,
|
|
236
245
|
ciWorkflows,
|
|
237
246
|
currentIntegration,
|
|
247
|
+
currentIntegrations,
|
|
238
248
|
recommendation,
|
|
239
249
|
missing,
|
|
240
250
|
proposedIntegration: planned.proposal?.integration ?? null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/public/operations/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAC1B,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAsZpE;;uEAEuE;AACvE,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,mBAAmB,GAC1B,mBAAmB,CAMrB;
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/public/operations/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAC1B,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAsZpE;;uEAEuE;AACvE,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,mBAAmB,GAC1B,mBAAmB,CAMrB;AAoXD,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAC3C,MAAM,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAa3C,CAAC;AAmDF,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EAClD,YAAY,EAAE,MAAM,GACnB,IAAI,CAIN;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,SAAS,eAAe,EAAE,GAClC,SAAS,0BAA0B,EAAE,CAoBvC"}
|
|
@@ -355,6 +355,8 @@ const BASE_DATA_SCHEMAS = {
|
|
|
355
355
|
truncated: booleanValue,
|
|
356
356
|
queryAnalysis: recordValue,
|
|
357
357
|
answer: recordValue,
|
|
358
|
+
branch: { type: ["string", "null"] },
|
|
359
|
+
branchStore: recordValue,
|
|
358
360
|
}, ["results", "count"]),
|
|
359
361
|
kb_status: objectData({
|
|
360
362
|
branch: stringValue,
|
|
@@ -377,6 +379,7 @@ const BASE_DATA_SCHEMAS = {
|
|
|
377
379
|
staleReasons: recordArray,
|
|
378
380
|
staleReasonCount: integerValue,
|
|
379
381
|
staleReasonsTruncated: booleanValue,
|
|
382
|
+
notices: recordArray,
|
|
380
383
|
branchAttachment: recordValue,
|
|
381
384
|
proofSnapshotChanges: recordArray,
|
|
382
385
|
proofSnapshotChangeCount: integerValue,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type IntentSearchAnalysis, type IntentSearchFacets, type IntentSearchMatch, type SourceLocation } from "../../intent-search.js";
|
|
2
2
|
import { type SearchAnswer } from "../../search-answer.js";
|
|
3
3
|
import type { SearchMatch } from "../../search-ranking.js";
|
|
4
|
-
import { type BranchStoreInspection } from "../../utils/branch-store.js";
|
|
4
|
+
import { BRANCH_STORE_NOT_COMPILED, type BranchStoreInspection } from "../../utils/branch-store.js";
|
|
5
5
|
import { type MigrationConfigStatus, type MigrationPlan } from "./migration-plan.js";
|
|
6
6
|
import type { OperationContext } from "./runtime-types.js";
|
|
7
7
|
import type { OperationResult } from "./types.js";
|
|
@@ -35,6 +35,17 @@ export type SearchPayload = {
|
|
|
35
35
|
readonly truncated?: boolean;
|
|
36
36
|
readonly queryAnalysis?: IntentSearchAnalysis;
|
|
37
37
|
readonly answer?: SearchAnswer;
|
|
38
|
+
/** The Kibi branch whose store was searched, when the runtime attached one. */
|
|
39
|
+
readonly branch?: string | null;
|
|
40
|
+
/** Present when the searched store was never compiled for this branch. */
|
|
41
|
+
readonly branchStore?: SearchBranchStoreNotice;
|
|
42
|
+
};
|
|
43
|
+
export type SearchBranchStoreNotice = {
|
|
44
|
+
readonly state: "not_compiled";
|
|
45
|
+
readonly code: typeof BRANCH_STORE_NOT_COMPILED;
|
|
46
|
+
readonly path: string;
|
|
47
|
+
readonly detail: string;
|
|
48
|
+
readonly remediation: Readonly<Record<string, unknown>>;
|
|
38
49
|
};
|
|
39
50
|
export type StatusInput = Readonly<Record<string, never>>;
|
|
40
51
|
export type StatusPayload = {
|
|
@@ -54,6 +65,8 @@ export type StatusPayload = {
|
|
|
54
65
|
readonly staleReasons?: readonly Record<string, unknown>[];
|
|
55
66
|
readonly staleReasonCount?: number;
|
|
56
67
|
readonly staleReasonsTruncated?: boolean;
|
|
68
|
+
/** Informational, non-blocking observations (never make the KB stale). */
|
|
69
|
+
readonly notices?: readonly Record<string, unknown>[];
|
|
57
70
|
readonly branchAttachment?: {
|
|
58
71
|
readonly gitBranch: string;
|
|
59
72
|
readonly kbBranch: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery-executors.d.ts","sourceRoot":"","sources":["../../../src/public/operations/discovery-executors.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAGpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,wBAAwB,CAAC;AAE9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE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EACjB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CA2CxC;AAmDD,wBAAsB,aAAa,CACjC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CA6HzC;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAmUzC"}
|
|
@@ -7,11 +7,34 @@ import { SwiplResolutionError } from "../../prolog/swipl-resolver.js";
|
|
|
7
7
|
import { buildSearchAnswer } from "../../search-answer.js";
|
|
8
8
|
import { rankEntities } from "../../search-ranking.js";
|
|
9
9
|
import { resolveBranchAttachment } from "../../utils/branch-resolver.js";
|
|
10
|
-
import { BRANCH_STORE_NOT_COMPILED, branchStoreReason, inspectBranchStore, storeLockJournalReason, uncompiledBranchStoreReason, } from "../../utils/branch-store.js";
|
|
10
|
+
import { BRANCH_STORE_NOT_COMPILED, branchStoreReason, inspectBranchStore, storeLockJournalReason, storeLockTakeoverReason, uncompiledBranchStoreReason, } from "../../utils/branch-store.js";
|
|
11
|
+
import { confirmSourceNewerReasons } from "../../utils/content-freshness.js";
|
|
11
12
|
import { loadSearchCandidates, paginateResults, queryEntitiesViaQuery, reloadFullEntities, validateEntityType, } from "./discovery-entities.js";
|
|
12
13
|
import { buildActionsFromStatus, readMigrationConfigStatus, } from "./migration-plan.js";
|
|
13
14
|
import { OperationJsonDecodeError, runOperationJsonQuery, } from "./prolog-json.js";
|
|
14
15
|
import { readWorkspaceSnapshot } from "./workspace-snapshot.js";
|
|
16
|
+
/**
|
|
17
|
+
* An empty result from a store that was never compiled says nothing about
|
|
18
|
+
* the authored requirements, so search reports the store state itself (the
|
|
19
|
+
* same reason kb_status and kb_check use) instead of a bare "no results".
|
|
20
|
+
*/
|
|
21
|
+
// implements REQ-cli-status-pre-first-sync, REQ-mcp-search-discovery
|
|
22
|
+
function uncompiledSearchNotice(context) {
|
|
23
|
+
const attachment = context.branchAttachment;
|
|
24
|
+
if (attachment === undefined)
|
|
25
|
+
return null;
|
|
26
|
+
const store = inspectBranchStore(context.workspaceRoot, attachment.kbBranch);
|
|
27
|
+
const reason = uncompiledBranchStoreReason(context.workspaceRoot, store, attachment.kbBranch);
|
|
28
|
+
if (reason === null)
|
|
29
|
+
return null;
|
|
30
|
+
return {
|
|
31
|
+
state: "not_compiled",
|
|
32
|
+
code: BRANCH_STORE_NOT_COMPILED,
|
|
33
|
+
path: store.path,
|
|
34
|
+
detail: String(reason.detail),
|
|
35
|
+
remediation: reason.remediation,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
15
38
|
function requireProlog(context) {
|
|
16
39
|
if (!context.prolog) {
|
|
17
40
|
throw new Error("Discovery operation requires a Prolog context");
|
|
@@ -118,6 +141,15 @@ export async function executeSearch(input, context) {
|
|
|
118
141
|
validateEntityType(type);
|
|
119
142
|
try {
|
|
120
143
|
const prolog = requireProlog(context);
|
|
144
|
+
const branch = context.branchAttachment?.kbBranch ?? null;
|
|
145
|
+
const storeNotice = uncompiledSearchNotice(context);
|
|
146
|
+
const branchFields = {
|
|
147
|
+
branch,
|
|
148
|
+
...(storeNotice ? { branchStore: storeNotice } : {}),
|
|
149
|
+
};
|
|
150
|
+
const storeNote = storeNotice
|
|
151
|
+
? ` Note: ${storeNotice.detail} Run kibi sync before relying on search results.`
|
|
152
|
+
: "";
|
|
121
153
|
const intentMode = rankingMode === "intent-v1" ||
|
|
122
154
|
semanticFacets !== undefined ||
|
|
123
155
|
sourceLocations !== undefined;
|
|
@@ -142,12 +174,12 @@ export async function executeSearch(input, context) {
|
|
|
142
174
|
: undefined;
|
|
143
175
|
// The structured payload carries every row; the text is a short
|
|
144
176
|
// human-readable digest instead of a second copy of the results.
|
|
145
|
-
const text = intentResult.matches.length === 0
|
|
177
|
+
const text = `${intentResult.matches.length === 0
|
|
146
178
|
? `No intent search results for '${trimmedQuery}' (abstained).`
|
|
147
179
|
: `Found ${intentResult.matches.length} intent search results for '${trimmedQuery}'${intentResult.analysis.ambiguous ? " (top matches are close; confirm before relying on one)" : ""}. Top: ${paginated
|
|
148
180
|
.slice(0, 5)
|
|
149
181
|
.map((match) => String(match.entity.id ?? ""))
|
|
150
|
-
.join(", ")}${answerLayer ? `. Governing: ${answerLayer.governing.map((req) => req.id).join(", ") || "none found"}` : ""}
|
|
182
|
+
.join(", ")}${answerLayer ? `. Governing: ${answerLayer.governing.map((req) => req.id).join(", ") || "none found"}` : ""}.`}${storeNote}`;
|
|
151
183
|
return {
|
|
152
184
|
content: [{ type: "text", text }],
|
|
153
185
|
structuredContent: {
|
|
@@ -156,6 +188,7 @@ export async function executeSearch(input, context) {
|
|
|
156
188
|
truncated: offset + paginated.length < intentResult.matches.length,
|
|
157
189
|
queryAnalysis: intentResult.analysis,
|
|
158
190
|
...(answerLayer ? { answer: answerLayer } : {}),
|
|
191
|
+
...branchFields,
|
|
159
192
|
},
|
|
160
193
|
};
|
|
161
194
|
}
|
|
@@ -168,17 +201,18 @@ export async function executeSearch(input, context) {
|
|
|
168
201
|
}, context.signal);
|
|
169
202
|
const matches = await rankEntities(entities, trimmedQuery, context.workspaceRoot);
|
|
170
203
|
const paginated = paginateResults(matches, limit, offset);
|
|
171
|
-
const text = matches.length === 0
|
|
204
|
+
const text = `${matches.length === 0
|
|
172
205
|
? `No search results for '${trimmedQuery}'.`
|
|
173
206
|
: `Found ${matches.length} search results for '${trimmedQuery}'. Showing ${paginated.length} (offset ${offset}, limit ${limit}): ${paginated
|
|
174
207
|
.map((match) => `${String(match.entity.id ?? "")} [${match.reasons.join(", ")}]`)
|
|
175
|
-
.join(", ")}`;
|
|
208
|
+
.join(", ")}`}${storeNote}`;
|
|
176
209
|
return {
|
|
177
210
|
content: [{ type: "text", text }],
|
|
178
211
|
structuredContent: {
|
|
179
212
|
results: await projectMatches(prolog, paginated, fields),
|
|
180
213
|
count: matches.length,
|
|
181
214
|
truncated: offset + paginated.length < matches.length,
|
|
215
|
+
...branchFields,
|
|
182
216
|
},
|
|
183
217
|
};
|
|
184
218
|
}
|
|
@@ -272,7 +306,19 @@ export async function executeStatus(_input, context) {
|
|
|
272
306
|
await ownedEngine?.terminate();
|
|
273
307
|
}
|
|
274
308
|
const snapshotEvidence = await readWorkspaceSnapshot(context);
|
|
275
|
-
|
|
309
|
+
// implements REQ-cli-status-pre-first-sync
|
|
310
|
+
// Prolog compares file times only. A fresh clone or a checkout rewrites
|
|
311
|
+
// every mtime without changing a byte, so confirm each "newer" source
|
|
312
|
+
// against the content hashes the last compilation recorded.
|
|
313
|
+
const prologReasons = payload.staleReasons ?? [];
|
|
314
|
+
const confirmed = confirmSourceNewerReasons(context.workspaceRoot, store.path, prologReasons);
|
|
315
|
+
const existingReasons = confirmed.kept;
|
|
316
|
+
if (confirmed.dropped.length > 0 &&
|
|
317
|
+
confirmed.kept.length === 0 &&
|
|
318
|
+
payload.staleReasonsTruncated !== true &&
|
|
319
|
+
payload.syncState === "stale") {
|
|
320
|
+
payload = { ...payload, syncState: "fresh", dirty: false };
|
|
321
|
+
}
|
|
276
322
|
// implements REQ-cli-status-pre-first-sync
|
|
277
323
|
// A missing or empty store beside authored sources gets the one reason
|
|
278
324
|
// whose remediation works (kibi sync); `kibi branch ensure` alone would
|
|
@@ -280,6 +326,9 @@ export async function executeStatus(_input, context) {
|
|
|
280
326
|
const storeReason = uncompiledBranchStoreReason(context.workspaceRoot, store, attachment.kbBranch) ?? branchStoreReason(store);
|
|
281
327
|
const storeUncompiled = storeReason?.code === BRANCH_STORE_NOT_COMPILED;
|
|
282
328
|
const lockReason = storeLockJournalReason(store.path);
|
|
329
|
+
// implements REQ-core-journaled-engine-persistence
|
|
330
|
+
// A stale-lock takeover heals itself; report it without making the KB stale.
|
|
331
|
+
const takeoverNotice = storeLockTakeoverReason(store.path);
|
|
283
332
|
const compilerReason = compilerFingerprintReason(store.path);
|
|
284
333
|
const engineReason = engineStatus
|
|
285
334
|
? {
|
|
@@ -318,6 +367,7 @@ export async function executeStatus(_input, context) {
|
|
|
318
367
|
...(storeUncompiled ? { syncState: "stale", dirty: true } : {}),
|
|
319
368
|
branchAttachment: attachment,
|
|
320
369
|
branchStore: store,
|
|
370
|
+
...(takeoverNotice ? { notices: [takeoverNotice] } : {}),
|
|
321
371
|
...(engineStatus ? { engineStatus } : {}),
|
|
322
372
|
staleReasons,
|
|
323
373
|
staleReasonCount: staleReasons.length,
|
|
@@ -447,7 +497,7 @@ export async function executeStatus(_input, context) {
|
|
|
447
497
|
content: [
|
|
448
498
|
{
|
|
449
499
|
type: "text",
|
|
450
|
-
text: `Branch ${payload.branch} is ${enrichedPayload.syncState} (snapshot ${payload.snapshotId}, dirty=${enrichedPayload.dirty}, proofSnapshot=${enrichedPayload.proofSnapshot})${storeUncompiled ? `. Blocking: ${String(storeReason?.detail)} Run kibi sync.` : ""}`,
|
|
500
|
+
text: `Branch ${payload.branch} is ${enrichedPayload.syncState} (snapshot ${payload.snapshotId}, dirty=${enrichedPayload.dirty}, proofSnapshot=${enrichedPayload.proofSnapshot})${storeUncompiled ? `. Blocking: ${String(storeReason?.detail)} Run kibi sync.` : ""}${takeoverNotice ? `. Note: ${String(takeoverNotice.detail)}` : ""}`,
|
|
451
501
|
},
|
|
452
502
|
],
|
|
453
503
|
structuredContent: statusWithPlan,
|
|
@@ -94,6 +94,8 @@ export type MigrationConfigStatus = Readonly<{
|
|
|
94
94
|
configHash: string | null;
|
|
95
95
|
}>;
|
|
96
96
|
export declare function readMigrationConfigStatus(workspaceRoot: string): MigrationConfigStatus;
|
|
97
|
+
/** Migration action code of the automatic recompile of changed sources. */
|
|
98
|
+
export declare const FRESHNESS_RESYNC = "freshness_resync";
|
|
97
99
|
export declare function buildActionsFromStatus(input: {
|
|
98
100
|
workspaceRoot: string;
|
|
99
101
|
branchAttachment?: Readonly<Record<string, unknown>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-plan.d.ts","sourceRoot":"","sources":["../../../src/public/operations/migration-plan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migration-plan.d.ts","sourceRoot":"","sources":["../../../src/public/operations/migration-plan.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,sBAAsB,EAAG,wBAAiC,CAAC;AAExE,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,SAAS,CAAC;AACvD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;AAChF,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC;AAErE,MAAM,MAAM,mBAAmB,GAC3B,QAAQ,CAAC;IACP,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC1C,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,KAAK,CAAC;IACZ,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAEP,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EACJ,SAAS,GACT,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,WAAW,GACX,cAAc,GACd,QAAQ,GACR,UAAU,GACV,OAAO,GACP,SAAS,CAAC;IACd,KAAK,EAAE,oBAAoB,CAAC;IAC5B,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,mBAAmB,CAAC;IAChC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,aAAa,EAAE,SAAS,MAAM,EAAE,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AAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAC5D,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,qBAAqB,CAAC;CACtC,GAAG,aAAa,CAuRhB"}
|
|
@@ -3,6 +3,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { BRANCH_STORE_NOT_COMPILED } from "../../utils/branch-store.js";
|
|
5
5
|
import { legacyConfigExists } from "../../utils/config.js";
|
|
6
|
+
import { MTIME_SOURCE_REASON_CODES } from "../../utils/content-freshness.js";
|
|
6
7
|
import { readKbManifestStatus } from "../../utils/kb-manifest.js";
|
|
7
8
|
import { getSchemaVersionStatus, normalizeSchemaVersion, } from "../../utils/schema-version.js";
|
|
8
9
|
import { lifecycleActionsFromViolations, schema6ReviewActionsFromCheck, } from "./schema6-check-actions.js";
|
|
@@ -438,6 +439,8 @@ function readLegacySchemaVersion(workspaceRoot) {
|
|
|
438
439
|
}
|
|
439
440
|
}
|
|
440
441
|
// implements REQ-agent-guided-migration-orchestration
|
|
442
|
+
/** Migration action code of the automatic recompile of changed sources. */
|
|
443
|
+
export const FRESHNESS_RESYNC = "freshness_resync";
|
|
441
444
|
export function buildActionsFromStatus(input) {
|
|
442
445
|
const actions = [];
|
|
443
446
|
const attachment = input.branchAttachment;
|
|
@@ -562,11 +565,39 @@ export function buildActionsFromStatus(input) {
|
|
|
562
565
|
autoApplicable: true,
|
|
563
566
|
}));
|
|
564
567
|
}
|
|
568
|
+
// implements REQ-cli-status-pre-first-sync
|
|
569
|
+
// Sources whose content changed since the last compilation (kb_status has
|
|
570
|
+
// already dropped mtime-only reasons) are fixed by recompiling them: one
|
|
571
|
+
// automatic `kibi sync`, not a review per file. An uncompiled store is
|
|
572
|
+
// compiled by the step above, which also covers these files.
|
|
573
|
+
const resyncReasons = (input.staleReasons ?? []).filter((reason) => typeof reason.code === "string" &&
|
|
574
|
+
MTIME_SOURCE_REASON_CODES.has(reason.code));
|
|
575
|
+
if (resyncReasons.length > 0 && uncompiled === undefined) {
|
|
576
|
+
actions.push(migrationAction({
|
|
577
|
+
id: "freshness-resync",
|
|
578
|
+
code: FRESHNESS_RESYNC,
|
|
579
|
+
category: "freshness",
|
|
580
|
+
safety: "automatic",
|
|
581
|
+
invocation: { kind: "cli", command_argv: ["kibi", "sync"] },
|
|
582
|
+
affectedFiles: [
|
|
583
|
+
...new Set(resyncReasons.flatMap((reason) => typeof reason.path === "string" ? [reason.path] : [])),
|
|
584
|
+
].sort(),
|
|
585
|
+
evidence: { reasons: resyncReasons },
|
|
586
|
+
dependsOn: actions
|
|
587
|
+
.map((action) => action.id)
|
|
588
|
+
.filter((id) => id === "branch-store-ensure" || id === "schema-config-upgrade"),
|
|
589
|
+
postconditions: [{ syncState: "fresh" }],
|
|
590
|
+
autoApplicable: true,
|
|
591
|
+
}));
|
|
592
|
+
}
|
|
565
593
|
for (const reason of input.staleReasons ?? []) {
|
|
566
594
|
const code = typeof reason.code === "string" ? reason.code : "stale_source";
|
|
567
595
|
// Planned above as an automatic compile step, not a review.
|
|
568
596
|
if (code === BRANCH_STORE_NOT_COMPILED)
|
|
569
597
|
continue;
|
|
598
|
+
// Planned above as one automatic resync (or covered by the compile).
|
|
599
|
+
if (MTIME_SOURCE_REASON_CODES.has(code))
|
|
600
|
+
continue;
|
|
570
601
|
const file = typeof reason.path === "string" ? reason.path : "";
|
|
571
602
|
actions.push(migrationAction({
|
|
572
603
|
id: `freshness-${code}-${file}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-relationship-parity.d.ts","sourceRoot":"","sources":["../../../src/public/operations/source-relationship-parity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"source-relationship-parity.d.ts","sourceRoot":"","sources":["../../../src/public/operations/source-relationship-parity.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CACpC,CAAC,CAAC;AAaH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,SAAS,wBAAwB,EAAE,EAC7C,QAAQ,EAAE,SAAS,wBAAwB,EAAE,GAC5C,SAAS,EAAE,CAwDb;AAuCD,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,wBAAwB,EAAE,CAmB5B;AA6BD,wBAAsB,yCAAyC,CAC7D,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,SAAS,EAAE,CAAC,CA0DtB"}
|