akm-cli 0.9.0-beta.5 → 0.9.0-beta.51
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/CHANGELOG.md +711 -0
- package/README.md +12 -4
- package/dist/akm +38 -0
- package/dist/akm-migrate-storage +38 -0
- package/dist/assets/profiles/default.json +9 -4
- package/dist/assets/profiles/frequent.json +1 -1
- package/dist/assets/profiles/memory-focus.json +1 -1
- package/dist/assets/profiles/quick.json +1 -1
- package/dist/assets/profiles/synthesize.json +15 -0
- package/dist/assets/profiles/thorough.json +1 -1
- package/dist/assets/prompts/consolidate-system.md +23 -0
- package/dist/assets/prompts/contradiction-judge.md +33 -0
- package/dist/assets/prompts/distill-knowledge-system.md +22 -0
- package/dist/assets/prompts/distill-lesson-system.md +36 -0
- package/dist/assets/prompts/extract-session.md +6 -2
- package/dist/assets/prompts/graph-extract-system.md +1 -0
- package/dist/assets/prompts/graph-extract-user-prompt.md +1 -1
- package/dist/assets/prompts/memory-infer-system.md +1 -0
- package/dist/assets/prompts/memory-infer-user.md +5 -0
- package/dist/assets/prompts/metadata-enhance-system.md +1 -0
- package/dist/assets/prompts/procedural-system.md +44 -0
- package/dist/assets/prompts/recombine-system.md +40 -0
- package/dist/assets/prompts/staleness-detect-system.md +6 -0
- package/dist/assets/prompts/validate-summary-judge.md +1 -0
- package/dist/assets/stash-skeleton/facts/conventions/assets/agent.md +38 -0
- package/dist/assets/stash-skeleton/facts/conventions/assets/command.md +38 -0
- package/dist/assets/stash-skeleton/facts/conventions/assets/fact.md +39 -0
- package/dist/assets/stash-skeleton/facts/conventions/assets/knowledge.md +40 -0
- package/dist/assets/stash-skeleton/facts/conventions/assets/lesson.md +43 -0
- package/dist/assets/stash-skeleton/facts/conventions/assets/memory.md +38 -0
- package/dist/assets/stash-skeleton/facts/conventions/assets/script.md +43 -0
- package/dist/assets/stash-skeleton/facts/conventions/assets/skill.md +40 -0
- package/dist/assets/stash-skeleton/facts/conventions/assets/workflow.md +43 -0
- package/dist/assets/templates/html/health.html +281 -111
- package/dist/assets/wiki/ingest-workflow-template.md +38 -10
- package/dist/cli/parse-args.js +46 -1
- package/dist/cli/shared.js +28 -0
- package/dist/cli.js +27 -11
- package/dist/commands/agent/agent-dispatch.js +2 -2
- package/dist/commands/agent/agent-support.js +0 -7
- package/dist/commands/agent/contribute-cli.js +17 -4
- package/dist/commands/config-cli.js +18 -2
- package/dist/commands/env/child-env.js +47 -0
- package/dist/commands/env/env-cli.js +33 -26
- package/dist/commands/env/secret-cli.js +36 -22
- package/dist/commands/feedback-cli.js +15 -6
- package/dist/commands/graph/graph-cli.js +5 -13
- package/dist/commands/graph/graph.js +76 -72
- package/dist/commands/health/checks.js +49 -1
- package/dist/commands/health/html-report.js +422 -80
- package/dist/commands/health.js +386 -9
- package/dist/commands/improve/calibration.js +161 -0
- package/dist/commands/improve/consolidate/chunking.js +141 -0
- package/dist/commands/improve/consolidate/eligibility.js +81 -0
- package/dist/commands/improve/consolidate/merge.js +145 -0
- package/dist/commands/improve/consolidate/sanitize.js +231 -0
- package/dist/commands/{lint.js → improve/consolidate/types.js} +1 -1
- package/dist/commands/improve/consolidate.js +635 -660
- package/dist/commands/improve/dedup.js +482 -0
- package/dist/commands/improve/distill.js +159 -69
- package/dist/commands/improve/eligibility.js +434 -0
- package/dist/commands/improve/encoding-salience.js +205 -0
- package/dist/commands/improve/extract-cli.js +124 -2
- package/dist/commands/improve/extract-prompt.js +39 -2
- package/dist/commands/improve/extract-watch.js +140 -0
- package/dist/commands/improve/extract.js +389 -40
- package/dist/commands/improve/feedback-valence.js +54 -0
- package/dist/commands/improve/homeostatic.js +467 -0
- package/dist/commands/improve/improve-auto-accept.js +138 -7
- package/dist/commands/improve/improve-cli.js +36 -61
- package/dist/commands/improve/improve-profiles.js +14 -0
- package/dist/commands/improve/improve-result-file.js +14 -25
- package/dist/commands/improve/improve-session.js +58 -0
- package/dist/commands/improve/improve.js +485 -2498
- package/dist/commands/improve/locks.js +154 -0
- package/dist/commands/improve/loop-stages.js +1083 -0
- package/dist/commands/improve/memory/memory-contradiction-detect.js +23 -28
- package/dist/commands/improve/outcome-loop.js +256 -0
- package/dist/commands/improve/preparation.js +1966 -0
- package/dist/commands/improve/proactive-maintenance.js +115 -0
- package/dist/commands/improve/procedural.js +418 -0
- package/dist/commands/improve/recombine.js +850 -0
- package/dist/commands/improve/reflect-noise.js +0 -0
- package/dist/commands/improve/reflect.js +183 -40
- package/dist/commands/improve/salience.js +438 -0
- package/dist/commands/improve/triage.js +93 -0
- package/dist/commands/lint/agent-linter.js +19 -24
- package/dist/commands/lint/base-linter.js +173 -60
- package/dist/commands/lint/command-linter.js +19 -24
- package/dist/commands/lint/env-key-rules.js +38 -1
- package/dist/commands/lint/fact-linter.js +39 -0
- package/dist/commands/lint/index.js +31 -13
- package/dist/commands/lint/memory-linter.js +1 -1
- package/dist/commands/lint/registry.js +7 -2
- package/dist/commands/lint/task-linter.js +3 -3
- package/dist/commands/lint/workflow-linter.js +26 -1
- package/dist/commands/proposal/drain-policies.js +5 -0
- package/dist/commands/proposal/drain.js +43 -50
- package/dist/commands/proposal/proposal-cli.js +21 -31
- package/dist/commands/proposal/proposal.js +5 -0
- package/dist/commands/proposal/propose.js +7 -2
- package/dist/commands/proposal/validators/proposal-quality-validators.js +9 -8
- package/dist/commands/proposal/validators/proposals.js +189 -63
- package/dist/commands/read/curate.js +414 -94
- package/dist/commands/read/knowledge.js +6 -3
- package/dist/commands/read/search-cli.js +9 -4
- package/dist/commands/read/search.js +10 -6
- package/dist/commands/read/show.js +86 -7
- package/dist/commands/sources/init.js +49 -17
- package/dist/commands/sources/installed-stashes.js +11 -3
- package/dist/commands/sources/schema-repair.js +43 -45
- package/dist/commands/sources/self-update.js +2 -2
- package/dist/commands/sources/source-add.js +7 -3
- package/dist/commands/sources/stash-cli.js +28 -40
- package/dist/commands/sources/stash-skeleton.js +23 -8
- package/dist/commands/tasks/tasks-cli.js +19 -27
- package/dist/commands/tasks/tasks.js +39 -11
- package/dist/commands/wiki-cli.js +21 -35
- package/dist/core/asset/asset-registry.js +3 -1
- package/dist/core/asset/asset-spec.js +18 -2
- package/dist/core/asset/frontmatter.js +166 -167
- package/dist/core/asset/markdown.js +8 -0
- package/dist/core/authoring-rules.js +92 -0
- package/dist/core/common.js +0 -5
- package/dist/core/config/config-migration.js +12 -11
- package/dist/core/config/config-schema.js +340 -56
- package/dist/core/config/config-types.js +3 -3
- package/dist/core/config/config.js +28 -7
- package/dist/core/events.js +3 -7
- package/dist/core/improve-types.js +11 -8
- package/dist/core/logs-db.js +10 -66
- package/dist/core/parse.js +36 -16
- package/dist/core/paths.js +3 -0
- package/dist/core/standards/resolve-standards-context.js +87 -0
- package/dist/core/standards/resolve-stash-standards.js +99 -0
- package/dist/core/standards/resolve-type-conventions.js +66 -0
- package/dist/core/state/migrations.js +714 -0
- package/dist/core/state-db.js +525 -474
- package/dist/indexer/db/db.js +439 -247
- package/dist/indexer/db/graph-db.js +129 -86
- package/dist/indexer/ensure-index.js +152 -17
- package/dist/indexer/graph/graph-boost.js +51 -41
- package/dist/indexer/graph/graph-extraction.js +218 -4
- package/dist/indexer/index-writer-lock.js +99 -0
- package/dist/indexer/indexer.js +123 -221
- package/dist/indexer/passes/dir-staleness.js +114 -0
- package/dist/indexer/passes/memory-inference.js +13 -5
- package/dist/indexer/passes/staleness-detect.js +2 -5
- package/dist/indexer/search/db-search.js +19 -6
- package/dist/indexer/search/ranking-contributors.js +22 -0
- package/dist/indexer/search/ranking.js +4 -0
- package/dist/indexer/search/search-source.js +17 -18
- package/dist/indexer/search/semantic-status.js +4 -0
- package/dist/indexer/walk/matchers.js +9 -0
- package/dist/integrations/agent/config.js +6 -53
- package/dist/integrations/agent/index.js +2 -18
- package/dist/integrations/agent/prompts.js +75 -9
- package/dist/integrations/agent/runner-dispatch.js +59 -0
- package/dist/integrations/harnesses/claude/session-log.js +11 -1
- package/dist/integrations/harnesses/index.js +2 -3
- package/dist/integrations/harnesses/opencode/session-log.js +173 -3
- package/dist/integrations/harnesses/opencode-sdk/index.js +2 -2
- package/dist/integrations/harnesses/opencode-sdk/sdk-runner.js +0 -2
- package/dist/integrations/session-logs/index.js +16 -0
- package/dist/llm/client.js +45 -15
- package/dist/llm/embedder.js +42 -3
- package/dist/llm/embedders/deterministic.js +66 -0
- package/dist/llm/embedders/local.js +66 -2
- package/dist/llm/feature-gate.js +8 -4
- package/dist/llm/graph-extract.js +67 -44
- package/dist/llm/memory-infer-impl.js +138 -0
- package/dist/llm/memory-infer.js +1 -127
- package/dist/llm/metadata-enhance.js +44 -31
- package/dist/llm/structured-call.js +49 -0
- package/dist/migrate-storage-node.mjs +8 -0
- package/dist/output/context.js +5 -5
- package/dist/output/renderers.js +74 -2
- package/dist/output/shapes/curate.js +14 -2
- package/dist/output/shapes/passthrough.js +0 -1
- package/dist/output/text/helpers.js +16 -1
- package/dist/registry/providers/skills-sh.js +21 -147
- package/dist/registry/providers/static-index.js +15 -157
- package/dist/registry/resolve.js +22 -9
- package/dist/runtime.js +25 -1
- package/dist/scripts/migrate-storage.js +2617 -1961
- package/dist/scripts/migrations/import-fs-improve-runs-to-db.js +759 -510
- package/dist/setup/setup.js +29 -8
- package/dist/sources/include.js +6 -2
- package/dist/sources/providers/filesystem.js +0 -1
- package/dist/sources/providers/git-install.js +210 -0
- package/dist/sources/providers/git-provider.js +234 -0
- package/dist/sources/providers/git-stash.js +248 -0
- package/dist/sources/providers/git.js +10 -661
- package/dist/sources/providers/npm.js +2 -6
- package/dist/sources/providers/provider-utils.js +13 -7
- package/dist/sources/providers/sync-from-ref.js +9 -1
- package/dist/sources/providers/tar-utils.js +16 -8
- package/dist/sources/providers/website.js +9 -5
- package/dist/sources/website-ingest.js +187 -29
- package/dist/sources/wiki-fetchers/registry.js +53 -0
- package/dist/sources/wiki-fetchers/youtube.js +239 -0
- package/dist/storage/database.js +45 -10
- package/dist/storage/managed-db.js +82 -0
- package/dist/storage/repositories/registry-cache.js +92 -0
- package/dist/storage/sqlite-pragmas.js +146 -0
- package/dist/tasks/backends/cron.js +1 -1
- package/dist/tasks/backends/launchd.js +1 -1
- package/dist/tasks/backends/schtasks.js +1 -1
- package/dist/tasks/{resolveAkmBin.js → resolve-akm-bin.js} +2 -2
- package/dist/tasks/runner.js +5 -13
- package/dist/text-import-hook.mjs +0 -0
- package/dist/wiki/wiki.js +37 -0
- package/dist/workflows/db.js +3 -4
- package/dist/workflows/runtime/runs.js +1 -117
- package/dist/workflows/runtime/workflow-asset-loader.js +125 -0
- package/dist/workflows/validate-summary.js +2 -7
- package/docs/data-and-telemetry.md +3 -2
- package/docs/migration/release-notes/0.9.0.md +39 -0
- package/package.json +13 -11
- package/dist/commands/db-cli.js +0 -23
- package/dist/indexer/db/db-backup.js +0 -376
|
@@ -11,10 +11,9 @@ import { writeFileAtomic } from "../core/common.js";
|
|
|
11
11
|
import { FEEDBACK_FAILURE_MODES, loadConfig } from "../core/config/config.js";
|
|
12
12
|
import { UsageError } from "../core/errors.js";
|
|
13
13
|
import { appendEvent } from "../core/events.js";
|
|
14
|
+
import { getDbPath } from "../core/paths.js";
|
|
14
15
|
import { warn } from "../core/warn.js";
|
|
15
16
|
import { applyFeedbackToUtilityScore, closeDatabase, findEntryIdByRef, getEntryFilePathById, openExistingDatabase, } from "../indexer/db/db.js";
|
|
16
|
-
import { ensureIndex } from "../indexer/ensure-index.js";
|
|
17
|
-
import { resolveSourceEntries } from "../indexer/search/search-source.js";
|
|
18
17
|
import { countFeedbackSignals, insertUsageEvent } from "../indexer/usage/usage-events.js";
|
|
19
18
|
// ── Tag validation ────────────────────────────────────────────────────────────
|
|
20
19
|
const TAG_KEY_RE = /^[a-z_][a-z0-9_]*$/;
|
|
@@ -203,11 +202,21 @@ export const feedbackCommand = defineCommand({
|
|
|
203
202
|
...(validatedTags.length > 0 ? { tags: validatedTags } : {}),
|
|
204
203
|
};
|
|
205
204
|
const metadataStr = Object.keys(metadataObj).length > 1 ? JSON.stringify(metadataObj) : undefined;
|
|
206
|
-
//
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
// Feedback only needs the index to exist, not to be current. A stale index
|
|
206
|
+
// is fine — the ref lookup works against any populated DB. We do NOT call
|
|
207
|
+
// ensureIndex here: it either blocks (3+ min inline reindex) or spawns a
|
|
208
|
+
// background process that holds the writer lock, causing the feedback write
|
|
209
|
+
// to spin-wait for the full reindex duration. If the DB is absent we give a
|
|
210
|
+
// clear error below rather than silently triggering a rebuild.
|
|
211
|
+
if (!fs.existsSync(getDbPath())) {
|
|
212
|
+
throw new UsageError("Index not found. Run 'akm index' first to build the index before recording feedback.", "MISSING_REQUIRED_ARGUMENT", "akm index");
|
|
210
213
|
}
|
|
214
|
+
// Feedback writes exactly 2 rows (usage_events + utility_score). SQLite
|
|
215
|
+
// WAL mode + busy_timeout=30s handles concurrent access with an ongoing
|
|
216
|
+
// `akm improve` run without needing the application-level writer lock.
|
|
217
|
+
// The lock was originally needed to prevent feedback from racing a
|
|
218
|
+
// background reindex it spawned — now that ensureIndex is removed, holding
|
|
219
|
+
// the lock only causes feedback to block for the full improve run duration.
|
|
211
220
|
let utilityResult;
|
|
212
221
|
const db = openExistingDatabase();
|
|
213
222
|
try {
|
|
@@ -9,12 +9,9 @@
|
|
|
9
9
|
* same JSON envelope (stdout/stderr/exit-code) as the inline `runWithJsonErrors`
|
|
10
10
|
* form it replaces.
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { defineJsonCommand, output, runWithJsonErrors } from "../../cli/shared.js";
|
|
12
|
+
import { parsePositiveIntFlag } from "../../cli/parse-args.js";
|
|
13
|
+
import { defineGroupCommand, defineJsonCommand, output } from "../../cli/shared.js";
|
|
15
14
|
import { akmGraphEntities, akmGraphEntity, akmGraphExport, akmGraphOrphans, akmGraphRelated, akmGraphRelations, akmGraphSummary, akmGraphUpdate, } from "./graph.js";
|
|
16
|
-
// Single source of truth: the routing set is derived from the subCommands keys
|
|
17
|
-
// (M10) so adding a subcommand can never silently desync from `hasSubcommand`.
|
|
18
15
|
const graphSubCommands = {
|
|
19
16
|
summary: defineJsonCommand({
|
|
20
17
|
meta: { name: "summary", description: "Show entity-graph counts and quality telemetry" },
|
|
@@ -118,15 +115,10 @@ const graphSubCommands = {
|
|
|
118
115
|
},
|
|
119
116
|
}),
|
|
120
117
|
};
|
|
121
|
-
const
|
|
122
|
-
export const graphCommand = defineCommand({
|
|
118
|
+
export const graphCommand = defineGroupCommand({
|
|
123
119
|
meta: { name: "graph", description: "Inspect the indexed entity graph stored in SQLite" },
|
|
124
120
|
subCommands: graphSubCommands,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (hasSubcommand(args, GRAPH_SUBCOMMAND_SET))
|
|
128
|
-
return;
|
|
129
|
-
output("graph-summary", akmGraphSummary());
|
|
130
|
-
});
|
|
121
|
+
defaultRun() {
|
|
122
|
+
output("graph-summary", akmGraphSummary());
|
|
131
123
|
},
|
|
132
124
|
});
|
|
@@ -8,10 +8,11 @@ import { loadConfig } from "../../core/config/config.js";
|
|
|
8
8
|
import { NotFoundError, UsageError } from "../../core/errors.js";
|
|
9
9
|
import { getDbPath } from "../../core/paths.js";
|
|
10
10
|
import { warn } from "../../core/warn.js";
|
|
11
|
-
import { closeDatabase, findEntryIdByRef, getEntryById, getEntryRefRowsForStashRoot,
|
|
11
|
+
import { closeDatabase, findEntryIdByRef, getEntryById, getEntryRefRowsForStashRoot, openExistingDatabase, openIndexDatabase, } from "../../indexer/db/db.js";
|
|
12
12
|
import { loadStoredGraphSnapshot } from "../../indexer/db/graph-db.js";
|
|
13
13
|
import { listRelatedPathsForFile } from "../../indexer/graph/graph-boost.js";
|
|
14
14
|
import { runGraphExtractionPass } from "../../indexer/graph/graph-extraction.js";
|
|
15
|
+
import { withIndexWriterLease } from "../../indexer/index-writer-lock.js";
|
|
15
16
|
import { lookup } from "../../indexer/indexer.js";
|
|
16
17
|
import { findSourceForPath, resolveSourceEntries } from "../../indexer/search/search-source.js";
|
|
17
18
|
import { resolveAssetPath } from "../../indexer/walk/path-resolver.js";
|
|
@@ -375,85 +376,88 @@ export async function akmGraphUpdate(options) {
|
|
|
375
376
|
}
|
|
376
377
|
}
|
|
377
378
|
const scoped = Array.isArray(options.refs) && options.refs.length > 0;
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
379
|
+
return withIndexWriterLease({ purpose: "graph-update" }, async () => {
|
|
380
|
+
let candidatePaths;
|
|
381
|
+
if (scoped && options.refs) {
|
|
382
|
+
// Resolve each ref to an absolute file path while the writer lease is held
|
|
383
|
+
// so the scoped graph write sees the same index snapshot it resolved from.
|
|
384
|
+
const dbPath = getDbPath();
|
|
385
|
+
let db;
|
|
386
|
+
const resolvedPaths = new Set();
|
|
387
|
+
try {
|
|
388
|
+
db = openIndexDatabase(dbPath);
|
|
389
|
+
for (const ref of options.refs) {
|
|
390
|
+
const trimmed = ref.trim();
|
|
391
|
+
if (!trimmed)
|
|
392
|
+
continue;
|
|
393
|
+
const entryId = findEntryIdByRef(db, trimmed);
|
|
394
|
+
if (entryId === undefined) {
|
|
395
|
+
warn(`[graph] ref not found in index, skipping: ${trimmed}`);
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
const row = getEntryById(db, entryId);
|
|
399
|
+
if (!row?.filePath) {
|
|
400
|
+
warn(`[graph] could not resolve path for ref, skipping: ${trimmed}`);
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
resolvedPaths.add(row.filePath);
|
|
394
404
|
}
|
|
395
|
-
const row = getEntryById(db, entryId);
|
|
396
|
-
if (!row?.filePath) {
|
|
397
|
-
warn(`[graph] could not resolve path for ref, skipping: ${trimmed}`);
|
|
398
|
-
continue;
|
|
399
|
-
}
|
|
400
|
-
resolvedPaths.add(row.filePath);
|
|
401
405
|
}
|
|
406
|
+
finally {
|
|
407
|
+
if (db)
|
|
408
|
+
closeDatabase(db);
|
|
409
|
+
}
|
|
410
|
+
if (resolvedPaths.size === 0) {
|
|
411
|
+
warn("[graph] none of the provided refs resolved to indexed paths — no extraction performed.");
|
|
412
|
+
return {
|
|
413
|
+
shape: "graph-update",
|
|
414
|
+
ok: true,
|
|
415
|
+
filesExtracted: 0,
|
|
416
|
+
entitiesUpserted: 0,
|
|
417
|
+
relationsUpserted: 0,
|
|
418
|
+
durationMs: 0,
|
|
419
|
+
scoped: true,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
candidatePaths = resolvedPaths;
|
|
402
423
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
424
|
+
const extractionFn = options.graphExtractionFn ?? runGraphExtractionPass;
|
|
425
|
+
const passOptions = candidatePaths ? { candidatePaths } : {};
|
|
426
|
+
let db;
|
|
427
|
+
const startMs = Date.now();
|
|
428
|
+
try {
|
|
429
|
+
db = openIndexDatabase(getDbPath());
|
|
430
|
+
const onProgress = (event) => {
|
|
431
|
+
if (!event.currentPath)
|
|
432
|
+
return;
|
|
433
|
+
const file = path.basename(event.currentPath);
|
|
434
|
+
warn(`[graph] extracting ${event.processed}/${event.total} ${file}`);
|
|
435
|
+
};
|
|
436
|
+
const result = await extractionFn({
|
|
437
|
+
config,
|
|
438
|
+
sources,
|
|
439
|
+
signal: undefined,
|
|
440
|
+
db,
|
|
441
|
+
reEnrich: false,
|
|
442
|
+
onProgress,
|
|
443
|
+
options: passOptions,
|
|
444
|
+
});
|
|
445
|
+
const durationMs = Date.now() - startMs;
|
|
409
446
|
return {
|
|
410
447
|
shape: "graph-update",
|
|
411
448
|
ok: true,
|
|
412
|
-
filesExtracted:
|
|
413
|
-
entitiesUpserted:
|
|
414
|
-
relationsUpserted:
|
|
415
|
-
durationMs
|
|
416
|
-
scoped
|
|
449
|
+
filesExtracted: result.quality.extractedFiles,
|
|
450
|
+
entitiesUpserted: result.quality.entityCount,
|
|
451
|
+
relationsUpserted: result.quality.relationCount,
|
|
452
|
+
durationMs,
|
|
453
|
+
scoped,
|
|
417
454
|
};
|
|
418
455
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
const startMs = Date.now();
|
|
425
|
-
try {
|
|
426
|
-
db = openDatabase(getDbPath());
|
|
427
|
-
const onProgress = (event) => {
|
|
428
|
-
if (!event.currentPath)
|
|
429
|
-
return;
|
|
430
|
-
const file = path.basename(event.currentPath);
|
|
431
|
-
warn(`[graph] extracting ${event.processed}/${event.total} ${file}`);
|
|
432
|
-
};
|
|
433
|
-
const result = await extractionFn({
|
|
434
|
-
config,
|
|
435
|
-
sources,
|
|
436
|
-
signal: undefined,
|
|
437
|
-
db,
|
|
438
|
-
reEnrich: false,
|
|
439
|
-
onProgress,
|
|
440
|
-
options: passOptions,
|
|
441
|
-
});
|
|
442
|
-
const durationMs = Date.now() - startMs;
|
|
443
|
-
return {
|
|
444
|
-
shape: "graph-update",
|
|
445
|
-
ok: true,
|
|
446
|
-
filesExtracted: result.quality.extractedFiles,
|
|
447
|
-
entitiesUpserted: result.quality.entityCount,
|
|
448
|
-
relationsUpserted: result.quality.relationCount,
|
|
449
|
-
durationMs,
|
|
450
|
-
scoped,
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
finally {
|
|
454
|
-
if (db)
|
|
455
|
-
closeDatabase(db);
|
|
456
|
-
}
|
|
456
|
+
finally {
|
|
457
|
+
if (db)
|
|
458
|
+
closeDatabase(db);
|
|
459
|
+
}
|
|
460
|
+
});
|
|
457
461
|
}
|
|
458
462
|
async function resolveGraphTarget(ref, source) {
|
|
459
463
|
const parsedRef = parseAssetRef(ref);
|
|
@@ -257,6 +257,54 @@ export const HEALTH_CHECKS = [
|
|
|
257
257
|
};
|
|
258
258
|
},
|
|
259
259
|
},
|
|
260
|
+
{
|
|
261
|
+
// #603: pool-saturation advisory. The raw `sessionsScanned` count fired on
|
|
262
|
+
// normal cadence changes (the Jun 12 false alarm). Instead track the ratio
|
|
263
|
+
// of NEW (unseen) sessions to the total session pool extract evaluated in
|
|
264
|
+
// the window: a low ratio is the *expected* steady state, only a near-zero
|
|
265
|
+
// ratio signals a possible discovery/dedup bug.
|
|
266
|
+
//
|
|
267
|
+
// unseen ≈ `sessionsScanned` (extract only processes new sessions; already-
|
|
268
|
+
// seen ones are deduped into `sessionsSkipped`). total = scanned + skipped.
|
|
269
|
+
// This is a heuristic approximation — `sessionsSkipped` also folds in
|
|
270
|
+
// too-short skips — so the check is informational and never gates status.
|
|
271
|
+
name: "pool-saturation",
|
|
272
|
+
channel: "advisory",
|
|
273
|
+
run: (ctx) => {
|
|
274
|
+
const sx = ctx.sessionExtraction;
|
|
275
|
+
const total = sx.sessionsScanned + sx.sessionsSkipped;
|
|
276
|
+
const unseen = sx.sessionsScanned;
|
|
277
|
+
const ratio = total > 0 ? unseen / total : null;
|
|
278
|
+
const pct = ratio === null ? null : Math.round(ratio * 1000) / 10;
|
|
279
|
+
let status = "pass";
|
|
280
|
+
let confidence = "low";
|
|
281
|
+
let message;
|
|
282
|
+
if (!sx.ran || ratio === null) {
|
|
283
|
+
message = "Pool saturation: no extract activity in the window — no signal.";
|
|
284
|
+
}
|
|
285
|
+
else if (ratio < 0.02) {
|
|
286
|
+
status = "warn";
|
|
287
|
+
confidence = "medium";
|
|
288
|
+
message = `Session pool near-exhausted: only ${pct}% of the ${total}-session pool was new (<2%). Possible discovery/dedup bug — verify extract is still finding new sessions.`;
|
|
289
|
+
}
|
|
290
|
+
else if (ratio < 0.1) {
|
|
291
|
+
confidence = "medium";
|
|
292
|
+
message = `Session pool saturation: ${pct}% of ${total} sessions were new (<10%, steady-state expected — informational).`;
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
confidence = "medium";
|
|
296
|
+
message = `Session pool healthy: ${pct}% of ${total} sessions were new.`;
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
name: "pool-saturation",
|
|
300
|
+
kind: "heuristic",
|
|
301
|
+
status,
|
|
302
|
+
confidence,
|
|
303
|
+
message,
|
|
304
|
+
evidence: { totalSessions: total, unseenSessions: unseen, saturationRatio: ratio },
|
|
305
|
+
};
|
|
306
|
+
},
|
|
307
|
+
},
|
|
260
308
|
{
|
|
261
309
|
name: "auto-accept-validation",
|
|
262
310
|
channel: "advisory",
|
|
@@ -268,7 +316,7 @@ export const HEALTH_CHECKS = [
|
|
|
268
316
|
status: aa.validationFailed > 0 ? "warn" : "pass",
|
|
269
317
|
confidence: aa.promoted + aa.validationFailed > 0 ? "high" : "low",
|
|
270
318
|
message: aa.validationFailed > 0
|
|
271
|
-
? `${aa.validationFailed}
|
|
319
|
+
? `${aa.validationFailed} auto-accept validation attempt(s) failed after passing the confidence threshold (truncated description, invalid frontmatter, etc.) — the affected proposals remain pending for manual review.`
|
|
272
320
|
: aa.promoted > 0
|
|
273
321
|
? `Auto-accept healthy: ${aa.promoted} proposal(s) promoted, 0 validation failures.`
|
|
274
322
|
: "Auto-accept gate did not run (disabled or no proposals above threshold).",
|