Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"scripts": {
"build": "node scripts/build.mjs",
"typecheck": "node scripts/build.mjs --check",
"test": "npm run build && node dist/tests/run-tests.js",
"typecheck": "tsc --noEmit",
"test": "npm run typecheck && npm run build && node dist/tests/run-tests.js",
"start": "npm run build && node dist/src/cli.js",
"codex": "npm run build && node dist/src/cli.js codex --json",
"clean": "rm -rf dist",
Expand Down Expand Up @@ -60,5 +60,9 @@
"external-brain",
"session-memory",
"developer-tools"
]
],
"devDependencies": {
"@types/node": "^22.19.19",
"typescript": "^6.0.3"
}
}
10 changes: 8 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ import { runBenchmarkCli } from './benchmark/index.js';
import { runScanCli } from './scan/index.js';
import { exportClaudeMd, exportAgentsMd } from './export/index.js';

type HistoryRecord = {
readonly valid_from?: string | null;
readonly valid_until?: string | null;
readonly status: string;
readonly updated_at: string;
};

export function runCli(argv: string[], io: CliIo): number {
let parsed;
try {
Expand Down Expand Up @@ -510,8 +517,7 @@ export function runCli(argv: string[], io: CliIo): number {
const store = createTruthKernelStorage(storePath, { autoMigrate: true });
try {
// Try entity history first, then decision history
let history: readonly { valid_from?: string | null; valid_until?: string | null; status: string; updated_at: string; [key: string]: unknown }[] =
store.listEntityHistory(parsed.entityId);
let history: readonly HistoryRecord[] = store.listEntityHistory(parsed.entityId);
let historyType = 'entity';

if (history.length === 0) {
Expand Down
4 changes: 4 additions & 0 deletions src/contracts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export type SourceKind =
| 'transcript'
| 'note'
| 'pointer'
| 'probe'
| 'local_adapter'
| 'observation'
| 'daily'
| 'person'
Expand Down Expand Up @@ -72,6 +74,8 @@ const SOURCE_KIND_SET = new Set<string>([
'transcript',
'note',
'pointer',
'probe',
'local_adapter',
'observation',
'daily',
'person',
Expand Down
6 changes: 3 additions & 3 deletions src/facade/facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ export function createFacade(options: FacadeOptions = {}): ManagedFacadeApi {
},
sourceStatus(): LocalSourceStatusResult {
return buildSourceStatusResult({
sourceAdaptersEnabled: options.sourceAdaptersEnabled,
...(options.sourceAdaptersEnabled ? { sourceAdaptersEnabled: options.sourceAdaptersEnabled } : {}),
jcpLiveReader,
});
},
health(): WaypathHealthResult {
return healthCheck(store, {
sourceAdaptersEnabled: options.sourceAdaptersEnabled,
...(options.sourceAdaptersEnabled ? { sourceAdaptersEnabled: options.sourceAdaptersEnabled } : {}),
jcpLiveReader,
});
},
Expand Down Expand Up @@ -478,7 +478,7 @@ function withEvidenceAppendix(
store,
{
...(recallWeights ? { weights: recallWeights } : {}),
jcpLiveReader,
...(jcpLiveReader ? { jcpLiveReader } : {}),
},
);

Expand Down
4 changes: 3 additions & 1 deletion src/jarvis_fusion/archive-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,9 @@ export function buildLocalArchiveBundle(
const extraCandidates = [...jcpRanked.candidates, ...mempalaceCandidates];
const extraRankedLists: RankedList[] = [
...jcpRanked.rankedLists,
...(mempalaceCandidates.length > 0 ? [{ dimension: 'keyword', results: mempalaceCandidates }] : []),
...(mempalaceCandidates.length > 0
? [{ dimension: 'keyword' as const, results: mempalaceCandidates }]
: []),
];

const searchResults = store
Expand Down
6 changes: 3 additions & 3 deletions src/jarvis_fusion/bootstrap-import.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ImportResult } from '../contracts/index.js';
import type { ImportResult, ImportRun } from '../contracts/index.js';
import { createDemoSourceReader } from './source-readers-demo.js';
import {
createJarvisBrainDbSourceReader,
Expand Down Expand Up @@ -224,14 +224,14 @@ export function runBootstrapImport(store: SqliteTruthKernelStorage, manifest: Bo
}

export function toImportResult(result: BootstrapImportResult, storePath: string): ImportResult {
const run = {
const run: ImportRun = {
manifest_id: result.manifest_id,
mode: result.import_mode,
imported_at: result.imported_at,
reader_names: result.readers,
source_anchors: result.readers.map((reader) => ({
source_system: reader,
source_kind: 'import_reader',
source_kind: 'import_reader' as const,
source_ref: `${result.manifest_id}#${reader}`,
})),
};
Expand Down
7 changes: 4 additions & 3 deletions src/jarvis_fusion/truth-kernel/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
SourceSystem,
GraphContext,
GraphRelationshipSummary,
ProvenanceRecord,
SqliteQueryResult,
TruthDecisionRecord,
TruthEntityRecord,
Expand Down Expand Up @@ -576,13 +577,13 @@ export class SqliteTruthKernelStorage implements TruthKernelStore {
return row ? mapRelationship(row) : undefined;
}

getProvenance(provenanceId: string) {
getProvenance(provenanceId: string): ProvenanceRecord | undefined {
const row = this.get<Record<string, unknown>>(`SELECT * FROM provenance_records WHERE provenance_id = :provenance_id LIMIT 1`, { provenance_id: provenanceId });
if (!row) return undefined;
return {
provenance_id: String(row.provenance_id),
source_system: String(row.source_system),
source_kind: String(row.source_kind),
source_system: String(row.source_system) as SourceSystem,
source_kind: String(row.source_kind) as SourceKind,
source_ref: String(row.source_ref),
observed_at: row.observed_at === null ? null : String(row.observed_at),
imported_at: row.imported_at === null ? null : String(row.imported_at),
Expand Down
4 changes: 2 additions & 2 deletions src/shared/config/runtime-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ function decodeRuntimeConfig(raw: TomlObject): RuntimeConfig {

function applyEnvOverrides(base: RuntimeConfig, env: EnvMap): RuntimeConfig {
const sourceAdapterOverrides = { ...(base.sourceAdapters?.enabled ?? {}) };
const sourceSystemWeights = { ...(base.retrieval?.weights?.sourceSystems ?? {}) };
const sourceKindWeights = { ...(base.retrieval?.weights?.sourceKinds ?? {}) };
const sourceSystemWeights: Record<string, number> = { ...(base.retrieval?.weights?.sourceSystems ?? {}) };
const sourceKindWeights: Record<string, number> = { ...(base.retrieval?.weights?.sourceKinds ?? {}) };
let allowMissingLocalReaders = base.import?.allowMissingLocalReaders;
let reviewQueueLimit = base.reviewQueue?.limit;

Expand Down
43 changes: 0 additions & 43 deletions src/shared/globals.d.ts

This file was deleted.

42 changes: 0 additions & 42 deletions tests/node-shim.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion tests/unit/promotion-engine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function testSubmitWithEvidenceBundleLinkage(): void {
evidence_bundle_id: 'bundle:test-evidence',
claim_type: 'observation',
source: {
source_system: 'test-system',
source_system: 'demo-source',
source_kind: 'observation',
source_ref: 'test-ref',
},
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/search-pipeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export function testRrfFusionMergesLists(): void {
}

export function testRrfScoreIsRankBased(): void {
const c1: SearchCandidate = { id: '1', title: 'First', content: '', source_type: 'entity', source_system: 's', source_kind: 'k', confidence: null, graph_depth: null, graph_weight: null, metadata: {} };
const c2: SearchCandidate = { id: '2', title: 'Second', content: '', source_type: 'entity', source_system: 's', source_kind: 'k', confidence: null, graph_depth: null, graph_weight: null, metadata: {} };
const c1: SearchCandidate = { id: '1', title: 'First', content: '', source_type: 'entity', source_system: 'truth-kernel', source_kind: 'entity', confidence: null, graph_depth: null, graph_weight: null, metadata: {} };
const c2: SearchCandidate = { id: '2', title: 'Second', content: '', source_type: 'entity', source_system: 'truth-kernel', source_kind: 'entity', confidence: null, graph_depth: null, graph_weight: null, metadata: {} };

const results = rrfFusion([
{ dimension: 'keyword', results: [c1, c2] },
Expand All @@ -62,7 +62,7 @@ export function testRrfScoreIsRankBased(): void {
// --- Dedup Tests ---

export function testDedupById(): void {
const candidate: SearchCandidate = { id: 'dup', title: 'Same', content: 'Same content', source_type: 'entity', source_system: 's', source_kind: 'k', confidence: null, graph_depth: null, graph_weight: null, metadata: {} };
const candidate: SearchCandidate = { id: 'dup', title: 'Same', content: 'Same content', source_type: 'entity', source_system: 'truth-kernel', source_kind: 'entity', confidence: null, graph_depth: null, graph_weight: null, metadata: {} };
const r1: ScoredResult = { candidate, score: 0.5, breakdown: { keyword: 0.5, graph: 0, provenance: 0, lexical: 0, rrf_fused: 0.5 } };
const r2: ScoredResult = { candidate, score: 0.8, breakdown: { keyword: 0.8, graph: 0, provenance: 0, lexical: 0, rrf_fused: 0.8 } };

Expand All @@ -75,7 +75,7 @@ export function testDedupTypeDiversity(): void {
const results: ScoredResult[] = [];
for (let i = 0; i < 10; i++) {
results.push({
candidate: { id: `e${i}`, title: `Entity ${i}`, content: `Unique content ${i} with different words`, source_type: 'entity', source_system: 's', source_kind: 'k', confidence: null, graph_depth: null, graph_weight: null, metadata: {} },
candidate: { id: `e${i}`, title: `Entity ${i}`, content: `Unique content ${i} with different words`, source_type: 'entity', source_system: 'truth-kernel', source_kind: 'entity', confidence: null, graph_depth: null, graph_weight: null, metadata: {} },
score: 1 - i * 0.01,
breakdown: { keyword: 0, graph: 0, provenance: 0, lexical: 0, rrf_fused: 0 },
});
Expand Down
8 changes: 5 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "Node16",
"moduleResolution": "Node16",
"module": "ESNext",
"moduleResolution": "Bundler",
"rootDir": ".",
"outDir": "dist",
"strict": true,
Expand All @@ -14,7 +14,9 @@
"skipLibCheck": true,
"declaration": true,
"resolveJsonModule": false,
"types": [],
"types": [
"node"
],
"ignoreDeprecations": "6.0"
},
"include": [
Expand Down