@haaaiawd/second-nature 0.2.9 → 0.2.13

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.
Files changed (115) hide show
  1. package/index.js +102 -6
  2. package/openclaw.plugin.json +2 -5
  3. package/package.json +1 -1
  4. package/runtime/cli/commands/index.js +85 -11
  5. package/runtime/cli/host-capability/host-discovery-port.d.ts +85 -0
  6. package/runtime/cli/host-capability/host-discovery-port.js +137 -0
  7. package/runtime/cli/host-capability/probe-host-capability.js +1 -1
  8. package/runtime/cli/host-capability/types.d.ts +2 -7
  9. package/runtime/cli/host-capability/types.js +0 -5
  10. package/runtime/cli/ops/heartbeat-surface.d.ts +5 -3
  11. package/runtime/cli/ops/heartbeat-surface.js +38 -8
  12. package/runtime/cli/ops/ops-router.d.ts +6 -2
  13. package/runtime/cli/ops/ops-router.js +1275 -1147
  14. package/runtime/cli/ops/workspace-heartbeat-runner.js +2 -5
  15. package/runtime/connectors/base/normalized-evidence-content.d.ts +4 -0
  16. package/runtime/connectors/base/normalized-evidence-content.js +21 -2
  17. package/runtime/connectors/evidence-normalizer.js +32 -1
  18. package/runtime/connectors/manifest/manifest-schema.d.ts +2 -2
  19. package/runtime/connectors/registry/dynamic-connector-registry.js +16 -1
  20. package/runtime/connectors/services/connector-executor-adapter.js +54 -35
  21. package/runtime/core/second-nature/action/action-closure-recorder.d.ts +4 -0
  22. package/runtime/core/second-nature/action/action-closure-recorder.js +51 -38
  23. package/runtime/core/second-nature/action/action-proposal-builder.js +8 -34
  24. package/runtime/core/second-nature/action/policy-bound-dispatch.d.ts +2 -0
  25. package/runtime/core/second-nature/action/policy-bound-dispatch.js +10 -5
  26. package/runtime/core/second-nature/control-plane/accepted-projection-loader.js +1 -11
  27. package/runtime/core/second-nature/control-plane/cycle-finalizer.d.ts +82 -0
  28. package/runtime/core/second-nature/control-plane/cycle-finalizer.js +187 -0
  29. package/runtime/core/second-nature/control-plane/heartbeat-orchestrator.d.ts +1 -0
  30. package/runtime/core/second-nature/control-plane/heartbeat-orchestrator.js +23 -15
  31. package/runtime/core/second-nature/control-plane/real-runtime-spine.d.ts +2 -0
  32. package/runtime/core/second-nature/control-plane/real-runtime-spine.js +2 -1
  33. package/runtime/core/second-nature/guidance/guidance-proposal-consumer.d.ts +2 -1
  34. package/runtime/core/second-nature/guidance/guidance-proposal-consumer.js +4 -2
  35. package/runtime/core/second-nature/heartbeat/heartbeat-loop.js +4 -3
  36. package/runtime/core/second-nature/heartbeat/runtime-snapshot.d.ts +3 -2
  37. package/runtime/core/second-nature/heartbeat/snapshot-builder.d.ts +3 -2
  38. package/runtime/core/second-nature/orchestrator/intent-planner.js +4 -2
  39. package/runtime/core/second-nature/orchestrator/narrative-update.js +1 -2
  40. package/runtime/core/second-nature/orchestrator/platform-capability-router.d.ts +2 -2
  41. package/runtime/core/second-nature/orchestrator/platform-capability-router.js +1 -1
  42. package/runtime/core/second-nature/outreach/build-outreach-draft-request.js +2 -3
  43. package/runtime/core/second-nature/outreach/dispatch-user-outreach.d.ts +2 -2
  44. package/runtime/core/second-nature/outreach/dispatch-user-outreach.js +6 -1
  45. package/runtime/core/second-nature/outreach/judge-input-from-snapshot.js +3 -14
  46. package/runtime/core/second-nature/outreach/judge-outreach.d.ts +6 -5
  47. package/runtime/core/second-nature/perception/judgment-engine.js +10 -16
  48. package/runtime/core/second-nature/perception/perception-builder.js +15 -11
  49. package/runtime/core/second-nature/quiet/run-source-backed-quiet.js +13 -15
  50. package/runtime/core/second-nature/quiet-dream/daily-rhythm-scheduler.js +40 -16
  51. package/runtime/core/second-nature/quiet-dream/dream-consolidation-runner.d.ts +5 -1
  52. package/runtime/core/second-nature/quiet-dream/dream-consolidation-runner.js +68 -29
  53. package/runtime/core/second-nature/quiet-dream/dream-scheduler.js +2 -3
  54. package/runtime/core/second-nature/quiet-dream/memory-projection-lifecycle.js +2 -13
  55. package/runtime/core/second-nature/quiet-dream/quiet-daily-review-builder.d.ts +1 -0
  56. package/runtime/core/second-nature/quiet-dream/quiet-daily-review-builder.js +34 -11
  57. package/runtime/core/second-nature/types.d.ts +2 -9
  58. package/runtime/dream/dream-engine.js +11 -4
  59. package/runtime/guidance/outreach-draft-schema.d.ts +12 -12
  60. package/runtime/guidance/persona-selection.js +5 -0
  61. package/runtime/guidance/template-registry.js +6 -1
  62. package/runtime/guidance/types.d.ts +2 -2
  63. package/runtime/observability/causal-loop-health.d.ts +2 -1
  64. package/runtime/observability/causal-loop-health.js +7 -0
  65. package/runtime/observability/living-loop-health-gate.js +2 -8
  66. package/runtime/observability/loop-stage-event-sink.js +6 -2
  67. package/runtime/observability/loop-status.d.ts +2 -0
  68. package/runtime/observability/loop-status.js +14 -1
  69. package/runtime/observability/services/heartbeat-digest-assembler.d.ts +3 -0
  70. package/runtime/observability/services/heartbeat-digest-assembler.js +9 -0
  71. package/runtime/observability/services/lived-experience-audit.d.ts +7 -7
  72. package/runtime/shared/degraded-status-classifier.d.ts +16 -0
  73. package/runtime/shared/degraded-status-classifier.js +68 -0
  74. package/runtime/shared/evidence-level-classifier.d.ts +61 -0
  75. package/runtime/shared/evidence-level-classifier.js +116 -0
  76. package/runtime/shared/provenance-tier.d.ts +37 -0
  77. package/runtime/shared/provenance-tier.js +97 -0
  78. package/runtime/shared/serialization.d.ts +17 -0
  79. package/runtime/shared/serialization.js +27 -0
  80. package/runtime/shared/setup-ack.d.ts +54 -0
  81. package/runtime/shared/setup-ack.js +108 -0
  82. package/runtime/shared/source-ref-compat.d.ts +26 -0
  83. package/runtime/shared/source-ref-compat.js +64 -0
  84. package/runtime/shared/types/goal.d.ts +4 -4
  85. package/runtime/shared/types/goal.js +1 -1
  86. package/runtime/shared/types/index.d.ts +1 -0
  87. package/runtime/shared/types/index.js +1 -3
  88. package/runtime/shared/types/source-ref.d.ts +2 -2
  89. package/runtime/shared/types/v7-entities.d.ts +5 -5
  90. package/runtime/shared/types/v7-entities.js +1 -1
  91. package/runtime/shared/types/v8-contracts.d.ts +13 -2
  92. package/runtime/storage/db/index.js +60 -12
  93. package/runtime/storage/db/migrations/index.js +4 -0
  94. package/runtime/storage/db/migrations/v8-004-schema-closure.d.ts +19 -0
  95. package/runtime/storage/db/migrations/v8-004-schema-closure.js +74 -0
  96. package/runtime/storage/db/migrations/v8-005-single-status-schema.d.ts +11 -0
  97. package/runtime/storage/db/migrations/v8-005-single-status-schema.js +16 -0
  98. package/runtime/storage/db/migrations/v8-006-loop-stage-event-proof-trace-columns.d.ts +9 -0
  99. package/runtime/storage/db/migrations/v8-006-loop-stage-event-proof-trace-columns.js +15 -0
  100. package/runtime/storage/db/schema/v8-entities.d.ts +65 -84
  101. package/runtime/storage/db/schema/v8-entities.js +8 -7
  102. package/runtime/storage/delivery/types.d.ts +2 -2
  103. package/runtime/storage/fallback/load-operator-fallback.d.ts +2 -2
  104. package/runtime/storage/fallback/operator-fallback-types.d.ts +2 -2
  105. package/runtime/storage/fallback/operator-fallback-view.d.ts +2 -2
  106. package/runtime/storage/index.d.ts +1 -1
  107. package/runtime/storage/life-evidence/types.d.ts +5 -5
  108. package/runtime/storage/quiet/quiet-artifact-types.d.ts +4 -4
  109. package/runtime/storage/quiet/quiet-artifact-writer.d.ts +2 -2
  110. package/runtime/storage/services/write-validation-gate.d.ts +1 -1
  111. package/runtime/storage/services/write-validation-gate.js +15 -3
  112. package/runtime/storage/snapshots/types.d.ts +8 -8
  113. package/runtime/storage/user-interest/types.d.ts +3 -3
  114. package/runtime/storage/v8-state-stores.d.ts +15 -3
  115. package/runtime/storage/v8-state-stores.js +60 -39
@@ -968,15 +968,15 @@ export declare const actionClosureRecord: import("drizzle-orm/sqlite-core").SQLi
968
968
  }, {}, {
969
969
  length: number | undefined;
970
970
  }>;
971
- redactionClass: import("drizzle-orm/sqlite-core").SQLiteColumn<{
972
- name: "redaction_class";
971
+ proofRefsJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
972
+ name: "proof_refs_json";
973
973
  tableName: "action_closure_record";
974
974
  dataType: "string";
975
975
  columnType: "SQLiteText";
976
976
  data: string;
977
977
  driverParam: string;
978
- notNull: true;
979
- hasDefault: true;
978
+ notNull: false;
979
+ hasDefault: false;
980
980
  isPrimaryKey: false;
981
981
  isAutoincrement: false;
982
982
  hasRuntimeDefault: false;
@@ -987,8 +987,8 @@ export declare const actionClosureRecord: import("drizzle-orm/sqlite-core").SQLi
987
987
  }, {}, {
988
988
  length: number | undefined;
989
989
  }>;
990
- payloadJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
991
- name: "payload_json";
990
+ traceRefsJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
991
+ name: "trace_refs_json";
992
992
  tableName: "action_closure_record";
993
993
  dataType: "string";
994
994
  columnType: "SQLiteText";
@@ -1006,8 +1006,8 @@ 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";
1009
+ redactionClass: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1010
+ name: "redaction_class";
1011
1011
  tableName: "action_closure_record";
1012
1012
  dataType: "string";
1013
1013
  columnType: "SQLiteText";
@@ -1025,6 +1025,25 @@ export declare const actionClosureRecord: import("drizzle-orm/sqlite-core").SQLi
1025
1025
  }, {}, {
1026
1026
  length: number | undefined;
1027
1027
  }>;
1028
+ payloadJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1029
+ name: "payload_json";
1030
+ tableName: "action_closure_record";
1031
+ dataType: "string";
1032
+ columnType: "SQLiteText";
1033
+ data: string;
1034
+ driverParam: string;
1035
+ notNull: false;
1036
+ hasDefault: false;
1037
+ isPrimaryKey: false;
1038
+ isAutoincrement: false;
1039
+ hasRuntimeDefault: false;
1040
+ enumValues: [string, ...string[]];
1041
+ baseColumn: never;
1042
+ identity: undefined;
1043
+ generated: undefined;
1044
+ }, {}, {
1045
+ length: number | undefined;
1046
+ }>;
1028
1047
  };
1029
1048
  dialect: "sqlite";
1030
1049
  }>;
@@ -1381,25 +1400,6 @@ export declare const dreamConsolidationRun: import("drizzle-orm/sqlite-core").SQ
1381
1400
  }, {}, {
1382
1401
  length: number | undefined;
1383
1402
  }>;
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
1403
  };
1404
1404
  dialect: "sqlite";
1405
1405
  }>;
@@ -1561,25 +1561,6 @@ export declare const longTermMemoryProjection: import("drizzle-orm/sqlite-core")
1561
1561
  }, {}, {
1562
1562
  length: number | undefined;
1563
1563
  }>;
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
1564
  };
1584
1565
  dialect: "sqlite";
1585
1566
  }>;
@@ -1790,25 +1771,6 @@ export declare const heartbeatCycleTrace: import("drizzle-orm/sqlite-core").SQLi
1790
1771
  }, {}, {
1791
1772
  length: number | undefined;
1792
1773
  }>;
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
1774
  };
1813
1775
  dialect: "sqlite";
1814
1776
  }>;
@@ -1949,6 +1911,44 @@ export declare const loopStageEvent: import("drizzle-orm/sqlite-core").SQLiteTab
1949
1911
  }, {}, {
1950
1912
  length: number | undefined;
1951
1913
  }>;
1914
+ proofRefsJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1915
+ name: "proof_refs_json";
1916
+ tableName: "loop_stage_event";
1917
+ dataType: "string";
1918
+ columnType: "SQLiteText";
1919
+ data: string;
1920
+ driverParam: string;
1921
+ notNull: false;
1922
+ hasDefault: false;
1923
+ isPrimaryKey: false;
1924
+ isAutoincrement: false;
1925
+ hasRuntimeDefault: false;
1926
+ enumValues: [string, ...string[]];
1927
+ baseColumn: never;
1928
+ identity: undefined;
1929
+ generated: undefined;
1930
+ }, {}, {
1931
+ length: number | undefined;
1932
+ }>;
1933
+ traceRefsJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1934
+ name: "trace_refs_json";
1935
+ tableName: "loop_stage_event";
1936
+ dataType: "string";
1937
+ columnType: "SQLiteText";
1938
+ data: string;
1939
+ driverParam: string;
1940
+ notNull: false;
1941
+ hasDefault: false;
1942
+ isPrimaryKey: false;
1943
+ isAutoincrement: false;
1944
+ hasRuntimeDefault: false;
1945
+ enumValues: [string, ...string[]];
1946
+ baseColumn: never;
1947
+ identity: undefined;
1948
+ generated: undefined;
1949
+ }, {}, {
1950
+ length: number | undefined;
1951
+ }>;
1952
1952
  redactionClass: import("drizzle-orm/sqlite-core").SQLiteColumn<{
1953
1953
  name: "redaction_class";
1954
1954
  tableName: "loop_stage_event";
@@ -2023,25 +2023,6 @@ export declare const loopStageEvent: import("drizzle-orm/sqlite-core").SQLiteTab
2023
2023
  }, {}, {
2024
2024
  length: number | undefined;
2025
2025
  }>;
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
2026
  };
2046
2027
  dialect: "sqlite";
2047
2028
  }>;
@@ -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
  // ───────────────────────────────────────────────────────────────
@@ -81,9 +83,10 @@ export const actionClosureRecord = sqliteTable("action_closure_record", {
81
83
  reason: text("reason"),
82
84
  nextState: text("next_state"),
83
85
  sourceRefsJson: text("source_refs_json").notNull(),
86
+ proofRefsJson: text("proof_refs_json"),
87
+ traceRefsJson: text("trace_refs_json"),
84
88
  redactionClass: text("redaction_class").notNull().default("none"),
85
89
  payloadJson: text("payload_json"),
86
- lifecycleStatus: text("lifecycle_status").notNull().default("closed"),
87
90
  });
88
91
  // ───────────────────────────────────────────────────────────────
89
92
  // 5. QuietDailyReview
@@ -112,7 +115,6 @@ export const dreamConsolidationRun = sqliteTable("dream_consolidation_run", {
112
115
  sourceRefsJson: text("source_refs_json").notNull(),
113
116
  redactionClass: text("redaction_class").notNull().default("none"),
114
117
  payloadJson: text("payload_json"),
115
- lifecycleStatus: text("lifecycle_status").notNull().default("pending"),
116
118
  });
117
119
  // ───────────────────────────────────────────────────────────────
118
120
  // 7. LongTermMemoryProjection
@@ -126,7 +128,6 @@ export const longTermMemoryProjection = sqliteTable("long_term_memory_projection
126
128
  sourceRefsJson: text("source_refs_json").notNull(),
127
129
  redactionClass: text("redaction_class").notNull().default("none"),
128
130
  payloadJson: text("payload_json"),
129
- lifecycleStatus: text("lifecycle_status").notNull().default("candidate"),
130
131
  });
131
132
  // ───────────────────────────────────────────────────────────────
132
133
  // 8. HeartbeatCycleTrace
@@ -143,7 +144,6 @@ export const heartbeatCycleTrace = sqliteTable("heartbeat_cycle_trace", {
143
144
  sourceRefsJson: text("source_refs_json"),
144
145
  redactionClass: text("redaction_class").notNull().default("none"),
145
146
  payloadJson: text("payload_json"),
146
- lifecycleStatus: text("lifecycle_status").notNull().default("started"),
147
147
  });
148
148
  // ───────────────────────────────────────────────────────────────
149
149
  // 9. LoopStageEvent
@@ -156,11 +156,12 @@ export const loopStageEvent = sqliteTable("loop_stage_event", {
156
156
  status: text("status").notNull(),
157
157
  reason: text("reason"),
158
158
  sourceRefsJson: text("source_refs_json").notNull(),
159
+ proofRefsJson: text("proof_refs_json"),
160
+ traceRefsJson: text("trace_refs_json"),
159
161
  redactionClass: text("redaction_class").notNull().default("none"),
160
162
  occurredAt: text("occurred_at").notNull(),
161
163
  expectedDownstreamByCycle: integer("expected_downstream_by_cycle"),
162
164
  payloadJson: text("payload_json"),
163
- lifecycleStatus: text("lifecycle_status").notNull().default("started"),
164
165
  });
165
166
  // ───────────────────────────────────────────────────────────────
166
167
  // 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 { SourceRef } from "../life-evidence/types.js";
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?: SourceRef;
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 { SourceRef } from "../life-evidence/types.js";
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: SourceRef[];
10
+ sourceRefs: LifeEvidenceSourceRef[];
11
11
  candidateMessage?: string;
12
12
  nextStep: string;
13
13
  } | null>;
@@ -1,9 +1,9 @@
1
- import type { SourceRef } from "../life-evidence/types.js";
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: SourceRef[];
6
+ sourceRefs: LifeEvidenceSourceRef[];
7
7
  candidateMessage?: string;
8
8
  nextStep: string;
9
9
  }
@@ -1,11 +1,11 @@
1
- import type { SourceRef } from "../life-evidence/types.js";
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: SourceRef[];
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, SourceRef, } from "./life-evidence/types.js";
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 SourceRef {
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: SourceRef[];
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: SourceRef[];
35
+ sourceRefs: LifeEvidenceSourceRef[];
36
36
  sensitivity: Sensitivity;
37
37
  confidence: number;
38
38
  tags: string[];
39
39
  producer: string;
40
- artifactRef: SourceRef;
40
+ artifactRef: LifeEvidenceSourceRef;
41
41
  }
42
42
  export interface LifeEvidenceWriteAck {
43
43
  evidenceId: string;
44
- artifactRef: SourceRef;
44
+ artifactRef: LifeEvidenceSourceRef;
45
45
  }
@@ -1,10 +1,10 @@
1
- import type { SourceRef } from "../life-evidence/types.js";
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: SourceRef[];
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: SourceRef[];
17
- memoryCandidateRefs?: SourceRef[];
16
+ sourceRefs: LifeEvidenceSourceRef[];
17
+ memoryCandidateRefs?: LifeEvidenceSourceRef[];
18
18
  }
@@ -1,4 +1,4 @@
1
- import type { SourceRef } from "../life-evidence/types.js";
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: SourceRef;
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
- * - `SourceRef` type from `../../shared/types/source-ref.js`
10
+ * - `SourceRefTuple` type from `../../shared/types/source-ref.js`
11
11
  * - v7 entity types for shape awareness
12
12
  *
13
13
  * Boundary:
@@ -7,7 +7,7 @@
7
7
  * readable reason codes (DR-022).
8
8
  *
9
9
  * Dependencies:
10
- * - `SourceRef` type from `../../shared/types/source-ref.js`
10
+ * - `SourceRefTuple` type from `../../shared/types/source-ref.js`
11
11
  * - v7 entity types for shape awareness
12
12
  *
13
13
  * Boundary:
@@ -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
- continue;
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 { LifeEvidenceType, SourceRef } from "../life-evidence/types.js";
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: SourceRef[];
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: SourceRef[];
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: SourceRef[];
38
+ evidenceRefs: LifeEvidenceSourceRef[];
39
39
  platformEvents: LifeEvidenceReadModel[];
40
40
  workEvents: LifeEvidenceReadModel[];
41
41
  userInteractionEvents: LifeEvidenceReadModel[];
42
- quietArtifacts: SourceRef[];
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: SourceRef[];
51
- openObligations: SourceRef[];
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: SourceRef[];
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 { SourceRef } from "../life-evidence/types.js";
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: SourceRef[];
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: SourceRef[];
21
+ sourceRefs: LifeEvidenceSourceRef[];
22
22
  confidence: number;
23
23
  staleness: UserInterestStaleness;
24
24
  missingReasons?: string[];
@@ -82,8 +82,11 @@ export declare function readJudgmentVerdictById(db: StateDatabase, id: string):
82
82
  row?: JudgmentVerdictRecord;
83
83
  degraded?: DegradedOperationResult;
84
84
  }>;
85
- export declare function writeActionClosureRecord(db: StateDatabase, row: Omit<ActionClosureRecordInsert, "sourceRefsJson"> & {
85
+ export declare function writeActionClosureRecord(db: StateDatabase, row: Omit<ActionClosureRecordInsert, "sourceRefsJson" | "proofRefsJson" | "traceRefsJson" | "payloadJson"> & {
86
86
  sourceRefs: SourceRef[];
87
+ proofRefs?: SourceRef[];
88
+ traceRefs?: SourceRef[];
89
+ payload?: Record<string, unknown>;
87
90
  }): Promise<{
88
91
  id: string;
89
92
  } | DegradedOperationResult>;
@@ -120,7 +123,6 @@ export declare function writeDreamConsolidationRun(db: StateDatabase, row: Omit<
120
123
  */
121
124
  export declare function updateDreamConsolidationRunStatus(db: StateDatabase, id: string, status: DreamConsolidationRunRecord["status"], options?: {
122
125
  reason?: DreamConsolidationRunRecord["reason"];
123
- lifecycleStatus?: DreamConsolidationRunRecord["lifecycleStatus"];
124
126
  payloadJson?: string;
125
127
  }): Promise<{
126
128
  id: string;
@@ -133,6 +135,14 @@ export declare function readDreamConsolidationRunsByQuietId(db: StateDatabase, q
133
135
  rows: DreamConsolidationRunRecord[];
134
136
  degraded?: DegradedOperationResult;
135
137
  }>;
138
+ /**
139
+ * Read the most recent DreamConsolidationRun globally, filtered by status.
140
+ * Used to enforce the 7-day Dream interval across Quiet review IDs.
141
+ */
142
+ export declare function readLatestDreamConsolidationRunByStatus(db: StateDatabase, statuses: DreamConsolidationRunRecord["status"][]): Promise<{
143
+ row?: DreamConsolidationRunRecord;
144
+ degraded?: DegradedOperationResult;
145
+ }>;
136
146
  export declare function writeLongTermMemoryProjection(db: StateDatabase, row: Omit<NewLongTermMemoryProjectionRecord, "sourceRefsJson"> & {
137
147
  sourceRefs: SourceRef[];
138
148
  }): Promise<{
@@ -166,8 +176,10 @@ export declare function readHeartbeatCycleTraces(db: StateDatabase, limit?: numb
166
176
  rows: HeartbeatCycleTraceRecord[];
167
177
  degraded?: DegradedOperationResult;
168
178
  }>;
169
- export declare function writeLoopStageEvent(db: StateDatabase, row: Omit<NewLoopStageEventRecord, "sourceRefsJson"> & {
179
+ export declare function writeLoopStageEvent(db: StateDatabase, row: Omit<NewLoopStageEventRecord, "sourceRefsJson" | "proofRefsJson" | "traceRefsJson"> & {
170
180
  sourceRefs: SourceRef[];
181
+ proofRefs?: SourceRef[];
182
+ traceRefs?: SourceRef[];
171
183
  }): Promise<{
172
184
  id: string;
173
185
  } | DegradedOperationResult>;