@haaaiawd/second-nature 0.2.9 → 0.2.12
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/index.js +6 -0
- package/openclaw.plugin.json +2 -5
- package/package.json +1 -1
- package/runtime/cli/host-capability/probe-host-capability.js +1 -1
- package/runtime/cli/host-capability/types.d.ts +2 -7
- package/runtime/cli/host-capability/types.js +0 -5
- package/runtime/cli/ops/heartbeat-surface.d.ts +2 -0
- package/runtime/cli/ops/heartbeat-surface.js +32 -3
- package/runtime/cli/ops/ops-router.js +3 -3
- package/runtime/cli/ops/workspace-heartbeat-runner.js +2 -5
- package/runtime/connectors/manifest/manifest-schema.d.ts +2 -2
- package/runtime/connectors/registry/dynamic-connector-registry.js +16 -1
- package/runtime/connectors/services/connector-executor-adapter.js +54 -35
- package/runtime/core/second-nature/action/action-closure-recorder.d.ts +2 -0
- package/runtime/core/second-nature/action/action-closure-recorder.js +2 -4
- package/runtime/core/second-nature/action/action-proposal-builder.js +5 -32
- package/runtime/core/second-nature/action/policy-bound-dispatch.js +4 -3
- package/runtime/core/second-nature/control-plane/accepted-projection-loader.js +1 -11
- package/runtime/core/second-nature/control-plane/heartbeat-orchestrator.d.ts +1 -0
- package/runtime/core/second-nature/control-plane/heartbeat-orchestrator.js +10 -6
- package/runtime/core/second-nature/control-plane/real-runtime-spine.d.ts +2 -0
- package/runtime/core/second-nature/control-plane/real-runtime-spine.js +1 -0
- package/runtime/core/second-nature/heartbeat/heartbeat-loop.js +4 -3
- package/runtime/core/second-nature/heartbeat/runtime-snapshot.d.ts +3 -2
- package/runtime/core/second-nature/heartbeat/snapshot-builder.d.ts +3 -2
- package/runtime/core/second-nature/orchestrator/intent-planner.js +4 -2
- package/runtime/core/second-nature/orchestrator/narrative-update.js +1 -2
- package/runtime/core/second-nature/orchestrator/platform-capability-router.d.ts +2 -2
- package/runtime/core/second-nature/orchestrator/platform-capability-router.js +1 -1
- package/runtime/core/second-nature/outreach/build-outreach-draft-request.js +2 -3
- package/runtime/core/second-nature/outreach/dispatch-user-outreach.d.ts +2 -2
- package/runtime/core/second-nature/outreach/dispatch-user-outreach.js +6 -1
- package/runtime/core/second-nature/outreach/judge-input-from-snapshot.js +3 -14
- package/runtime/core/second-nature/outreach/judge-outreach.d.ts +6 -5
- package/runtime/core/second-nature/perception/judgment-engine.js +2 -12
- package/runtime/core/second-nature/perception/perception-builder.js +1 -9
- package/runtime/core/second-nature/quiet/run-source-backed-quiet.js +13 -15
- package/runtime/core/second-nature/quiet-dream/daily-rhythm-scheduler.js +10 -13
- package/runtime/core/second-nature/quiet-dream/dream-scheduler.js +0 -2
- package/runtime/core/second-nature/quiet-dream/memory-projection-lifecycle.js +0 -12
- package/runtime/core/second-nature/quiet-dream/quiet-daily-review-builder.js +1 -11
- package/runtime/core/second-nature/types.d.ts +2 -9
- package/runtime/dream/dream-engine.js +11 -4
- package/runtime/guidance/outreach-draft-schema.d.ts +12 -12
- package/runtime/guidance/persona-selection.js +5 -0
- package/runtime/guidance/template-registry.js +6 -1
- package/runtime/guidance/types.d.ts +2 -2
- package/runtime/observability/living-loop-health-gate.js +2 -8
- package/runtime/observability/loop-stage-event-sink.js +0 -1
- package/runtime/observability/services/lived-experience-audit.d.ts +7 -7
- package/runtime/shared/serialization.d.ts +17 -0
- package/runtime/shared/serialization.js +27 -0
- package/runtime/shared/source-ref-compat.d.ts +26 -0
- package/runtime/shared/source-ref-compat.js +61 -0
- package/runtime/shared/types/goal.d.ts +4 -4
- package/runtime/shared/types/goal.js +1 -1
- package/runtime/shared/types/index.d.ts +1 -0
- package/runtime/shared/types/index.js +1 -3
- package/runtime/shared/types/source-ref.d.ts +2 -2
- package/runtime/shared/types/v7-entities.d.ts +5 -5
- package/runtime/shared/types/v7-entities.js +1 -1
- package/runtime/shared/types/v8-contracts.d.ts +1 -1
- package/runtime/storage/db/index.js +31 -26
- package/runtime/storage/db/migrations/index.js +4 -0
- package/runtime/storage/db/migrations/v8-004-schema-closure.d.ts +19 -0
- package/runtime/storage/db/migrations/v8-004-schema-closure.js +74 -0
- package/runtime/storage/db/migrations/v8-005-single-status-schema.d.ts +11 -0
- package/runtime/storage/db/migrations/v8-005-single-status-schema.js +16 -0
- package/runtime/storage/db/schema/v8-entities.d.ts +0 -95
- package/runtime/storage/db/schema/v8-entities.js +4 -7
- package/runtime/storage/delivery/types.d.ts +2 -2
- package/runtime/storage/fallback/load-operator-fallback.d.ts +2 -2
- package/runtime/storage/fallback/operator-fallback-types.d.ts +2 -2
- package/runtime/storage/fallback/operator-fallback-view.d.ts +2 -2
- package/runtime/storage/index.d.ts +1 -1
- package/runtime/storage/life-evidence/types.d.ts +5 -5
- package/runtime/storage/quiet/quiet-artifact-types.d.ts +4 -4
- package/runtime/storage/quiet/quiet-artifact-writer.d.ts +2 -2
- package/runtime/storage/services/write-validation-gate.d.ts +1 -1
- package/runtime/storage/services/write-validation-gate.js +16 -4
- package/runtime/storage/snapshots/types.d.ts +8 -8
- package/runtime/storage/user-interest/types.d.ts +3 -3
- package/runtime/storage/v8-state-stores.d.ts +8 -1
- package/runtime/storage/v8-state-stores.js +23 -20
|
@@ -8,6 +8,8 @@ import { V7_004_BEHAVIOR_PROMOTION } from "./v7-004-behavior-promotion.js";
|
|
|
8
8
|
import { V8_001_LIVING_PERCEPTION_LOOP } from "./v8-001-living-perception-loop.js";
|
|
9
9
|
import { V8_002_PERCEPTION_CONTRACT_ALIGNMENT } from "./v8-002-perception-contract-alignment.js";
|
|
10
10
|
import { V8_003_QUIET_CLOSURE_REFS } from "./v8-003-quiet-closure-refs.js";
|
|
11
|
+
import { V8_004_SCHEMA_CLOSURE } from "./v8-004-schema-closure.js";
|
|
12
|
+
import { V8_005_SINGLE_STATUS_SCHEMA } from "./v8-005-single-status-schema.js";
|
|
11
13
|
export const ALL_MIGRATIONS = [
|
|
12
14
|
V7_001_FOUNDATION,
|
|
13
15
|
V7_002_EFFECT_COMMIT_LEDGER,
|
|
@@ -16,4 +18,6 @@ export const ALL_MIGRATIONS = [
|
|
|
16
18
|
V8_001_LIVING_PERCEPTION_LOOP,
|
|
17
19
|
V8_002_PERCEPTION_CONTRACT_ALIGNMENT,
|
|
18
20
|
V8_003_QUIET_CLOSURE_REFS,
|
|
21
|
+
V8_004_SCHEMA_CLOSURE,
|
|
22
|
+
V8_005_SINGLE_STATUS_SCHEMA,
|
|
19
23
|
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v8-004 Schema Closure — brings pre-existing v8 DBs up to the current bootstrap schema.
|
|
3
|
+
*
|
|
4
|
+
* Problem: v8-001 created the first v8 tables, but daily_rhythm_state,
|
|
5
|
+
* impulse_context_artifact, connector_cooldown_state, and several columns
|
|
6
|
+
* (action_closure_record.platform_id/capability_id,
|
|
7
|
+
* quiet_daily_review.closure_refs_json, connector_cooldown_state.terminal_count)
|
|
8
|
+
* were added later only in the bootstrap SQL. DBs initialized before those
|
|
9
|
+
* bootstrap changes would miss tables/columns and break at runtime.
|
|
10
|
+
*
|
|
11
|
+
* Strategy:
|
|
12
|
+
* - CREATE TABLE IF NOT EXISTS for the three tables (idempotent on fresh DBs).
|
|
13
|
+
* - Column-level fixes are handled by the defensive applyStateSchemaMigrations
|
|
14
|
+
* helper in db/index.ts, because SQLite cannot conditionally ADD COLUMN.
|
|
15
|
+
*
|
|
16
|
+
* Resolves T-SMS.R.2.
|
|
17
|
+
*/
|
|
18
|
+
import type { Migration } from "../migration-runner.js";
|
|
19
|
+
export declare const V8_004_SCHEMA_CLOSURE: Migration;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v8-004 Schema Closure — brings pre-existing v8 DBs up to the current bootstrap schema.
|
|
3
|
+
*
|
|
4
|
+
* Problem: v8-001 created the first v8 tables, but daily_rhythm_state,
|
|
5
|
+
* impulse_context_artifact, connector_cooldown_state, and several columns
|
|
6
|
+
* (action_closure_record.platform_id/capability_id,
|
|
7
|
+
* quiet_daily_review.closure_refs_json, connector_cooldown_state.terminal_count)
|
|
8
|
+
* were added later only in the bootstrap SQL. DBs initialized before those
|
|
9
|
+
* bootstrap changes would miss tables/columns and break at runtime.
|
|
10
|
+
*
|
|
11
|
+
* Strategy:
|
|
12
|
+
* - CREATE TABLE IF NOT EXISTS for the three tables (idempotent on fresh DBs).
|
|
13
|
+
* - Column-level fixes are handled by the defensive applyStateSchemaMigrations
|
|
14
|
+
* helper in db/index.ts, because SQLite cannot conditionally ADD COLUMN.
|
|
15
|
+
*
|
|
16
|
+
* Resolves T-SMS.R.2.
|
|
17
|
+
*/
|
|
18
|
+
export const V8_004_SCHEMA_CLOSURE = {
|
|
19
|
+
version: 8,
|
|
20
|
+
label: "v8-schema-closure",
|
|
21
|
+
sql: `
|
|
22
|
+
CREATE TABLE IF NOT EXISTS daily_rhythm_state (
|
|
23
|
+
id TEXT PRIMARY KEY,
|
|
24
|
+
day TEXT NOT NULL,
|
|
25
|
+
quiet_status TEXT NOT NULL DEFAULT 'not_due',
|
|
26
|
+
dream_status TEXT NOT NULL DEFAULT 'not_due',
|
|
27
|
+
quiet_reason TEXT,
|
|
28
|
+
dream_reason TEXT,
|
|
29
|
+
quiet_completed_at TEXT,
|
|
30
|
+
dream_completed_at TEXT,
|
|
31
|
+
source_refs_json TEXT NOT NULL,
|
|
32
|
+
payload_json TEXT,
|
|
33
|
+
updated_at TEXT NOT NULL
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
CREATE TABLE IF NOT EXISTS impulse_context_artifact (
|
|
37
|
+
id TEXT PRIMARY KEY,
|
|
38
|
+
created_at TEXT NOT NULL,
|
|
39
|
+
updated_at TEXT NOT NULL,
|
|
40
|
+
scene_type TEXT NOT NULL,
|
|
41
|
+
capability_intent TEXT,
|
|
42
|
+
platform_id TEXT,
|
|
43
|
+
capability_class TEXT,
|
|
44
|
+
impulse_source TEXT NOT NULL,
|
|
45
|
+
impulse_text TEXT,
|
|
46
|
+
atmosphere_text TEXT,
|
|
47
|
+
expression_boundary_constraints_json TEXT,
|
|
48
|
+
expression_boundary_style TEXT,
|
|
49
|
+
freshness_version INTEGER NOT NULL DEFAULT 1,
|
|
50
|
+
source_refs_json TEXT NOT NULL,
|
|
51
|
+
redaction_class TEXT NOT NULL DEFAULT 'none',
|
|
52
|
+
payload_json TEXT,
|
|
53
|
+
lifecycle_status TEXT NOT NULL DEFAULT 'active'
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
CREATE TABLE IF NOT EXISTS connector_cooldown_state (
|
|
57
|
+
id TEXT PRIMARY KEY,
|
|
58
|
+
platform_id TEXT NOT NULL,
|
|
59
|
+
capability_id TEXT NOT NULL,
|
|
60
|
+
failure_class TEXT NOT NULL,
|
|
61
|
+
retry_after_ms INTEGER,
|
|
62
|
+
blocked_until TEXT NOT NULL,
|
|
63
|
+
failure_count INTEGER NOT NULL DEFAULT 1,
|
|
64
|
+
terminal_count INTEGER NOT NULL DEFAULT 0,
|
|
65
|
+
source_refs_json TEXT NOT NULL,
|
|
66
|
+
redaction_class TEXT NOT NULL DEFAULT 'none',
|
|
67
|
+
payload_json TEXT,
|
|
68
|
+
created_at TEXT NOT NULL,
|
|
69
|
+
updated_at TEXT NOT NULL
|
|
70
|
+
);
|
|
71
|
+
CREATE INDEX IF NOT EXISTS connector_cooldown_state_platform_capability_idx
|
|
72
|
+
ON connector_cooldown_state(platform_id, capability_id);
|
|
73
|
+
`,
|
|
74
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v8-005 Single Status Schema — records Wave 114 status-column cleanup.
|
|
3
|
+
*
|
|
4
|
+
* SQLite cannot safely run `DROP COLUMN IF EXISTS`; the actual idempotent
|
|
5
|
+
* column removal lives in applyStateSchemaMigrations where each statement is
|
|
6
|
+
* isolated. This migration marks the schema version after that defensive pass.
|
|
7
|
+
*
|
|
8
|
+
* Resolves T-SMS.R.4.
|
|
9
|
+
*/
|
|
10
|
+
import type { Migration } from "../migration-runner.js";
|
|
11
|
+
export declare const V8_005_SINGLE_STATUS_SCHEMA: Migration;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v8-005 Single Status Schema — records Wave 114 status-column cleanup.
|
|
3
|
+
*
|
|
4
|
+
* SQLite cannot safely run `DROP COLUMN IF EXISTS`; the actual idempotent
|
|
5
|
+
* column removal lives in applyStateSchemaMigrations where each statement is
|
|
6
|
+
* isolated. This migration marks the schema version after that defensive pass.
|
|
7
|
+
*
|
|
8
|
+
* Resolves T-SMS.R.4.
|
|
9
|
+
*/
|
|
10
|
+
export const V8_005_SINGLE_STATUS_SCHEMA = {
|
|
11
|
+
version: 9,
|
|
12
|
+
label: "v8-single-status-schema",
|
|
13
|
+
sql: `
|
|
14
|
+
SELECT 1;
|
|
15
|
+
`,
|
|
16
|
+
};
|
|
@@ -1006,25 +1006,6 @@ export declare const actionClosureRecord: import("drizzle-orm/sqlite-core").SQLi
|
|
|
1006
1006
|
}, {}, {
|
|
1007
1007
|
length: number | undefined;
|
|
1008
1008
|
}>;
|
|
1009
|
-
lifecycleStatus: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
1010
|
-
name: "lifecycle_status";
|
|
1011
|
-
tableName: "action_closure_record";
|
|
1012
|
-
dataType: "string";
|
|
1013
|
-
columnType: "SQLiteText";
|
|
1014
|
-
data: string;
|
|
1015
|
-
driverParam: string;
|
|
1016
|
-
notNull: true;
|
|
1017
|
-
hasDefault: true;
|
|
1018
|
-
isPrimaryKey: false;
|
|
1019
|
-
isAutoincrement: false;
|
|
1020
|
-
hasRuntimeDefault: false;
|
|
1021
|
-
enumValues: [string, ...string[]];
|
|
1022
|
-
baseColumn: never;
|
|
1023
|
-
identity: undefined;
|
|
1024
|
-
generated: undefined;
|
|
1025
|
-
}, {}, {
|
|
1026
|
-
length: number | undefined;
|
|
1027
|
-
}>;
|
|
1028
1009
|
};
|
|
1029
1010
|
dialect: "sqlite";
|
|
1030
1011
|
}>;
|
|
@@ -1381,25 +1362,6 @@ export declare const dreamConsolidationRun: import("drizzle-orm/sqlite-core").SQ
|
|
|
1381
1362
|
}, {}, {
|
|
1382
1363
|
length: number | undefined;
|
|
1383
1364
|
}>;
|
|
1384
|
-
lifecycleStatus: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
1385
|
-
name: "lifecycle_status";
|
|
1386
|
-
tableName: "dream_consolidation_run";
|
|
1387
|
-
dataType: "string";
|
|
1388
|
-
columnType: "SQLiteText";
|
|
1389
|
-
data: string;
|
|
1390
|
-
driverParam: string;
|
|
1391
|
-
notNull: true;
|
|
1392
|
-
hasDefault: true;
|
|
1393
|
-
isPrimaryKey: false;
|
|
1394
|
-
isAutoincrement: false;
|
|
1395
|
-
hasRuntimeDefault: false;
|
|
1396
|
-
enumValues: [string, ...string[]];
|
|
1397
|
-
baseColumn: never;
|
|
1398
|
-
identity: undefined;
|
|
1399
|
-
generated: undefined;
|
|
1400
|
-
}, {}, {
|
|
1401
|
-
length: number | undefined;
|
|
1402
|
-
}>;
|
|
1403
1365
|
};
|
|
1404
1366
|
dialect: "sqlite";
|
|
1405
1367
|
}>;
|
|
@@ -1561,25 +1523,6 @@ export declare const longTermMemoryProjection: import("drizzle-orm/sqlite-core")
|
|
|
1561
1523
|
}, {}, {
|
|
1562
1524
|
length: number | undefined;
|
|
1563
1525
|
}>;
|
|
1564
|
-
lifecycleStatus: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
1565
|
-
name: "lifecycle_status";
|
|
1566
|
-
tableName: "long_term_memory_projection";
|
|
1567
|
-
dataType: "string";
|
|
1568
|
-
columnType: "SQLiteText";
|
|
1569
|
-
data: string;
|
|
1570
|
-
driverParam: string;
|
|
1571
|
-
notNull: true;
|
|
1572
|
-
hasDefault: true;
|
|
1573
|
-
isPrimaryKey: false;
|
|
1574
|
-
isAutoincrement: false;
|
|
1575
|
-
hasRuntimeDefault: false;
|
|
1576
|
-
enumValues: [string, ...string[]];
|
|
1577
|
-
baseColumn: never;
|
|
1578
|
-
identity: undefined;
|
|
1579
|
-
generated: undefined;
|
|
1580
|
-
}, {}, {
|
|
1581
|
-
length: number | undefined;
|
|
1582
|
-
}>;
|
|
1583
1526
|
};
|
|
1584
1527
|
dialect: "sqlite";
|
|
1585
1528
|
}>;
|
|
@@ -1790,25 +1733,6 @@ export declare const heartbeatCycleTrace: import("drizzle-orm/sqlite-core").SQLi
|
|
|
1790
1733
|
}, {}, {
|
|
1791
1734
|
length: number | undefined;
|
|
1792
1735
|
}>;
|
|
1793
|
-
lifecycleStatus: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
1794
|
-
name: "lifecycle_status";
|
|
1795
|
-
tableName: "heartbeat_cycle_trace";
|
|
1796
|
-
dataType: "string";
|
|
1797
|
-
columnType: "SQLiteText";
|
|
1798
|
-
data: string;
|
|
1799
|
-
driverParam: string;
|
|
1800
|
-
notNull: true;
|
|
1801
|
-
hasDefault: true;
|
|
1802
|
-
isPrimaryKey: false;
|
|
1803
|
-
isAutoincrement: false;
|
|
1804
|
-
hasRuntimeDefault: false;
|
|
1805
|
-
enumValues: [string, ...string[]];
|
|
1806
|
-
baseColumn: never;
|
|
1807
|
-
identity: undefined;
|
|
1808
|
-
generated: undefined;
|
|
1809
|
-
}, {}, {
|
|
1810
|
-
length: number | undefined;
|
|
1811
|
-
}>;
|
|
1812
1736
|
};
|
|
1813
1737
|
dialect: "sqlite";
|
|
1814
1738
|
}>;
|
|
@@ -2023,25 +1947,6 @@ export declare const loopStageEvent: import("drizzle-orm/sqlite-core").SQLiteTab
|
|
|
2023
1947
|
}, {}, {
|
|
2024
1948
|
length: number | undefined;
|
|
2025
1949
|
}>;
|
|
2026
|
-
lifecycleStatus: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
2027
|
-
name: "lifecycle_status";
|
|
2028
|
-
tableName: "loop_stage_event";
|
|
2029
|
-
dataType: "string";
|
|
2030
|
-
columnType: "SQLiteText";
|
|
2031
|
-
data: string;
|
|
2032
|
-
driverParam: string;
|
|
2033
|
-
notNull: true;
|
|
2034
|
-
hasDefault: true;
|
|
2035
|
-
isPrimaryKey: false;
|
|
2036
|
-
isAutoincrement: false;
|
|
2037
|
-
hasRuntimeDefault: false;
|
|
2038
|
-
enumValues: [string, ...string[]];
|
|
2039
|
-
baseColumn: never;
|
|
2040
|
-
identity: undefined;
|
|
2041
|
-
generated: undefined;
|
|
2042
|
-
}, {}, {
|
|
2043
|
-
length: number | undefined;
|
|
2044
|
-
}>;
|
|
2045
1950
|
};
|
|
2046
1951
|
dialect: "sqlite";
|
|
2047
1952
|
}>;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Dependencies: drizzle-orm/sqlite-core
|
|
13
13
|
* Boundary: Schema definitions only; no runtime logic.
|
|
14
14
|
*/
|
|
15
|
-
import { sqliteTable, text, integer, real, index } from "drizzle-orm/sqlite-core";
|
|
15
|
+
import { sqliteTable, text, integer, real, index, uniqueIndex } from "drizzle-orm/sqlite-core";
|
|
16
16
|
// ───────────────────────────────────────────────────────────────
|
|
17
17
|
// 1. EvidenceItem
|
|
18
18
|
// ───────────────────────────────────────────────────────────────
|
|
@@ -27,7 +27,9 @@ export const evidenceItem = sqliteTable("evidence_item", {
|
|
|
27
27
|
redactionClass: text("redaction_class").notNull().default("none"),
|
|
28
28
|
payloadJson: text("payload_json"),
|
|
29
29
|
lifecycleStatus: text("lifecycle_status").notNull().default("pending"),
|
|
30
|
-
})
|
|
30
|
+
}, (table) => ({
|
|
31
|
+
platformContentHashIdx: uniqueIndex("evidence_item_platform_content_hash_idx").on(table.platformId, table.contentHash),
|
|
32
|
+
}));
|
|
31
33
|
// ───────────────────────────────────────────────────────────────
|
|
32
34
|
// 2. PerceptionCard
|
|
33
35
|
// ───────────────────────────────────────────────────────────────
|
|
@@ -83,7 +85,6 @@ export const actionClosureRecord = sqliteTable("action_closure_record", {
|
|
|
83
85
|
sourceRefsJson: text("source_refs_json").notNull(),
|
|
84
86
|
redactionClass: text("redaction_class").notNull().default("none"),
|
|
85
87
|
payloadJson: text("payload_json"),
|
|
86
|
-
lifecycleStatus: text("lifecycle_status").notNull().default("closed"),
|
|
87
88
|
});
|
|
88
89
|
// ───────────────────────────────────────────────────────────────
|
|
89
90
|
// 5. QuietDailyReview
|
|
@@ -112,7 +113,6 @@ export const dreamConsolidationRun = sqliteTable("dream_consolidation_run", {
|
|
|
112
113
|
sourceRefsJson: text("source_refs_json").notNull(),
|
|
113
114
|
redactionClass: text("redaction_class").notNull().default("none"),
|
|
114
115
|
payloadJson: text("payload_json"),
|
|
115
|
-
lifecycleStatus: text("lifecycle_status").notNull().default("pending"),
|
|
116
116
|
});
|
|
117
117
|
// ───────────────────────────────────────────────────────────────
|
|
118
118
|
// 7. LongTermMemoryProjection
|
|
@@ -126,7 +126,6 @@ export const longTermMemoryProjection = sqliteTable("long_term_memory_projection
|
|
|
126
126
|
sourceRefsJson: text("source_refs_json").notNull(),
|
|
127
127
|
redactionClass: text("redaction_class").notNull().default("none"),
|
|
128
128
|
payloadJson: text("payload_json"),
|
|
129
|
-
lifecycleStatus: text("lifecycle_status").notNull().default("candidate"),
|
|
130
129
|
});
|
|
131
130
|
// ───────────────────────────────────────────────────────────────
|
|
132
131
|
// 8. HeartbeatCycleTrace
|
|
@@ -143,7 +142,6 @@ export const heartbeatCycleTrace = sqliteTable("heartbeat_cycle_trace", {
|
|
|
143
142
|
sourceRefsJson: text("source_refs_json"),
|
|
144
143
|
redactionClass: text("redaction_class").notNull().default("none"),
|
|
145
144
|
payloadJson: text("payload_json"),
|
|
146
|
-
lifecycleStatus: text("lifecycle_status").notNull().default("started"),
|
|
147
145
|
});
|
|
148
146
|
// ───────────────────────────────────────────────────────────────
|
|
149
147
|
// 9. LoopStageEvent
|
|
@@ -160,7 +158,6 @@ export const loopStageEvent = sqliteTable("loop_stage_event", {
|
|
|
160
158
|
occurredAt: text("occurred_at").notNull(),
|
|
161
159
|
expectedDownstreamByCycle: integer("expected_downstream_by_cycle"),
|
|
162
160
|
payloadJson: text("payload_json"),
|
|
163
|
-
lifecycleStatus: text("lifecycle_status").notNull().default("started"),
|
|
164
161
|
});
|
|
165
162
|
// ───────────────────────────────────────────────────────────────
|
|
166
163
|
// 10. ImpulseContextArtifact
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Boundaries: validates proof fields before index write; hostProofRef uses SourceRef JSON.
|
|
5
5
|
* Test coverage: tests/unit/storage/delivery-attempt.test.ts
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { LifeEvidenceSourceRef } from "../life-evidence/types.js";
|
|
8
8
|
export type DeliveryAttemptStatus = "sent" | "failed" | "dropped_by_host_policy";
|
|
9
9
|
export interface DeliveryAttemptWrite {
|
|
10
10
|
attemptId: string;
|
|
@@ -13,7 +13,7 @@ export interface DeliveryAttemptWrite {
|
|
|
13
13
|
channel?: string;
|
|
14
14
|
status: DeliveryAttemptStatus;
|
|
15
15
|
messageId?: string;
|
|
16
|
-
hostProofRef?:
|
|
16
|
+
hostProofRef?: LifeEvidenceSourceRef;
|
|
17
17
|
errorClass?: string;
|
|
18
18
|
fallbackRef?: string;
|
|
19
19
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StateDatabase } from "../db/index.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { LifeEvidenceSourceRef } from "../life-evidence/types.js";
|
|
3
3
|
import type { OperatorFallbackView } from "./operator-fallback-view.js";
|
|
4
4
|
export declare function normalizeFallbackRef(ref: string): string;
|
|
5
5
|
/** Loads persisted operator fallback row; does not coerce status (use `toOperatorFallbackView`). */
|
|
@@ -7,7 +7,7 @@ export declare function loadOperatorFallbackRow(state: StateDatabase, fallbackRe
|
|
|
7
7
|
fallbackRef: string;
|
|
8
8
|
reason: string;
|
|
9
9
|
status: string;
|
|
10
|
-
sourceRefs:
|
|
10
|
+
sourceRefs: LifeEvidenceSourceRef[];
|
|
11
11
|
candidateMessage?: string;
|
|
12
12
|
nextStep: string;
|
|
13
13
|
} | null>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LifeEvidenceSourceRef } from "../life-evidence/types.js";
|
|
2
2
|
export type OperatorFallbackReason = "target_none" | "channel_missing" | "host_unsupported" | "delivery_failed";
|
|
3
3
|
export interface OperatorFallbackWrite {
|
|
4
4
|
reason: OperatorFallbackReason;
|
|
5
5
|
decisionId: string;
|
|
6
|
-
sourceRefs:
|
|
6
|
+
sourceRefs: LifeEvidenceSourceRef[];
|
|
7
7
|
candidateMessage?: string;
|
|
8
8
|
nextStep: string;
|
|
9
9
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LifeEvidenceSourceRef } from "../life-evidence/types.js";
|
|
2
2
|
import type { OperatorFallbackReason } from "./operator-fallback-types.js";
|
|
3
3
|
/** Operator-facing delivery fallback (T1.2.2 / cli-system v5). Status is always not_sent — never sent/delivered. */
|
|
4
4
|
export interface OperatorFallbackView {
|
|
5
5
|
fallbackRef: string;
|
|
6
6
|
reason: OperatorFallbackReason | string;
|
|
7
7
|
status: "not_sent";
|
|
8
|
-
sourceRefs:
|
|
8
|
+
sourceRefs: LifeEvidenceSourceRef[];
|
|
9
9
|
candidateMessage?: string;
|
|
10
10
|
nextStep: string;
|
|
11
11
|
}
|
|
@@ -22,7 +22,7 @@ export { createNarrativeStateStore, type NarrativeStateStore, type NarrativeStat
|
|
|
22
22
|
export { createRelationshipMemoryStore, type RelationshipMemoryStore, type RelationshipMemory, type RelationshipMemoryUpdate, type RelationshipMemoryWriteAck, type TopicAffinity, } from "./relationship/relationship-memory-store.js";
|
|
23
23
|
export { createAgentGoalStore, type AgentGoalStore, type AgentGoal, type AgentGoalWrite, type AgentGoalStatusTransition, type AgentGoalQuery, type AgentGoalWriteAck, } from "./goal/agent-goal-store.js";
|
|
24
24
|
export { createMemoryStoreLifecycle, type MemoryStorePort, type MemoryStore, type MemoryStoreWrite, type MemoryStoreLifecycleTransition, type MemoryStoreAck, type CanonicalMemoryEntry, type DreamInsight, type MemoryStoreValidation, } from "./memory-store/memory-store-lifecycle.js";
|
|
25
|
-
export type { LifeEvidence, LifeEvidenceCandidate, LifeEvidenceType, LifeEvidenceWriteAck, Sensitivity,
|
|
25
|
+
export type { LifeEvidence, LifeEvidenceCandidate, LifeEvidenceSourceRef, LifeEvidenceType, LifeEvidenceWriteAck, Sensitivity, } from "./life-evidence/types.js";
|
|
26
26
|
export { appendLifeEvidence, type AppendLifeEvidenceOptions } from "./life-evidence/append-life-evidence.js";
|
|
27
27
|
export { loadRhythmPolicySnapshot, type RhythmPolicySnapshot } from "./rhythm/rhythm-policy-snapshot.js";
|
|
28
28
|
export type { LifeEvidenceQuery, LifeEvidenceSnapshot, LifeEvidenceReadModel, ContinuitySnapshot, SourceCoverage, } from "./snapshots/types.js";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export type LifeEvidenceType = "platform_browse" | "platform_interaction" | "work_progress" | "task_discovery" | "user_interaction" | "quiet_reflection" | "delivery_fallback";
|
|
7
7
|
export type Sensitivity = "public" | "private" | "credential" | "sensitive";
|
|
8
|
-
export interface
|
|
8
|
+
export interface LifeEvidenceSourceRef {
|
|
9
9
|
id: string;
|
|
10
10
|
kind: "platform_item" | "workspace_artifact" | "decision_record" | "user_anchor" | "connector_result" | "host_report" | "fallback_artifact";
|
|
11
11
|
uri: string;
|
|
@@ -19,7 +19,7 @@ export interface LifeEvidenceCandidate {
|
|
|
19
19
|
platformId?: string;
|
|
20
20
|
summary: string;
|
|
21
21
|
rawContentRef?: string;
|
|
22
|
-
sourceRefs:
|
|
22
|
+
sourceRefs: LifeEvidenceSourceRef[];
|
|
23
23
|
sensitivity: Sensitivity;
|
|
24
24
|
confidence?: number;
|
|
25
25
|
tags?: string[];
|
|
@@ -32,14 +32,14 @@ export interface LifeEvidence {
|
|
|
32
32
|
platformId?: string;
|
|
33
33
|
summary: string;
|
|
34
34
|
rawContentRef?: string;
|
|
35
|
-
sourceRefs:
|
|
35
|
+
sourceRefs: LifeEvidenceSourceRef[];
|
|
36
36
|
sensitivity: Sensitivity;
|
|
37
37
|
confidence: number;
|
|
38
38
|
tags: string[];
|
|
39
39
|
producer: string;
|
|
40
|
-
artifactRef:
|
|
40
|
+
artifactRef: LifeEvidenceSourceRef;
|
|
41
41
|
}
|
|
42
42
|
export interface LifeEvidenceWriteAck {
|
|
43
43
|
evidenceId: string;
|
|
44
|
-
artifactRef:
|
|
44
|
+
artifactRef: LifeEvidenceSourceRef;
|
|
45
45
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LifeEvidenceSourceRef } from "../life-evidence/types.js";
|
|
2
2
|
export type QuietArtifactKind = "daily_report" | "narrative_reflection" | "curated_memory_candidate" | "empty_state";
|
|
3
3
|
export type QuietClaimType = "fact" | "emotion" | "interpretation" | "next_step";
|
|
4
4
|
export interface QuietClaim {
|
|
5
5
|
id: string;
|
|
6
6
|
text: string;
|
|
7
|
-
sourceRefs:
|
|
7
|
+
sourceRefs: LifeEvidenceSourceRef[];
|
|
8
8
|
claimType: QuietClaimType;
|
|
9
9
|
}
|
|
10
10
|
export interface QuietArtifactWrite {
|
|
@@ -13,6 +13,6 @@ export interface QuietArtifactWrite {
|
|
|
13
13
|
title: string;
|
|
14
14
|
body: string;
|
|
15
15
|
claims: QuietClaim[];
|
|
16
|
-
sourceRefs:
|
|
17
|
-
memoryCandidateRefs?:
|
|
16
|
+
sourceRefs: LifeEvidenceSourceRef[];
|
|
17
|
+
memoryCandidateRefs?: LifeEvidenceSourceRef[];
|
|
18
18
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LifeEvidenceSourceRef } from "../life-evidence/types.js";
|
|
2
2
|
import type { SourceCoverage } from "../snapshots/types.js";
|
|
3
3
|
import type { QuietArtifactWrite } from "./quiet-artifact-types.js";
|
|
4
4
|
import type { QuietClaim } from "./quiet-artifact-types.js";
|
|
@@ -7,7 +7,7 @@ export declare function calculateQuietSourceCoverage(claims: QuietClaim[]): Sour
|
|
|
7
7
|
export declare function evidenceGroundingRatio(input: Pick<QuietArtifactWrite, "claims" | "sourceRefs">): number;
|
|
8
8
|
export interface QuietArtifactAck {
|
|
9
9
|
artifactId: string;
|
|
10
|
-
artifactRef:
|
|
10
|
+
artifactRef: LifeEvidenceSourceRef;
|
|
11
11
|
sourceCoverage: SourceCoverage;
|
|
12
12
|
}
|
|
13
13
|
export declare function writeQuietArtifact(input: QuietArtifactWrite, opts?: {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* readable reason codes (DR-022).
|
|
8
8
|
*
|
|
9
9
|
* Dependencies:
|
|
10
|
-
* - `
|
|
10
|
+
* - `SourceRefTuple` type from `../../shared/types/source-ref.js`
|
|
11
11
|
* - v7 entity types for shape awareness
|
|
12
12
|
*
|
|
13
13
|
* Boundary:
|
|
@@ -115,7 +115,7 @@ const IDENTIFIER_FIELD_NAMES = new Set([
|
|
|
115
115
|
"id",
|
|
116
116
|
"runId",
|
|
117
117
|
"run_id",
|
|
118
|
-
"
|
|
118
|
+
"SourceRefTuple",
|
|
119
119
|
"source_ref",
|
|
120
120
|
"sourceRefs",
|
|
121
121
|
"source_refs_json",
|
|
@@ -127,6 +127,14 @@ const IDENTIFIER_FIELD_NAMES = new Set([
|
|
|
127
127
|
"capability_id",
|
|
128
128
|
"candidate_id",
|
|
129
129
|
]);
|
|
130
|
+
// Fields that describe where a secret is stored must still reject payloads
|
|
131
|
+
// that contain raw secret material, even if the value is URI-shaped.
|
|
132
|
+
const SECRET_LOCATION_FIELD_NAMES = new Set([
|
|
133
|
+
"locationRef",
|
|
134
|
+
"location_ref",
|
|
135
|
+
"rotationPolicyRef",
|
|
136
|
+
"rotation_policy_ref",
|
|
137
|
+
]);
|
|
130
138
|
function looksLikeUriPath(text) {
|
|
131
139
|
return /^[a-z][a-z0-9+.-]*:\/\//i.test(text) || (text.includes("/") && !text.includes(" "));
|
|
132
140
|
}
|
|
@@ -154,8 +162,12 @@ function sensitivityScan(value, fieldPath = "payload") {
|
|
|
154
162
|
const matched = match[0];
|
|
155
163
|
if (exempt && exempt(matched))
|
|
156
164
|
continue;
|
|
157
|
-
if (isIdentifierField || looksLikeUriPath(value))
|
|
158
|
-
|
|
165
|
+
if (isIdentifierField || looksLikeUriPath(value)) {
|
|
166
|
+
const leafField = fieldPath.split(".").pop() ?? "";
|
|
167
|
+
if (!SECRET_LOCATION_FIELD_NAMES.has(leafField)) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
159
171
|
return {
|
|
160
172
|
reason: "write_validation_failed:sensitivity_scan_failed",
|
|
161
173
|
field: fieldPath,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Read-model snapshots aligned with state-system v5 (subset for S1/S2).
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { LifeEvidenceSourceRef, LifeEvidenceType } from "../life-evidence/types.js";
|
|
5
5
|
export interface LifeEvidenceQuery {
|
|
6
6
|
windowStart?: string;
|
|
7
7
|
windowEnd?: string;
|
|
@@ -14,7 +14,7 @@ export interface SourceCoverage {
|
|
|
14
14
|
claimCoverage: Array<{
|
|
15
15
|
claimId: string;
|
|
16
16
|
backed: boolean;
|
|
17
|
-
sourceRefs:
|
|
17
|
+
sourceRefs: LifeEvidenceSourceRef[];
|
|
18
18
|
}>;
|
|
19
19
|
}
|
|
20
20
|
export interface LifeEvidenceReadModel {
|
|
@@ -24,7 +24,7 @@ export interface LifeEvidenceReadModel {
|
|
|
24
24
|
platformId?: string;
|
|
25
25
|
summary: string;
|
|
26
26
|
rawContentRef?: string;
|
|
27
|
-
sourceRefs:
|
|
27
|
+
sourceRefs: LifeEvidenceSourceRef[];
|
|
28
28
|
sensitivity: import("../life-evidence/types.js").Sensitivity;
|
|
29
29
|
confidence: number;
|
|
30
30
|
tags: string[];
|
|
@@ -35,11 +35,11 @@ export interface LifeEvidenceSnapshot {
|
|
|
35
35
|
generatedAt: string;
|
|
36
36
|
windowStart: string;
|
|
37
37
|
windowEnd: string;
|
|
38
|
-
evidenceRefs:
|
|
38
|
+
evidenceRefs: LifeEvidenceSourceRef[];
|
|
39
39
|
platformEvents: LifeEvidenceReadModel[];
|
|
40
40
|
workEvents: LifeEvidenceReadModel[];
|
|
41
41
|
userInteractionEvents: LifeEvidenceReadModel[];
|
|
42
|
-
quietArtifacts:
|
|
42
|
+
quietArtifacts: LifeEvidenceSourceRef[];
|
|
43
43
|
coverage: SourceCoverage;
|
|
44
44
|
empty: boolean;
|
|
45
45
|
}
|
|
@@ -47,12 +47,12 @@ export interface ContinuitySnapshot {
|
|
|
47
47
|
snapshotId: string;
|
|
48
48
|
generatedAt: string;
|
|
49
49
|
lastHeartbeatAt?: string;
|
|
50
|
-
recentDecisionRefs:
|
|
51
|
-
openObligations:
|
|
50
|
+
recentDecisionRefs: LifeEvidenceSourceRef[];
|
|
51
|
+
openObligations: LifeEvidenceSourceRef[];
|
|
52
52
|
quietDebt: {
|
|
53
53
|
hasUnprocessedEvidence: boolean;
|
|
54
54
|
oldestUnprocessedEvidenceAt?: string;
|
|
55
55
|
pendingCount: number;
|
|
56
56
|
};
|
|
57
|
-
fallbackRefs:
|
|
57
|
+
fallbackRefs: LifeEvidenceSourceRef[];
|
|
58
58
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Test coverage: tests/unit/storage/user-interest-snapshot.test.ts
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { LifeEvidenceSourceRef } from "../life-evidence/types.js";
|
|
7
7
|
export type UserInterestStaleness = "fresh" | "stale" | "insufficient";
|
|
8
8
|
export interface UserInterestSignal {
|
|
9
9
|
id: string;
|
|
@@ -11,14 +11,14 @@ export interface UserInterestSignal {
|
|
|
11
11
|
affinity: "positive" | "negative" | "watching" | "unknown";
|
|
12
12
|
reason: string;
|
|
13
13
|
confidence: number;
|
|
14
|
-
sourceRefs:
|
|
14
|
+
sourceRefs: LifeEvidenceSourceRef[];
|
|
15
15
|
updatedAt: string;
|
|
16
16
|
}
|
|
17
17
|
export interface UserInterestSnapshot {
|
|
18
18
|
snapshotId: string;
|
|
19
19
|
generatedAt: string;
|
|
20
20
|
signals: UserInterestSignal[];
|
|
21
|
-
sourceRefs:
|
|
21
|
+
sourceRefs: LifeEvidenceSourceRef[];
|
|
22
22
|
confidence: number;
|
|
23
23
|
staleness: UserInterestStaleness;
|
|
24
24
|
missingReasons?: string[];
|
|
@@ -120,7 +120,6 @@ export declare function writeDreamConsolidationRun(db: StateDatabase, row: Omit<
|
|
|
120
120
|
*/
|
|
121
121
|
export declare function updateDreamConsolidationRunStatus(db: StateDatabase, id: string, status: DreamConsolidationRunRecord["status"], options?: {
|
|
122
122
|
reason?: DreamConsolidationRunRecord["reason"];
|
|
123
|
-
lifecycleStatus?: DreamConsolidationRunRecord["lifecycleStatus"];
|
|
124
123
|
payloadJson?: string;
|
|
125
124
|
}): Promise<{
|
|
126
125
|
id: string;
|
|
@@ -133,6 +132,14 @@ export declare function readDreamConsolidationRunsByQuietId(db: StateDatabase, q
|
|
|
133
132
|
rows: DreamConsolidationRunRecord[];
|
|
134
133
|
degraded?: DegradedOperationResult;
|
|
135
134
|
}>;
|
|
135
|
+
/**
|
|
136
|
+
* Read the most recent DreamConsolidationRun globally, filtered by status.
|
|
137
|
+
* Used to enforce the 7-day Dream interval across Quiet review IDs.
|
|
138
|
+
*/
|
|
139
|
+
export declare function readLatestDreamConsolidationRunByStatus(db: StateDatabase, statuses: DreamConsolidationRunRecord["status"][]): Promise<{
|
|
140
|
+
row?: DreamConsolidationRunRecord;
|
|
141
|
+
degraded?: DegradedOperationResult;
|
|
142
|
+
}>;
|
|
136
143
|
export declare function writeLongTermMemoryProjection(db: StateDatabase, row: Omit<NewLongTermMemoryProjectionRecord, "sourceRefsJson"> & {
|
|
137
144
|
sourceRefs: SourceRef[];
|
|
138
145
|
}): Promise<{
|