@devflow-tools/database 0.17.7 → 0.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/LICENSE +21 -0
- package/README.md +2 -2
- package/dist/data/LocalDataProvider.d.ts +63 -0
- package/dist/data/LocalDataProvider.js +332 -0
- package/dist/data/default-enforcer-rules.d.ts +3 -0
- package/dist/data/default-enforcer-rules.js +170 -0
- package/dist/data/devflow-schema.d.ts +2 -0
- package/dist/data/devflow-schema.js +80 -0
- package/dist/database.d.ts +45 -7
- package/dist/database.js +583 -125
- package/dist/index.d.ts +8 -4
- package/dist/index.js +11 -5
- package/dist/retrieval-ledger.d.ts +16 -1
- package/dist/retrieval-ledger.js +6 -0
- package/dist/retrieval-runtime.d.ts +39 -0
- package/dist/retrieval-runtime.js +2 -0
- package/dist/task-aggregate.d.ts +49 -0
- package/dist/task-aggregate.js +2 -0
- package/dist/task-semantic-control.d.ts +8 -1
- package/dist/task-semantic-control.js +2 -4
- package/package.json +15 -3
- package/CHANGELOG.md +0 -836
- package/__tests__/database.failure-category.test.ts +0 -44
- package/__tests__/database.host-actions.test.ts +0 -405
- package/__tests__/database.learning-candidates.test.ts +0 -93
- package/__tests__/database.memory-turn-receipts.test.ts +0 -98
- package/__tests__/database.retrieval-ledger.test.ts +0 -68
- package/__tests__/database.retrieval-sessions.test.ts +0 -79
- package/__tests__/database.semantic-resolution.test.ts +0 -87
- package/__tests__/database.skill-executions.test.ts +0 -456
- package/__tests__/database.task-runtime.test.ts +0 -73
- package/__tests__/database.test.ts +0 -177
- package/__tests__/database.work-queue.test.ts +0 -274
- package/__tests__/database.workflow-workers.test.ts +0 -60
- package/__tests__/node-sqlite.test.ts +0 -68
- package/src/database.ts +0 -5853
- package/src/host-actions.ts +0 -211
- package/src/index.ts +0 -153
- package/src/learning-candidates.ts +0 -181
- package/src/node-sqlite.ts +0 -60
- package/src/obligation-ledger.ts +0 -57
- package/src/retrieval-ledger.ts +0 -35
- package/src/retrieval-sessions.ts +0 -196
- package/src/semantic-resolution.ts +0 -181
- package/src/task-runtime.ts +0 -169
- package/src/task-semantic-control.ts +0 -270
- package/src/types.ts +0 -17
- package/src/work-queue.ts +0 -123
- package/src/workflow-workers.ts +0 -198
- package/tsconfig.json +0 -19
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -41
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEVFLOW_SCHEMA_SQL = exports.DEVFLOW_TABLE_NAMES = void 0;
|
|
4
|
+
exports.DEVFLOW_TABLE_NAMES = [
|
|
5
|
+
'devflow_kv',
|
|
6
|
+
'devflow_sessions',
|
|
7
|
+
'devflow_telemetry_runs',
|
|
8
|
+
'devflow_benchmark_reports',
|
|
9
|
+
'devflow_workflow_runs',
|
|
10
|
+
'devflow_knowledge_entries',
|
|
11
|
+
'devflow_tool_calls',
|
|
12
|
+
'devflow_rules',
|
|
13
|
+
'devflow_audit_chain',
|
|
14
|
+
'devflow_context_receipts',
|
|
15
|
+
];
|
|
16
|
+
exports.DEVFLOW_SCHEMA_SQL = `
|
|
17
|
+
CREATE TABLE IF NOT EXISTS devflow_kv (
|
|
18
|
+
key TEXT PRIMARY KEY, value TEXT
|
|
19
|
+
);
|
|
20
|
+
CREATE TABLE IF NOT EXISTS devflow_sessions (
|
|
21
|
+
session_id TEXT, timestamp INTEGER, event TEXT, data TEXT
|
|
22
|
+
);
|
|
23
|
+
CREATE TABLE IF NOT EXISTS devflow_telemetry_runs (
|
|
24
|
+
id TEXT PRIMARY KEY, agent TEXT, mode TEXT, status TEXT,
|
|
25
|
+
started_at INTEGER, finished_at INTEGER, token_used INTEGER, data TEXT
|
|
26
|
+
);
|
|
27
|
+
CREATE TABLE IF NOT EXISTS devflow_benchmark_reports (
|
|
28
|
+
id TEXT PRIMARY KEY, task TEXT, score REAL, started_at INTEGER,
|
|
29
|
+
finished_at INTEGER, data TEXT
|
|
30
|
+
);
|
|
31
|
+
CREATE TABLE IF NOT EXISTS devflow_workflow_runs (
|
|
32
|
+
run_id TEXT PRIMARY KEY, type TEXT, status TEXT, input TEXT,
|
|
33
|
+
steps TEXT, started_at INTEGER, finished_at INTEGER,
|
|
34
|
+
failure_category TEXT, failure_reason TEXT, failure_evidence TEXT
|
|
35
|
+
);
|
|
36
|
+
CREATE TABLE IF NOT EXISTS devflow_knowledge_entries (
|
|
37
|
+
id TEXT PRIMARY KEY, source TEXT, title TEXT, content TEXT
|
|
38
|
+
);
|
|
39
|
+
CREATE TABLE IF NOT EXISTS devflow_tool_calls (
|
|
40
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
41
|
+
tool TEXT NOT NULL,
|
|
42
|
+
args TEXT,
|
|
43
|
+
timestamp INTEGER NOT NULL,
|
|
44
|
+
duration_ms INTEGER NOT NULL,
|
|
45
|
+
error TEXT
|
|
46
|
+
);
|
|
47
|
+
CREATE TABLE IF NOT EXISTS devflow_rules (
|
|
48
|
+
id TEXT PRIMARY KEY, name TEXT NOT NULL, level TEXT NOT NULL DEFAULT 'project',
|
|
49
|
+
gate INTEGER NOT NULL DEFAULT 1,
|
|
50
|
+
condition_json TEXT NOT NULL, action TEXT NOT NULL DEFAULT 'warn',
|
|
51
|
+
message TEXT NOT NULL, enabled INTEGER NOT NULL DEFAULT 1,
|
|
52
|
+
created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL
|
|
53
|
+
);
|
|
54
|
+
CREATE TABLE IF NOT EXISTS devflow_audit_chain (
|
|
55
|
+
seq INTEGER PRIMARY KEY AUTOINCREMENT, ts INTEGER NOT NULL,
|
|
56
|
+
tool TEXT NOT NULL, args_hash TEXT NOT NULL,
|
|
57
|
+
decision TEXT NOT NULL, rule_id TEXT,
|
|
58
|
+
session_id TEXT NOT NULL, prev_hash TEXT NOT NULL,
|
|
59
|
+
signature TEXT NOT NULL
|
|
60
|
+
);
|
|
61
|
+
CREATE TABLE IF NOT EXISTS devflow_context_receipts (
|
|
62
|
+
project_root TEXT NOT NULL,
|
|
63
|
+
session_id TEXT NOT NULL,
|
|
64
|
+
execution_id TEXT NOT NULL,
|
|
65
|
+
context_hash TEXT NOT NULL,
|
|
66
|
+
issued_at INTEGER NOT NULL,
|
|
67
|
+
expires_at INTEGER NOT NULL,
|
|
68
|
+
selected_files TEXT NOT NULL DEFAULT '[]',
|
|
69
|
+
memory_ids TEXT NOT NULL DEFAULT '[]',
|
|
70
|
+
canonical_next_action TEXT,
|
|
71
|
+
canonical_action_json TEXT,
|
|
72
|
+
action_attempts TEXT NOT NULL DEFAULT '[]',
|
|
73
|
+
action_satisfied_at INTEGER,
|
|
74
|
+
action_degradation_json TEXT,
|
|
75
|
+
request_id TEXT,
|
|
76
|
+
PRIMARY KEY (project_root, session_id, execution_id)
|
|
77
|
+
);
|
|
78
|
+
CREATE INDEX IF NOT EXISTS idx_context_receipts_expiry
|
|
79
|
+
ON devflow_context_receipts(expires_at);
|
|
80
|
+
`;
|
package/dist/database.d.ts
CHANGED
|
@@ -4,10 +4,12 @@ import { type FailHostActionInput, type HostActionRecord, type ReportHostActionI
|
|
|
4
4
|
import { type AppendRetrievalCycleInput, type CreateRetrievalSessionInput, type RetrievalCycleRecord, type RetrievalSessionRecord, type RetrievalSessionState } from './retrieval-sessions';
|
|
5
5
|
import { type AddLearningCandidateEvidenceInput, type LearningCandidateEvidenceRecord, type LearningCandidateRecord, type LearningCandidateState, type LearningCandidateVersionRecord, type TransitionLearningCandidateInput, type UpsertLearningCandidateInput } from './learning-candidates';
|
|
6
6
|
import { type CreateWorkflowWorkerInput, type EnqueueWorkflowMergeInput, type TransitionWorkflowWorkerInput, type WorkflowMergeRecord, type WorkflowMergeState, type WorkflowWorkerEventRecord, type WorkflowWorkerRecord } from './workflow-workers';
|
|
7
|
-
import type
|
|
8
|
-
import { type ChannelQueryPlanRecord, type TaskIntentArtifactRecord, type TerminalTransitionRecord, type ToolNameResolutionRecord, type TranscriptCheckpointRecord } from './task-semantic-control';
|
|
7
|
+
import { type RetrievalLedgerEventRecord, type VerifyReceiptBoundRetrievalInput, type VerifyReceiptBoundRetrievalResult } from './retrieval-ledger';
|
|
8
|
+
import { type CanonicalSemanticTaskWrite, type ChannelQueryPlanRecord, type TaskIntentArtifactRecord, type TerminalTransitionRecord, type ToolNameResolutionRecord, type TranscriptCheckpointRecord } from './task-semantic-control';
|
|
9
9
|
import { type TaskRuntimeEventRecord, type TaskRuntimeSnapshotRecord } from './task-runtime';
|
|
10
|
-
import {
|
|
10
|
+
import type { AppendTaskAggregateInput, AppendTaskAggregateResult, LeaseTaskOutboxInput, TaskOutboxRecord } from './task-aggregate';
|
|
11
|
+
import { type CanonicalTaskIdentity, type RetrievalCycleReceiptV1, type RuntimeActivationSnapshotV1, type SemanticExecutionContext, type TaskAggregateEventV1, type TaskDefinitionV1, type TaskRuntimeSnapshotV2 } from '@devflow-tools/sdk';
|
|
12
|
+
import type { AppendRetrievalCycleV2Input, CreateRetrievalSessionV2Input, RetrievalSessionV2Record } from './retrieval-runtime';
|
|
11
13
|
export interface BenchmarkReportRecord {
|
|
12
14
|
runId: string;
|
|
13
15
|
suiteId: string;
|
|
@@ -435,6 +437,10 @@ export declare class DevFlowDatabase {
|
|
|
435
437
|
updateHookReceipt(projectRoot: string, updater: (current: HookReceiptRecord | null) => Omit<HookReceiptRecord, 'projectRoot' | 'updatedAt'>): HookReceiptRecord;
|
|
436
438
|
deleteHookReceipt(projectRoot: string): boolean;
|
|
437
439
|
createRetrievalSession(input: CreateRetrievalSessionInput): RetrievalSessionRecord;
|
|
440
|
+
createRetrievalSessionV2(input: CreateRetrievalSessionV2Input): RetrievalSessionV2Record;
|
|
441
|
+
getRetrievalSessionV2(id: string): RetrievalSessionV2Record | null;
|
|
442
|
+
listRetrievalCyclesV2(sessionId: string): RetrievalCycleReceiptV1[];
|
|
443
|
+
appendRetrievalCycleV2(input: AppendRetrievalCycleV2Input): RetrievalSessionV2Record;
|
|
438
444
|
getRetrievalSession(projectRoot: string, sessionId: string, id: string): RetrievalSessionRecord | null;
|
|
439
445
|
getRetrievalSessionByRequest(requestId: string): RetrievalSessionRecord | null;
|
|
440
446
|
listRetrievalCycles(retrievalSessionId: string): RetrievalCycleRecord[];
|
|
@@ -455,7 +461,9 @@ export declare class DevFlowDatabase {
|
|
|
455
461
|
getContextReceiptForRequest(projectRoot: string, sessionId: string, requestId: string): ContextReceiptRecord | null;
|
|
456
462
|
recordContextSelectionEvent(event: ContextSelectionEventRecord): boolean;
|
|
457
463
|
appendRetrievalLedgerEvent(event: RetrievalLedgerEventRecord): boolean;
|
|
464
|
+
verifyReceiptBoundRetrieval(input: VerifyReceiptBoundRetrievalInput): VerifyReceiptBoundRetrievalResult;
|
|
458
465
|
appendTaskIntentArtifact(record: TaskIntentArtifactRecord): TaskIntentArtifactRecord;
|
|
466
|
+
private appendTaskIntentArtifactInTransaction;
|
|
459
467
|
getTaskIntentArtifact(artifactHash: string): TaskIntentArtifactRecord | null;
|
|
460
468
|
getLatestTaskIntentArtifact(input: {
|
|
461
469
|
projectRoot: string;
|
|
@@ -468,10 +476,6 @@ export declare class DevFlowDatabase {
|
|
|
468
476
|
sessionId: string;
|
|
469
477
|
sourceHash: string;
|
|
470
478
|
}): TaskIntentArtifactRecord | null;
|
|
471
|
-
appendSemanticResolution(record: SemanticResolutionRecord): boolean;
|
|
472
|
-
getSemanticResolution(frameHash: string): SemanticResolutionRecord | null;
|
|
473
|
-
getLatestSemanticResolution(projectRoot: string, sessionId: string, turnId: string): SemanticResolutionRecord | null;
|
|
474
|
-
listSemanticResolutions(projectRoot: string, sessionId: string, turnId: string): SemanticResolutionRecord[];
|
|
475
479
|
listLatestTaskIntentArtifacts(projectRoot: string, sessionId: string): TaskIntentArtifactRecord[];
|
|
476
480
|
appendChannelQueryPlan(record: ChannelQueryPlanRecord): ChannelQueryPlanRecord;
|
|
477
481
|
getChannelQueryPlan(planHash: string): ChannelQueryPlanRecord | null;
|
|
@@ -495,6 +499,40 @@ export declare class DevFlowDatabase {
|
|
|
495
499
|
appendTaskRuntimeEventAndSnapshot(event: TaskRuntimeEventRecord, snapshot: TaskRuntimeSnapshotRecord): TaskRuntimeSnapshotRecord;
|
|
496
500
|
getTaskRuntimeSnapshot(projectRoot: string, sessionId: string, turnId: string): TaskRuntimeSnapshotRecord | null;
|
|
497
501
|
deleteTaskRuntimeSnapshot(projectRoot: string, sessionId: string, turnId: string): boolean;
|
|
502
|
+
appendTaskAggregate(input: AppendTaskAggregateInput): AppendTaskAggregateResult;
|
|
503
|
+
bindRuntimeActivation(input: {
|
|
504
|
+
identity: CanonicalTaskIdentity;
|
|
505
|
+
revision: number;
|
|
506
|
+
snapshot: RuntimeActivationSnapshotV1;
|
|
507
|
+
}): {
|
|
508
|
+
snapshot: RuntimeActivationSnapshotV1;
|
|
509
|
+
replayed: boolean;
|
|
510
|
+
};
|
|
511
|
+
private bindRuntimeActivationInTransaction;
|
|
512
|
+
getRuntimeActivation(projectRoot: string, sessionId: string, turnId: string, revision: number): RuntimeActivationSnapshotV1 | null;
|
|
513
|
+
putSemanticExecutionContext(input: {
|
|
514
|
+
context: SemanticExecutionContext;
|
|
515
|
+
revision: number;
|
|
516
|
+
}): SemanticExecutionContext;
|
|
517
|
+
putCanonicalSemanticTask(input: CanonicalSemanticTaskWrite): SemanticExecutionContext;
|
|
518
|
+
getSemanticExecutionContext(projectRoot: string, sessionId: string, turnId: string, revision: number): SemanticExecutionContext | null;
|
|
519
|
+
getSemanticExecutionContextByHash(contextHash: string): SemanticExecutionContext | null;
|
|
520
|
+
getLatestSemanticExecutionContext(input: {
|
|
521
|
+
projectRoot: string;
|
|
522
|
+
sessionId: string;
|
|
523
|
+
turnId: string;
|
|
524
|
+
}): {
|
|
525
|
+
context: SemanticExecutionContext;
|
|
526
|
+
revision: number;
|
|
527
|
+
} | null;
|
|
528
|
+
listTaskAggregateEvents(projectRoot: string, sessionId: string, turnId: string, revision: number): TaskAggregateEventV1[];
|
|
529
|
+
getTaskAggregateEventByIdempotencyKey(idempotencyKey: string): TaskAggregateEventV1 | null;
|
|
530
|
+
getTaskAggregateSnapshot(projectRoot: string, sessionId: string, turnId: string, revision: number): TaskRuntimeSnapshotV2 | null;
|
|
531
|
+
getTaskDefinitionV2(definitionHash: string): TaskDefinitionV1 | null;
|
|
532
|
+
leaseTaskOutbox(input: LeaseTaskOutboxInput): TaskOutboxRecord[];
|
|
533
|
+
completeTaskOutbox(operationId: string, owner: string, fencingToken: number, now?: number): boolean;
|
|
534
|
+
getTaskOutbox(operationId: string): TaskOutboxRecord | null;
|
|
535
|
+
private putTaskDefinitionV2;
|
|
498
536
|
getTerminalTransition(receiptId: string): TerminalTransitionRecord | null;
|
|
499
537
|
getLatestTerminalTransition(projectRoot: string, sessionId: string, turnId: string): TerminalTransitionRecord | null;
|
|
500
538
|
appendTranscriptCheckpoint(record: TranscriptCheckpointRecord): boolean;
|