@meetless/mla 0.1.4
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/LICENSE +201 -0
- package/README.md +81 -0
- package/dist/build-info.json +9 -0
- package/dist/bundles/ask-core.js +396 -0
- package/dist/bundles/mcp.js +16592 -0
- package/dist/bundles/trace-core.js +263 -0
- package/dist/cli.js +828 -0
- package/dist/commands/activate.js +781 -0
- package/dist/commands/adoption.js +130 -0
- package/dist/commands/ask.js +290 -0
- package/dist/commands/context.js +114 -0
- package/dist/commands/debug.js +313 -0
- package/dist/commands/doctor.js +1021 -0
- package/dist/commands/enrich.js +427 -0
- package/dist/commands/evidence.js +229 -0
- package/dist/commands/flush.js +184 -0
- package/dist/commands/graph.js +104 -0
- package/dist/commands/init.js +272 -0
- package/dist/commands/internal-active-review.js +322 -0
- package/dist/commands/internal-auto-index.js +188 -0
- package/dist/commands/internal-capture-decisions.js +320 -0
- package/dist/commands/internal-evidence-correlate.js +239 -0
- package/dist/commands/internal-evidence-hooks.js +240 -0
- package/dist/commands/internal-evidence-inject.js +231 -0
- package/dist/commands/internal-finalize.js +221 -0
- package/dist/commands/internal-pretool-observe.js +225 -0
- package/dist/commands/internal-refresh.js +136 -0
- package/dist/commands/internal-session-nudge.js +120 -0
- package/dist/commands/internal-steer-sync.js +117 -0
- package/dist/commands/internal-turn-recap.js +140 -0
- package/dist/commands/kb.js +375 -0
- package/dist/commands/kb_add.js +681 -0
- package/dist/commands/kb_forget.js +283 -0
- package/dist/commands/kb_move.js +45 -0
- package/dist/commands/kb_pending.js +410 -0
- package/dist/commands/kb_personal.js +149 -0
- package/dist/commands/kb_promote.js +188 -0
- package/dist/commands/kb_purge.js +168 -0
- package/dist/commands/kb_reingest.js +335 -0
- package/dist/commands/kb_retime.js +170 -0
- package/dist/commands/kb_review.js +391 -0
- package/dist/commands/kb_revision.js +179 -0
- package/dist/commands/kb_show.js +385 -0
- package/dist/commands/label.js +226 -0
- package/dist/commands/login.js +295 -0
- package/dist/commands/logout.js +108 -0
- package/dist/commands/mcp-supervisor.js +93 -0
- package/dist/commands/mcp.js +227 -0
- package/dist/commands/queue-prune.js +98 -0
- package/dist/commands/review.js +358 -0
- package/dist/commands/rewire.js +124 -0
- package/dist/commands/rules.js +728 -0
- package/dist/commands/scan-context.js +67 -0
- package/dist/commands/session.js +347 -0
- package/dist/commands/stats.js +479 -0
- package/dist/commands/status.js +61 -0
- package/dist/commands/summary.js +250 -0
- package/dist/commands/turn.js +114 -0
- package/dist/commands/uninstall.js +222 -0
- package/dist/commands/whoami.js +102 -0
- package/dist/commands/workspace.js +130 -0
- package/dist/hooks-template/ce0-post-tool-use.sh +34 -0
- package/dist/hooks-template/ce0-session-start.sh +49 -0
- package/dist/hooks-template/ce0-stop.sh +29 -0
- package/dist/hooks-template/ce0-user-prompt-submit.sh +38 -0
- package/dist/hooks-template/common.sh +934 -0
- package/dist/hooks-template/event-batch-filter.jq +67 -0
- package/dist/hooks-template/flush.sh +503 -0
- package/dist/hooks-template/post-tool-use.sh +423 -0
- package/dist/hooks-template/pre-tool-use.sh +69 -0
- package/dist/hooks-template/session-start.sh +140 -0
- package/dist/hooks-template/stop.sh +308 -0
- package/dist/hooks-template/user-prompt-submit.sh +1162 -0
- package/dist/lib/activation.js +79 -0
- package/dist/lib/active-conflict-cache.js +141 -0
- package/dist/lib/active-memory.js +59 -0
- package/dist/lib/active-review-runner.js +26 -0
- package/dist/lib/agent-decision/index.js +25 -0
- package/dist/lib/agent-decision/keys.js +49 -0
- package/dist/lib/agent-decision/normalize-claude.js +183 -0
- package/dist/lib/agent-decision/types.js +21 -0
- package/dist/lib/agent-decision/validate.js +216 -0
- package/dist/lib/analytics/capture.js +96 -0
- package/dist/lib/analytics/command-event.js +267 -0
- package/dist/lib/analytics/consent.js +58 -0
- package/dist/lib/analytics/coverage-gap.js +96 -0
- package/dist/lib/analytics/envelope.js +236 -0
- package/dist/lib/analytics/event-id.js +86 -0
- package/dist/lib/analytics/evidence.js +150 -0
- package/dist/lib/analytics/followthrough.js +194 -0
- package/dist/lib/analytics/forwarder.js +109 -0
- package/dist/lib/analytics/logs.js +78 -0
- package/dist/lib/analytics/metrics.js +78 -0
- package/dist/lib/analytics/recorder.js +92 -0
- package/dist/lib/analytics/review-analytics.js +75 -0
- package/dist/lib/analytics/sequence.js +77 -0
- package/dist/lib/analytics/store.js +131 -0
- package/dist/lib/analytics/turn-recap.js +279 -0
- package/dist/lib/artifact_id.js +108 -0
- package/dist/lib/auth-breaker.js +161 -0
- package/dist/lib/auto-index.js +112 -0
- package/dist/lib/classifier.js +88 -0
- package/dist/lib/config.js +298 -0
- package/dist/lib/conflict-advisory.js +64 -0
- package/dist/lib/debug-bundle.js +520 -0
- package/dist/lib/enrichment/ingest.js +301 -0
- package/dist/lib/enrichment/plan.js +253 -0
- package/dist/lib/enrichment/protocol.js +359 -0
- package/dist/lib/enrichment/scout-brief.js +176 -0
- package/dist/lib/failure-telemetry.js +444 -0
- package/dist/lib/git.js +200 -0
- package/dist/lib/governance-cache.js +77 -0
- package/dist/lib/governed-path-cache.js +76 -0
- package/dist/lib/http.js +677 -0
- package/dist/lib/identity-envelope.js +23 -0
- package/dist/lib/kb-candidate.js +65 -0
- package/dist/lib/kb_acl.js +98 -0
- package/dist/lib/login.js +353 -0
- package/dist/lib/mcp-fetchers.js +130 -0
- package/dist/lib/mcp-restart.js +47 -0
- package/dist/lib/observability.js +805 -0
- package/dist/lib/open-url.js +33 -0
- package/dist/lib/orphan-guard.js +70 -0
- package/dist/lib/packaged.js +21 -0
- package/dist/lib/reconcile-sessions.js +171 -0
- package/dist/lib/redactor.js +89 -0
- package/dist/lib/relationship-candidate-query.js +27 -0
- package/dist/lib/render.js +611 -0
- package/dist/lib/rules/applicability.js +64 -0
- package/dist/lib/rules/attest-code-rule-version.js +47 -0
- package/dist/lib/rules/attest-notes-location.js +217 -0
- package/dist/lib/rules/attest-rule-version.js +69 -0
- package/dist/lib/rules/canonical-json.js +97 -0
- package/dist/lib/rules/ce0-emit.js +64 -0
- package/dist/lib/rules/ce0-evidence.js +281 -0
- package/dist/lib/rules/ce0-recall-sample.js +82 -0
- package/dist/lib/rules/ce0-rule.js +55 -0
- package/dist/lib/rules/ce0-sampling-bucket.js +15 -0
- package/dist/lib/rules/ce0-store.js +683 -0
- package/dist/lib/rules/ce0-telemetry-project.js +93 -0
- package/dist/lib/rules/ce0-telemetry.js +158 -0
- package/dist/lib/rules/code-rule-registry.js +17 -0
- package/dist/lib/rules/command-match.js +185 -0
- package/dist/lib/rules/consult-evidence-binding.js +27 -0
- package/dist/lib/rules/consultation-capture-adapter.js +193 -0
- package/dist/lib/rules/content-match.js +56 -0
- package/dist/lib/rules/deny-admission.js +99 -0
- package/dist/lib/rules/durable-observation.js +190 -0
- package/dist/lib/rules/enforce-notes-version.js +421 -0
- package/dist/lib/rules/evaluation-input-hash.js +126 -0
- package/dist/lib/rules/evaluator.js +108 -0
- package/dist/lib/rules/inert-rule-families.js +51 -0
- package/dist/lib/rules/input-authority-resolver.js +241 -0
- package/dist/lib/rules/interception-schema.js +170 -0
- package/dist/lib/rules/interception-store.js +267 -0
- package/dist/lib/rules/live-input-authority.js +66 -0
- package/dist/lib/rules/local-matcher.js +108 -0
- package/dist/lib/rules/local-observe.js +79 -0
- package/dist/lib/rules/local-rule-version-repo.js +214 -0
- package/dist/lib/rules/memory-requirement.js +109 -0
- package/dist/lib/rules/notes-observe.js +39 -0
- package/dist/lib/rules/notes-path.js +261 -0
- package/dist/lib/rules/notes-rule.js +75 -0
- package/dist/lib/rules/observe-adapter.js +114 -0
- package/dist/lib/rules/observed-rule-hash.js +119 -0
- package/dist/lib/rules/prompt-submit-adapter.js +132 -0
- package/dist/lib/rules/requirement-subject.js +240 -0
- package/dist/lib/rules/rule-activity.js +67 -0
- package/dist/lib/rules/rule-version-hash.js +151 -0
- package/dist/lib/rules/runtime-scope.js +55 -0
- package/dist/lib/rules/stop-adapter.js +116 -0
- package/dist/lib/rules/stop-response-snapshot.js +174 -0
- package/dist/lib/rules/types.js +10 -0
- package/dist/lib/rules/ulid.js +46 -0
- package/dist/lib/rules/version-evaluation.js +156 -0
- package/dist/lib/scanner/agent-memory.js +99 -0
- package/dist/lib/scanner/bootstrap-summary.js +87 -0
- package/dist/lib/scanner/cache.js +59 -0
- package/dist/lib/scanner/frontmatter.js +42 -0
- package/dist/lib/scanner/parse-directives.js +69 -0
- package/dist/lib/scanner/parse-structured.js +72 -0
- package/dist/lib/scanner/render.js +73 -0
- package/dist/lib/scanner/scan.js +132 -0
- package/dist/lib/scanner/score.js +38 -0
- package/dist/lib/scanner/scout-mission.js +126 -0
- package/dist/lib/scanner/types.js +7 -0
- package/dist/lib/session-scope.js +195 -0
- package/dist/lib/spool.js +355 -0
- package/dist/lib/staleness.js +100 -0
- package/dist/lib/steer-cache.js +87 -0
- package/dist/lib/tagged-reference.js +20 -0
- package/dist/lib/temporal.js +109 -0
- package/dist/lib/turn-recap-emit.js +67 -0
- package/dist/lib/unwire.js +253 -0
- package/dist/lib/update-check.js +469 -0
- package/dist/lib/update-notifier.js +217 -0
- package/dist/lib/upgrade-apply.js +643 -0
- package/dist/lib/wire.js +1087 -0
- package/dist/lib/workspace.js +96 -0
- package/dist/lib/zip.js +154 -0
- package/dist/pretool-entry.js +37 -0
- package/package.json +75 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.parseKbForgetArgs = parseKbForgetArgs;
|
|
37
|
+
exports.resolveForgetHandle = resolveForgetHandle;
|
|
38
|
+
exports.cascadeRejectForDoc = cascadeRejectForDoc;
|
|
39
|
+
exports.runKbForget = runKbForget;
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const os = __importStar(require("os"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const config_1 = require("../lib/config");
|
|
44
|
+
const kb_acl_1 = require("../lib/kb_acl");
|
|
45
|
+
const render_1 = require("../lib/render");
|
|
46
|
+
const http_1 = require("../lib/http");
|
|
47
|
+
const relationship_candidate_query_1 = require("../lib/relationship-candidate-query");
|
|
48
|
+
const session_scope_1 = require("../lib/session-scope");
|
|
49
|
+
const kb_add_1 = require("./kb_add");
|
|
50
|
+
const kb_reingest_1 = require("./kb_reingest");
|
|
51
|
+
const VALUE_FLAGS = new Set(["--workspace", "--reason"]);
|
|
52
|
+
const KBDOC_PREFIX = "kbdoc:";
|
|
53
|
+
const NOTE_PREFIX = "note:";
|
|
54
|
+
const FORGET_TIMEOUT_MS = 30_000;
|
|
55
|
+
function parseKbForgetArgs(argv) {
|
|
56
|
+
const out = {};
|
|
57
|
+
let positional = null;
|
|
58
|
+
for (let i = 0; i < argv.length; i++) {
|
|
59
|
+
const a = argv[i];
|
|
60
|
+
if (VALUE_FLAGS.has(a)) {
|
|
61
|
+
const v = argv[i + 1];
|
|
62
|
+
if (v === undefined) {
|
|
63
|
+
throw new Error(`Missing value for ${a}`);
|
|
64
|
+
}
|
|
65
|
+
if (v.startsWith("--") || v.startsWith("-")) {
|
|
66
|
+
throw new Error(`Missing value for ${a} (got the next flag ${v} instead)`);
|
|
67
|
+
}
|
|
68
|
+
switch (a) {
|
|
69
|
+
case "--workspace":
|
|
70
|
+
out.workspace = v;
|
|
71
|
+
break;
|
|
72
|
+
case "--reason":
|
|
73
|
+
out.reason = v;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
i += 1;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (a.startsWith("--") || a.startsWith("-")) {
|
|
80
|
+
throw new Error(`Unknown flag: ${a}. Supported flags: ${[...VALUE_FLAGS].sort().join(", ")}`);
|
|
81
|
+
}
|
|
82
|
+
if (positional !== null) {
|
|
83
|
+
throw new Error(`\`mla kb forget\` takes exactly one positional input (got '${positional}' and '${a}')`);
|
|
84
|
+
}
|
|
85
|
+
positional = a;
|
|
86
|
+
}
|
|
87
|
+
if (positional === null) {
|
|
88
|
+
throw new Error("`mla kb forget` requires a positional input: kbdoc:<id>, note:<path>, or a bare note path");
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
input: positional,
|
|
92
|
+
workspace: out.workspace,
|
|
93
|
+
reason: out.reason,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
// Client-side handle resolution (was the python worker's identity-vs-filesystem
|
|
98
|
+
// candidate logic, minus the disk read forget never does).
|
|
99
|
+
// ---------------------------------------------------------------------------
|
|
100
|
+
function expandHome(p) {
|
|
101
|
+
if (p === "~")
|
|
102
|
+
return os.homedir();
|
|
103
|
+
if (p.startsWith("~/"))
|
|
104
|
+
return path.join(os.homedir(), p.slice(2));
|
|
105
|
+
return p;
|
|
106
|
+
}
|
|
107
|
+
// Map the operator's input to the handle the route resolves. A real local file is
|
|
108
|
+
// mapped to its vault-relative path (the SAME mapping `kb add` / `kb reingest`
|
|
109
|
+
// use, so the identity matches); anything else (an opaque kbdoc id, a stored
|
|
110
|
+
// externalObjectId, or a path that is not a local file) is passed through as `ref`
|
|
111
|
+
// for the server to canonicalize and resolve. Throws ReingestPreconditionError
|
|
112
|
+
// (-> exit 2) only when a real local file's vault root cannot be resolved.
|
|
113
|
+
function resolveForgetHandle(input) {
|
|
114
|
+
const raw = input.trim();
|
|
115
|
+
if (!raw) {
|
|
116
|
+
throw new kb_reingest_1.ReingestPreconditionError("`mla kb forget` requires a non-empty input");
|
|
117
|
+
}
|
|
118
|
+
// kbdoc:<id>: opaque, never a file. The server does an exact PK load.
|
|
119
|
+
if (raw.startsWith(KBDOC_PREFIX)) {
|
|
120
|
+
const id = raw.slice(KBDOC_PREFIX.length).trim();
|
|
121
|
+
if (!id) {
|
|
122
|
+
throw new kb_reingest_1.ReingestPreconditionError("kbdoc: prefix requires an id");
|
|
123
|
+
}
|
|
124
|
+
return { ref: raw };
|
|
125
|
+
}
|
|
126
|
+
// note:<X> or bare <X>. If X is a real local file, the client maps it to its
|
|
127
|
+
// vault-relative path (filesystem form). Otherwise it is a stored
|
|
128
|
+
// externalObjectId / identity string; pass it through for the server to resolve.
|
|
129
|
+
const rawPath = raw.startsWith(NOTE_PREFIX) ? raw.slice(NOTE_PREFIX.length) : raw;
|
|
130
|
+
const abs = path.resolve(expandHome(rawPath));
|
|
131
|
+
let isFile = false;
|
|
132
|
+
try {
|
|
133
|
+
isFile = fs.existsSync(abs) && fs.statSync(abs).isFile();
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
isFile = false;
|
|
137
|
+
}
|
|
138
|
+
if (isFile) {
|
|
139
|
+
const vaultRoot = (0, kb_reingest_1.resolveReingestVaultRoot)(path.dirname(abs));
|
|
140
|
+
const relPath = (0, kb_add_1.vaultRelPath)(vaultRoot, abs);
|
|
141
|
+
return { relPath };
|
|
142
|
+
}
|
|
143
|
+
return { ref: raw };
|
|
144
|
+
}
|
|
145
|
+
function printPreflight(flags, cfg) {
|
|
146
|
+
const ws = flags.workspace || cfg.workspaceId;
|
|
147
|
+
const reasonHint = flags.reason ? ` reason=${JSON.stringify(flags.reason)}` : "";
|
|
148
|
+
console.log(`mla kb forget workspace=${ws} input=${flags.input}${reasonHint}`);
|
|
149
|
+
}
|
|
150
|
+
// Map an HTTP/network failure to the worker's exit semantics: a 404 (unknown
|
|
151
|
+
// doc), 409 (PURGED terminal), or 422 (bad args) is a precondition -> 2; a
|
|
152
|
+
// network error (no status), a 5xx, or the 500 write-time state race is an
|
|
153
|
+
// operational failure -> 1.
|
|
154
|
+
function exitForHttpError(e) {
|
|
155
|
+
const status = e?.status;
|
|
156
|
+
if (status === 404 || status === 409 || status === 422)
|
|
157
|
+
return 2;
|
|
158
|
+
return 1;
|
|
159
|
+
}
|
|
160
|
+
// Best-effort: after a doc is tombstoned, its PENDING relationship candidates point
|
|
161
|
+
// at a dead artifact and should not linger in the review queue. Keys on the note
|
|
162
|
+
// basename; the route matches either endpoint. A forgotten doc with >200 pending
|
|
163
|
+
// candidates is not realistic, so this reads a single page. Failures are caught and
|
|
164
|
+
// COUNTED (never thrown) so a cascade hiccup cannot mask a successful tombstone,
|
|
165
|
+
// but the caller reports them so the operator knows dangling edges may remain.
|
|
166
|
+
async function cascadeRejectForDoc(canonicalPath, ctx, deps) {
|
|
167
|
+
const key = (0, session_scope_1.noteKey)(canonicalPath);
|
|
168
|
+
let page;
|
|
169
|
+
try {
|
|
170
|
+
page = await deps.fetchPending((0, relationship_candidate_query_1.buildPendingCandidateQuery)(ctx.workspaceId, key, 200));
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return { fetched: 0, rejected: 0, failed: 0, fetchFailed: true };
|
|
174
|
+
}
|
|
175
|
+
let rejected = 0;
|
|
176
|
+
let failed = 0;
|
|
177
|
+
for (const c of page.items) {
|
|
178
|
+
try {
|
|
179
|
+
await deps.submitReject(c.id, {
|
|
180
|
+
workspaceId: ctx.workspaceId,
|
|
181
|
+
userId: ctx.actorUserId,
|
|
182
|
+
note: "[forget-cascade] source document tombstoned",
|
|
183
|
+
});
|
|
184
|
+
rejected++;
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
failed++;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return { fetched: page.items.length, rejected, failed, fetchFailed: false };
|
|
191
|
+
}
|
|
192
|
+
async function runKbForget(argv) {
|
|
193
|
+
// Parse flags BEFORE loading config so `--workspace <id>` can override the
|
|
194
|
+
// marker-resolved workspace (T1.1 folder = workspace) without requiring the
|
|
195
|
+
// current directory to be activated.
|
|
196
|
+
let flags;
|
|
197
|
+
try {
|
|
198
|
+
flags = parseKbForgetArgs(argv);
|
|
199
|
+
}
|
|
200
|
+
catch (e) {
|
|
201
|
+
console.error(e.message);
|
|
202
|
+
return 2;
|
|
203
|
+
}
|
|
204
|
+
let cfg;
|
|
205
|
+
try {
|
|
206
|
+
cfg = (0, config_1.readKbConfig)(flags.workspace);
|
|
207
|
+
}
|
|
208
|
+
catch (e) {
|
|
209
|
+
console.error(e.message);
|
|
210
|
+
return 2;
|
|
211
|
+
}
|
|
212
|
+
// §13.14 owner-only ACL: verify the configured actor is a workspace OWNER
|
|
213
|
+
// before the tombstone side effect.
|
|
214
|
+
try {
|
|
215
|
+
await (0, kb_acl_1.verifyKbActorIsOwner)(cfg);
|
|
216
|
+
}
|
|
217
|
+
catch (e) {
|
|
218
|
+
if (e instanceof kb_acl_1.KbOwnerCheckError) {
|
|
219
|
+
console.error(e.message);
|
|
220
|
+
return 2;
|
|
221
|
+
}
|
|
222
|
+
throw e;
|
|
223
|
+
}
|
|
224
|
+
const workspaceId = flags.workspace || cfg.workspaceId;
|
|
225
|
+
printPreflight(flags, cfg);
|
|
226
|
+
// Pick the server-resolvable handle. A real local file maps to its vault-relative
|
|
227
|
+
// path (vault root resolved client-side); an unresolved vault root for a real
|
|
228
|
+
// file is a precondition (-> 2).
|
|
229
|
+
let handle;
|
|
230
|
+
try {
|
|
231
|
+
handle = resolveForgetHandle(flags.input);
|
|
232
|
+
}
|
|
233
|
+
catch (e) {
|
|
234
|
+
if (e instanceof kb_reingest_1.ReingestPreconditionError) {
|
|
235
|
+
console.error(e.message);
|
|
236
|
+
return 2;
|
|
237
|
+
}
|
|
238
|
+
throw e;
|
|
239
|
+
}
|
|
240
|
+
const body = {
|
|
241
|
+
workspaceId,
|
|
242
|
+
actor: cfg.actorUserId,
|
|
243
|
+
reason: flags.reason ?? undefined,
|
|
244
|
+
...handle,
|
|
245
|
+
};
|
|
246
|
+
let receipt;
|
|
247
|
+
try {
|
|
248
|
+
const res = await (0, http_1.intelPost)(cfg, "/internal/v1/kb/forget", body, FORGET_TIMEOUT_MS);
|
|
249
|
+
receipt = res.receipt;
|
|
250
|
+
}
|
|
251
|
+
catch (e) {
|
|
252
|
+
console.error(`kb forget failed: ${e.message}`);
|
|
253
|
+
return exitForHttpError(e);
|
|
254
|
+
}
|
|
255
|
+
if (!receipt) {
|
|
256
|
+
console.error("kb forget: the route returned no receipt.");
|
|
257
|
+
return 1;
|
|
258
|
+
}
|
|
259
|
+
console.log((0, render_1.renderKbForgetReceipt)(receipt));
|
|
260
|
+
console.log("");
|
|
261
|
+
// Cascade: clear PENDING relationship candidates that referenced the now-dead doc.
|
|
262
|
+
// Only a fresh tombstone needs it; an already_tombstoned doc's candidates were
|
|
263
|
+
// cleared on the first forget.
|
|
264
|
+
if (receipt.outcome === "tombstoned") {
|
|
265
|
+
const cascadeDeps = {
|
|
266
|
+
fetchPending: (qs) => (0, http_1.get)(cfg, `/internal/v1/relationship-candidates?${qs}`, 12000),
|
|
267
|
+
submitReject: async (id, rejectBody) => {
|
|
268
|
+
await (0, http_1.post)(cfg, `/internal/v1/relationship-candidates/${encodeURIComponent(id)}/reject`, rejectBody, 12000);
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
const r = await cascadeRejectForDoc(receipt.canonicalPath, { workspaceId: cfg.workspaceId, actorUserId: cfg.actorUserId }, cascadeDeps);
|
|
272
|
+
if (r.rejected > 0) {
|
|
273
|
+
console.log(`Also cleared ${r.rejected} orphaned relationship candidate${r.rejected === 1 ? "" : "s"} that referenced this doc.`);
|
|
274
|
+
}
|
|
275
|
+
if (r.fetchFailed) {
|
|
276
|
+
console.error("Warning: could not check for orphaned relationship candidates; some may remain in the review queue.");
|
|
277
|
+
}
|
|
278
|
+
else if (r.failed > 0) {
|
|
279
|
+
console.error(`Warning: ${r.failed} orphaned relationship candidate${r.failed === 1 ? "" : "s"} could not be cleared; clear them with mla kb review <id> --reject.`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return 0;
|
|
283
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// `mla kb move` is a BLOCKED capability in the governed (slice-A) model.
|
|
3
|
+
//
|
|
4
|
+
// A governed document's identity IS its source tuple (sourceSystem,
|
|
5
|
+
// sourceTenantId, externalObjectId). For a note, externalObjectId is derived
|
|
6
|
+
// from its path, so re-pathing a note produces a DIFFERENT governed document,
|
|
7
|
+
// not a rename of the existing one. The legacy worker faked a rename by
|
|
8
|
+
// rewriting a row's canonical_path and array-appending the old path to
|
|
9
|
+
// path_aliases while preserving parent_uuid; the slice-A reshape dropped that
|
|
10
|
+
// table shape and every method it leaned on (move_document,
|
|
11
|
+
// resolve_by_canonical_path, path_aliases, parent_uuid, current_posture).
|
|
12
|
+
//
|
|
13
|
+
// Slice A ships no redirect / alias primitive that would let a new path inherit
|
|
14
|
+
// the old document's stable id, revisions, human review verdicts, and audit
|
|
15
|
+
// trail. Until that primitive lands, a true identity-preserving move is not
|
|
16
|
+
// expressible, so this command refuses fast (no config load, no owner check, no
|
|
17
|
+
// subprocess) rather than silently forking a document's history.
|
|
18
|
+
//
|
|
19
|
+
// Workaround (history does NOT follow the content):
|
|
20
|
+
// 1. mla kb add <new-path> - ingest the content under its new identity
|
|
21
|
+
// 2. mla kb forget <old> - tombstone the old document
|
|
22
|
+
//
|
|
23
|
+
// Exit code 2 = unsupported / refused, consistent with the other curation
|
|
24
|
+
// commands' usage-error code.
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.MOVE_BLOCKED_MESSAGE = void 0;
|
|
27
|
+
exports.runKbMove = runKbMove;
|
|
28
|
+
exports.MOVE_BLOCKED_MESSAGE = [
|
|
29
|
+
"`mla kb move` is blocked in the governed model.",
|
|
30
|
+
"",
|
|
31
|
+
"A document's identity is its source tuple (sourceSystem, sourceTenantId,",
|
|
32
|
+
"externalObjectId). For a note, externalObjectId is derived from its path, so",
|
|
33
|
+
"re-pathing it is a different governed document, not a rename. Slice A ships no",
|
|
34
|
+
"redirect / alias primitive that would carry the old document's id, revisions,",
|
|
35
|
+
"review verdicts, and audit trail to the new path, so a true move is not yet",
|
|
36
|
+
"expressible.",
|
|
37
|
+
"",
|
|
38
|
+
"Workaround (history does NOT follow the content):",
|
|
39
|
+
" 1. mla kb add <new-path> - ingest the content under its new identity",
|
|
40
|
+
" 2. mla kb forget <old> - tombstone the old document",
|
|
41
|
+
].join("\n");
|
|
42
|
+
async function runKbMove(_argv) {
|
|
43
|
+
console.error(exports.MOVE_BLOCKED_MESSAGE);
|
|
44
|
+
return 2;
|
|
45
|
+
}
|