@haaaiawd/second-nature 0.1.8 → 0.1.9

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 (183) hide show
  1. package/index.js +73 -1
  2. package/openclaw.plugin.json +1 -1
  3. package/package.json +1 -1
  4. package/runtime/cli/commands/index.d.ts +2 -0
  5. package/runtime/cli/commands/index.js +61 -6
  6. package/runtime/cli/explain/explain-surface-subject.d.ts +8 -0
  7. package/runtime/cli/explain/explain-surface-subject.js +9 -0
  8. package/runtime/cli/explain/format-explanation.d.ts +2 -0
  9. package/runtime/cli/explain/format-explanation.js +2 -0
  10. package/runtime/cli/explain/resolve-subject.js +15 -0
  11. package/runtime/cli/host-capability/classify-delivery.d.ts +14 -0
  12. package/runtime/cli/host-capability/classify-delivery.js +20 -0
  13. package/runtime/cli/host-capability/probe-host-capability.d.ts +2 -0
  14. package/runtime/cli/host-capability/probe-host-capability.js +58 -0
  15. package/runtime/cli/host-capability/record-host-capability.d.ts +6 -0
  16. package/runtime/cli/host-capability/record-host-capability.js +14 -0
  17. package/runtime/cli/host-capability/types.d.ts +71 -0
  18. package/runtime/cli/host-capability/types.js +6 -0
  19. package/runtime/cli/host-smoke/run-host-smoke.d.ts +2 -0
  20. package/runtime/cli/host-smoke/run-host-smoke.js +40 -0
  21. package/runtime/cli/host-smoke/types.d.ts +35 -0
  22. package/runtime/cli/host-smoke/types.js +6 -0
  23. package/runtime/cli/index.js +18 -0
  24. package/runtime/cli/ops/heartbeat-surface.d.ts +35 -0
  25. package/runtime/cli/ops/heartbeat-surface.js +71 -0
  26. package/runtime/cli/ops/ops-router.d.ts +16 -0
  27. package/runtime/cli/ops/ops-router.js +83 -0
  28. package/runtime/cli/ops/show-operator-fallback.d.ts +13 -0
  29. package/runtime/cli/ops/show-operator-fallback.js +22 -0
  30. package/runtime/cli/ops/workspace-heartbeat-runner.d.ts +10 -0
  31. package/runtime/cli/ops/workspace-heartbeat-runner.js +26 -0
  32. package/runtime/cli/read-models/index.d.ts +11 -2
  33. package/runtime/cli/read-models/index.js +50 -0
  34. package/runtime/cli/read-models/operator-explain-map.d.ts +6 -0
  35. package/runtime/cli/read-models/operator-explain-map.js +10 -0
  36. package/runtime/cli/read-models/types.d.ts +5 -1
  37. package/runtime/cli/runtime/runtime-artifact-boundary.d.ts +28 -0
  38. package/runtime/cli/runtime/runtime-artifact-boundary.js +94 -0
  39. package/runtime/connectors/base/contract.d.ts +6 -0
  40. package/runtime/connectors/base/execution-policy.d.ts +47 -0
  41. package/runtime/connectors/base/execution-policy.js +82 -0
  42. package/runtime/connectors/base/index.d.ts +2 -0
  43. package/runtime/connectors/base/index.js +2 -0
  44. package/runtime/connectors/base/manifest.d.ts +55 -2
  45. package/runtime/connectors/base/manifest.js +50 -0
  46. package/runtime/connectors/base/map-life-evidence.d.ts +16 -0
  47. package/runtime/connectors/base/map-life-evidence.js +79 -0
  48. package/runtime/connectors/base/policy-layer.d.ts +2 -0
  49. package/runtime/connectors/base/policy-layer.js +16 -0
  50. package/runtime/connectors/base/route-planner.js +1 -0
  51. package/runtime/connectors/index.d.ts +1 -0
  52. package/runtime/connectors/index.js +1 -0
  53. package/runtime/connectors/near-real/near-real-connector-smoke.d.ts +19 -0
  54. package/runtime/connectors/near-real/near-real-connector-smoke.js +152 -0
  55. package/runtime/core/second-nature/heartbeat/heartbeat-executor.js +2 -0
  56. package/runtime/core/second-nature/heartbeat/heartbeat-loop.d.ts +37 -16
  57. package/runtime/core/second-nature/heartbeat/heartbeat-loop.js +95 -29
  58. package/runtime/core/second-nature/heartbeat/index.d.ts +4 -1
  59. package/runtime/core/second-nature/heartbeat/index.js +4 -1
  60. package/runtime/core/second-nature/heartbeat/run-heartbeat-cycle.d.ts +21 -0
  61. package/runtime/core/second-nature/heartbeat/run-heartbeat-cycle.js +35 -0
  62. package/runtime/core/second-nature/heartbeat/runtime-snapshot.d.ts +28 -0
  63. package/runtime/core/second-nature/heartbeat/runtime-snapshot.js +35 -0
  64. package/runtime/core/second-nature/heartbeat/signal.d.ts +9 -2
  65. package/runtime/core/second-nature/heartbeat/snapshot-builder.d.ts +19 -1
  66. package/runtime/core/second-nature/index.d.ts +8 -0
  67. package/runtime/core/second-nature/index.js +8 -0
  68. package/runtime/core/second-nature/orchestrator/effect-dispatcher.d.ts +1 -1
  69. package/runtime/core/second-nature/orchestrator/effect-dispatcher.js +9 -4
  70. package/runtime/core/second-nature/orchestrator/guard-layer.d.ts +6 -0
  71. package/runtime/core/second-nature/orchestrator/guard-layer.js +76 -20
  72. package/runtime/core/second-nature/orchestrator/intent-planner.d.ts +10 -0
  73. package/runtime/core/second-nature/orchestrator/intent-planner.js +135 -28
  74. package/runtime/core/second-nature/orchestrator/lease-manager.d.ts +1 -1
  75. package/runtime/core/second-nature/orchestrator/lease-manager.js +1 -1
  76. package/runtime/core/second-nature/outreach/build-outreach-draft-request.d.ts +6 -0
  77. package/runtime/core/second-nature/outreach/build-outreach-draft-request.js +63 -0
  78. package/runtime/core/second-nature/outreach/delivery-target.d.ts +26 -0
  79. package/runtime/core/second-nature/outreach/delivery-target.js +70 -0
  80. package/runtime/core/second-nature/outreach/dispatch-user-outreach.d.ts +38 -0
  81. package/runtime/core/second-nature/outreach/dispatch-user-outreach.js +119 -0
  82. package/runtime/core/second-nature/outreach/judge-input-from-snapshot.d.ts +7 -0
  83. package/runtime/core/second-nature/outreach/judge-input-from-snapshot.js +45 -0
  84. package/runtime/core/second-nature/outreach/judge-outreach.d.ts +40 -0
  85. package/runtime/core/second-nature/outreach/judge-outreach.js +121 -0
  86. package/runtime/core/second-nature/quiet/run-source-backed-quiet.d.ts +21 -0
  87. package/runtime/core/second-nature/quiet/run-source-backed-quiet.js +123 -0
  88. package/runtime/core/second-nature/rhythm/planner-rhythm-window.d.ts +15 -0
  89. package/runtime/core/second-nature/rhythm/planner-rhythm-window.js +52 -0
  90. package/runtime/core/second-nature/rhythm/policy-bridge.d.ts +19 -0
  91. package/runtime/core/second-nature/rhythm/policy-bridge.js +34 -0
  92. package/runtime/core/second-nature/types.d.ts +16 -2
  93. package/runtime/guidance/draft-outreach-message.d.ts +7 -0
  94. package/runtime/guidance/draft-outreach-message.js +42 -0
  95. package/runtime/guidance/evidence-guidance.d.ts +40 -0
  96. package/runtime/guidance/evidence-guidance.js +52 -0
  97. package/runtime/guidance/index.d.ts +3 -0
  98. package/runtime/guidance/index.js +3 -0
  99. package/runtime/guidance/outreach-draft-schema.d.ts +228 -0
  100. package/runtime/guidance/outreach-draft-schema.js +80 -0
  101. package/runtime/observability/audit/append-only-audit-store.d.ts +14 -0
  102. package/runtime/observability/audit/append-only-audit-store.js +21 -0
  103. package/runtime/observability/audit/audit-envelope.d.ts +51 -0
  104. package/runtime/observability/audit/audit-envelope.js +130 -0
  105. package/runtime/observability/audit/verify-audit-hash-chain.d.ts +23 -0
  106. package/runtime/observability/audit/verify-audit-hash-chain.js +83 -0
  107. package/runtime/observability/db/index.js +11 -0
  108. package/runtime/observability/db/schema/host-capability-reports.d.ts +180 -0
  109. package/runtime/observability/db/schema/host-capability-reports.js +12 -0
  110. package/runtime/observability/db/schema/index.d.ts +1 -0
  111. package/runtime/observability/db/schema/index.js +1 -0
  112. package/runtime/observability/index.d.ts +7 -0
  113. package/runtime/observability/index.js +7 -0
  114. package/runtime/observability/query/explain-query.d.ts +48 -0
  115. package/runtime/observability/query/explain-query.js +114 -0
  116. package/runtime/observability/query/export-audit-bundle.d.ts +22 -0
  117. package/runtime/observability/query/export-audit-bundle.js +27 -0
  118. package/runtime/observability/services/decision-ledger.d.ts +1 -1
  119. package/runtime/observability/services/decision-ledger.js +4 -0
  120. package/runtime/observability/services/governance-audit.d.ts +14 -0
  121. package/runtime/observability/services/governance-audit.js +25 -1
  122. package/runtime/observability/services/governance-plane-recorder.d.ts +47 -0
  123. package/runtime/observability/services/governance-plane-recorder.js +55 -0
  124. package/runtime/observability/services/lived-experience-audit.d.ts +97 -0
  125. package/runtime/observability/services/lived-experience-audit.js +161 -0
  126. package/runtime/storage/bootstrap/native-sqlite-probe.d.ts +7 -0
  127. package/runtime/storage/bootstrap/native-sqlite-probe.js +28 -0
  128. package/runtime/storage/bootstrap/repair-gate.d.ts +17 -0
  129. package/runtime/storage/bootstrap/repair-gate.js +71 -0
  130. package/runtime/storage/bootstrap/storage-mode-smoke.d.ts +38 -0
  131. package/runtime/storage/bootstrap/storage-mode-smoke.js +85 -0
  132. package/runtime/storage/db/index.js +49 -0
  133. package/runtime/storage/db/schema/delivery-attempts.d.ts +199 -0
  134. package/runtime/storage/db/schema/delivery-attempts.js +13 -0
  135. package/runtime/storage/db/schema/index.d.ts +3 -0
  136. package/runtime/storage/db/schema/index.js +3 -0
  137. package/runtime/storage/db/schema/life-evidence-index.d.ts +161 -0
  138. package/runtime/storage/db/schema/life-evidence-index.js +11 -0
  139. package/runtime/storage/db/schema/operator-fallback-artifacts.d.ts +161 -0
  140. package/runtime/storage/db/schema/operator-fallback-artifacts.js +11 -0
  141. package/runtime/storage/db/schema/policies.d.ts +17 -0
  142. package/runtime/storage/db/schema/policies.js +1 -0
  143. package/runtime/storage/delivery/query-delivery-attempts.d.ts +3 -0
  144. package/runtime/storage/delivery/query-delivery-attempts.js +32 -0
  145. package/runtime/storage/delivery/types.d.ts +27 -0
  146. package/runtime/storage/delivery/types.js +1 -0
  147. package/runtime/storage/delivery/write-delivery-attempt.d.ts +6 -0
  148. package/runtime/storage/delivery/write-delivery-attempt.js +36 -0
  149. package/runtime/storage/fallback/load-operator-fallback.d.ts +14 -0
  150. package/runtime/storage/fallback/load-operator-fallback.js +47 -0
  151. package/runtime/storage/fallback/operator-fallback-types.d.ts +9 -0
  152. package/runtime/storage/fallback/operator-fallback-types.js +1 -0
  153. package/runtime/storage/fallback/operator-fallback-view.d.ts +11 -0
  154. package/runtime/storage/fallback/operator-fallback-view.js +1 -0
  155. package/runtime/storage/fallback/write-operator-fallback.d.ts +6 -0
  156. package/runtime/storage/fallback/write-operator-fallback.js +21 -0
  157. package/runtime/storage/index.d.ts +21 -0
  158. package/runtime/storage/index.js +14 -0
  159. package/runtime/storage/life-evidence/append-life-evidence.d.ts +7 -0
  160. package/runtime/storage/life-evidence/append-life-evidence.js +64 -0
  161. package/runtime/storage/life-evidence/types.d.ts +45 -0
  162. package/runtime/storage/life-evidence/types.js +6 -0
  163. package/runtime/storage/quiet/persist-quiet-artifact.d.ts +7 -0
  164. package/runtime/storage/quiet/persist-quiet-artifact.js +22 -0
  165. package/runtime/storage/quiet/quiet-artifact-types.d.ts +18 -0
  166. package/runtime/storage/quiet/quiet-artifact-types.js +1 -0
  167. package/runtime/storage/quiet/quiet-artifact-writer.d.ts +15 -0
  168. package/runtime/storage/quiet/quiet-artifact-writer.js +56 -0
  169. package/runtime/storage/rhythm/rhythm-policy-snapshot.d.ts +10 -0
  170. package/runtime/storage/rhythm/rhythm-policy-snapshot.js +34 -0
  171. package/runtime/storage/services/credential-vault.d.ts +5 -0
  172. package/runtime/storage/services/credential-vault.js +46 -9
  173. package/runtime/storage/snapshots/continuity-snapshot.d.ts +9 -0
  174. package/runtime/storage/snapshots/continuity-snapshot.js +41 -0
  175. package/runtime/storage/snapshots/life-evidence-snapshot.d.ts +6 -0
  176. package/runtime/storage/snapshots/life-evidence-snapshot.js +114 -0
  177. package/runtime/storage/snapshots/types.d.ts +58 -0
  178. package/runtime/storage/snapshots/types.js +1 -0
  179. package/runtime/storage/state-api.js +11 -4
  180. package/runtime/storage/user-interest/load-user-interest-snapshot.d.ts +2 -0
  181. package/runtime/storage/user-interest/load-user-interest-snapshot.js +150 -0
  182. package/runtime/storage/user-interest/types.d.ts +25 -0
  183. package/runtime/storage/user-interest/types.js +1 -0
@@ -0,0 +1,180 @@
1
+ export declare const hostCapabilityReports: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
2
+ name: "host_capability_reports";
3
+ schema: undefined;
4
+ columns: {
5
+ reportId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
6
+ name: "report_id";
7
+ tableName: "host_capability_reports";
8
+ dataType: "string";
9
+ columnType: "SQLiteText";
10
+ data: string;
11
+ driverParam: string;
12
+ notNull: true;
13
+ hasDefault: false;
14
+ isPrimaryKey: true;
15
+ isAutoincrement: false;
16
+ hasRuntimeDefault: false;
17
+ enumValues: [string, ...string[]];
18
+ baseColumn: never;
19
+ identity: undefined;
20
+ generated: undefined;
21
+ }, {}, {
22
+ length: number | undefined;
23
+ }>;
24
+ generatedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
25
+ name: "generated_at";
26
+ tableName: "host_capability_reports";
27
+ dataType: "string";
28
+ columnType: "SQLiteText";
29
+ data: string;
30
+ driverParam: string;
31
+ notNull: true;
32
+ hasDefault: false;
33
+ isPrimaryKey: false;
34
+ isAutoincrement: false;
35
+ hasRuntimeDefault: false;
36
+ enumValues: [string, ...string[]];
37
+ baseColumn: never;
38
+ identity: undefined;
39
+ generated: undefined;
40
+ }, {}, {
41
+ length: number | undefined;
42
+ }>;
43
+ hostVersion: import("drizzle-orm/sqlite-core").SQLiteColumn<{
44
+ name: "host_version";
45
+ tableName: "host_capability_reports";
46
+ dataType: "string";
47
+ columnType: "SQLiteText";
48
+ data: string;
49
+ driverParam: string;
50
+ notNull: false;
51
+ hasDefault: false;
52
+ isPrimaryKey: false;
53
+ isAutoincrement: false;
54
+ hasRuntimeDefault: false;
55
+ enumValues: [string, ...string[]];
56
+ baseColumn: never;
57
+ identity: undefined;
58
+ generated: undefined;
59
+ }, {}, {
60
+ length: number | undefined;
61
+ }>;
62
+ observedVersion: import("drizzle-orm/sqlite-core").SQLiteColumn<{
63
+ name: "observed_version";
64
+ tableName: "host_capability_reports";
65
+ dataType: "string";
66
+ columnType: "SQLiteText";
67
+ data: string;
68
+ driverParam: string;
69
+ notNull: false;
70
+ hasDefault: false;
71
+ isPrimaryKey: false;
72
+ isAutoincrement: false;
73
+ hasRuntimeDefault: false;
74
+ enumValues: [string, ...string[]];
75
+ baseColumn: never;
76
+ identity: undefined;
77
+ generated: undefined;
78
+ }, {}, {
79
+ length: number | undefined;
80
+ }>;
81
+ docCheckedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
82
+ name: "doc_checked_at";
83
+ tableName: "host_capability_reports";
84
+ dataType: "string";
85
+ columnType: "SQLiteText";
86
+ data: string;
87
+ driverParam: string;
88
+ notNull: true;
89
+ hasDefault: false;
90
+ isPrimaryKey: false;
91
+ isAutoincrement: false;
92
+ hasRuntimeDefault: false;
93
+ enumValues: [string, ...string[]];
94
+ baseColumn: never;
95
+ identity: undefined;
96
+ generated: undefined;
97
+ }, {}, {
98
+ length: number | undefined;
99
+ }>;
100
+ docLinksJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
101
+ name: "doc_links_json";
102
+ tableName: "host_capability_reports";
103
+ dataType: "string";
104
+ columnType: "SQLiteText";
105
+ data: string;
106
+ driverParam: string;
107
+ notNull: true;
108
+ hasDefault: false;
109
+ isPrimaryKey: false;
110
+ isAutoincrement: false;
111
+ hasRuntimeDefault: false;
112
+ enumValues: [string, ...string[]];
113
+ baseColumn: never;
114
+ identity: undefined;
115
+ generated: undefined;
116
+ }, {}, {
117
+ length: number | undefined;
118
+ }>;
119
+ deliveryTarget: import("drizzle-orm/sqlite-core").SQLiteColumn<{
120
+ name: "delivery_target";
121
+ tableName: "host_capability_reports";
122
+ dataType: "string";
123
+ columnType: "SQLiteText";
124
+ data: string;
125
+ driverParam: string;
126
+ notNull: true;
127
+ hasDefault: false;
128
+ isPrimaryKey: false;
129
+ isAutoincrement: false;
130
+ hasRuntimeDefault: false;
131
+ enumValues: [string, ...string[]];
132
+ baseColumn: never;
133
+ identity: undefined;
134
+ generated: undefined;
135
+ }, {}, {
136
+ length: number | undefined;
137
+ }>;
138
+ conflictRecordsJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
139
+ name: "conflict_records_json";
140
+ tableName: "host_capability_reports";
141
+ dataType: "string";
142
+ columnType: "SQLiteText";
143
+ data: string;
144
+ driverParam: string;
145
+ notNull: true;
146
+ hasDefault: false;
147
+ isPrimaryKey: false;
148
+ isAutoincrement: false;
149
+ hasRuntimeDefault: false;
150
+ enumValues: [string, ...string[]];
151
+ baseColumn: never;
152
+ identity: undefined;
153
+ generated: undefined;
154
+ }, {}, {
155
+ length: number | undefined;
156
+ }>;
157
+ fullReportJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
158
+ name: "full_report_json";
159
+ tableName: "host_capability_reports";
160
+ dataType: "string";
161
+ columnType: "SQLiteText";
162
+ data: string;
163
+ driverParam: string;
164
+ notNull: true;
165
+ hasDefault: false;
166
+ isPrimaryKey: false;
167
+ isAutoincrement: false;
168
+ hasRuntimeDefault: false;
169
+ enumValues: [string, ...string[]];
170
+ baseColumn: never;
171
+ identity: undefined;
172
+ generated: undefined;
173
+ }, {}, {
174
+ length: number | undefined;
175
+ }>;
176
+ };
177
+ dialect: "sqlite";
178
+ }>;
179
+ export type HostCapabilityReportRow = typeof hostCapabilityReports.$inferSelect;
180
+ export type NewHostCapabilityReportRow = typeof hostCapabilityReports.$inferInsert;
@@ -0,0 +1,12 @@
1
+ import { sqliteTable, text } from "drizzle-orm/sqlite-core";
2
+ export const hostCapabilityReports = sqliteTable("host_capability_reports", {
3
+ reportId: text("report_id").primaryKey(),
4
+ generatedAt: text("generated_at").notNull(),
5
+ hostVersion: text("host_version"),
6
+ observedVersion: text("observed_version"),
7
+ docCheckedAt: text("doc_checked_at").notNull(),
8
+ docLinksJson: text("doc_links_json").notNull(),
9
+ deliveryTarget: text("delivery_target").notNull(),
10
+ conflictRecordsJson: text("conflict_records_json").notNull(),
11
+ fullReportJson: text("full_report_json").notNull(),
12
+ });
@@ -944,3 +944,4 @@ export type GovernanceAuditDb = typeof governanceAudit.$inferSelect;
944
944
  export type NewGovernanceAuditDb = typeof governanceAudit.$inferInsert;
945
945
  export type RedactionManifestDb = typeof redactionManifest.$inferSelect;
946
946
  export type NewRedactionManifestDb = typeof redactionManifest.$inferInsert;
947
+ export { hostCapabilityReports, type HostCapabilityReportRow, type NewHostCapabilityReportRow, } from "./host-capability-reports.js";
@@ -68,3 +68,4 @@ export const redactionManifest = sqliteTable("redaction_manifest", {
68
68
  }, (table) => [
69
69
  index("redact_event_idx").on(table.eventId),
70
70
  ]);
71
+ export { hostCapabilityReports, } from "./host-capability-reports.js";
@@ -1,10 +1,17 @@
1
1
  export { createObservabilityDatabase, type ObservabilityDatabase } from "./db/index.js";
2
2
  export * as obsSchema from "./db/schema/index.js";
3
+ export { buildAuditEnvelope, computeAuditRecordHash, redactAuditEvent, auditManifestFromFieldManifest, type AuditEnvelope, type AuditEnvelopeSensitivity, type AuditEventFamily, type AuditPlane, type AuditRedactionManifest, type AuditIntegrity, type BuildAuditEnvelopeInput, type RedactAuditEventResult, } from "./audit/audit-envelope.js";
4
+ export { AppendOnlyAuditStore } from "./audit/append-only-audit-store.js";
5
+ export { verifyAuditHashChain, createAppendOnlyAuditStoreRangeLoader, type AuditExportRange, type AuditHashChainVerificationReport, type AuditHashChainVerificationStatus, type VerifyAuditHashChainDeps, } from "./audit/verify-audit-hash-chain.js";
3
6
  export { REDACTION_CONFIG, DEFAULT_REDACTION_POLICY, getFieldRedactionRule, type RedactionPolicy, type RedactionRule, type SensitivityLevel, } from "./redaction/policy.js";
4
7
  export { redactEvent, createEmptyManifest, mergeManifests, type RedactionManifest, type RedactionResult, } from "./redaction/manifest.js";
5
8
  export { DecisionLedger, type QuietLifecycleEvent, type OutreachDecision, type HeartbeatDecisionEvent } from "./services/decision-ledger.js";
6
9
  export { GovernanceAudit, type CredentialLifecycleAudit } from "./services/governance-audit.js";
7
10
  export { ExecutionTelemetry, type ExecutionAttemptInput } from "./services/execution-telemetry.js";
11
+ export { LivedExperienceAuditRecorder, createLivedExperienceAuditRecorder, type DecisionTracePayload, type DeliveryAuditPayload, type DeliveryAuditStatus, type ExplainLinkageSummary, type GuidanceGroundingAuditPayload, type SourceCoverageAuditPayload, } from "./services/lived-experience-audit.js";
12
+ export { GovernancePlaneRecorder, createGovernancePlaneRecorder, type AuditAppendAck, type ConnectorAttemptAudit, type ConnectorAttemptOutcome, type StateGovernanceAudit, type StateGovernanceKind, } from "./services/governance-plane-recorder.js";
13
+ export { queryExplain, type ExplainQuery, type OperatorExplainReadModel, type RedactedExplainEvent, } from "./query/explain-query.js";
14
+ export { exportAuditBundle, type AuditBundle, type AuditBundleExportRange, type AuditRedactionSummary, type ExportAuditBundleDeps } from "./query/export-audit-bundle.js";
8
15
  export { EvidenceQueryEngine, } from "./query/evidence-query-engine.js";
9
16
  export type { EvidenceQuery, EvidenceBundle, EvidenceResolutionPlan, GovernanceEvidenceRecord, ResolvedContentRef, ExplanationCapsule, } from "./query/compose-evidence.js";
10
17
  export { projectReflectionAudit, type ReflectionAudit, type ReflectionAuditProjection, } from "./projections/reflection-audit.js";
@@ -1,10 +1,17 @@
1
1
  export { createObservabilityDatabase } from "./db/index.js";
2
2
  export * as obsSchema from "./db/schema/index.js";
3
+ export { buildAuditEnvelope, computeAuditRecordHash, redactAuditEvent, auditManifestFromFieldManifest, } from "./audit/audit-envelope.js";
4
+ export { AppendOnlyAuditStore } from "./audit/append-only-audit-store.js";
5
+ export { verifyAuditHashChain, createAppendOnlyAuditStoreRangeLoader, } from "./audit/verify-audit-hash-chain.js";
3
6
  export { REDACTION_CONFIG, DEFAULT_REDACTION_POLICY, getFieldRedactionRule, } from "./redaction/policy.js";
4
7
  export { redactEvent, createEmptyManifest, mergeManifests, } from "./redaction/manifest.js";
5
8
  export { DecisionLedger } from "./services/decision-ledger.js";
6
9
  export { GovernanceAudit } from "./services/governance-audit.js";
7
10
  export { ExecutionTelemetry } from "./services/execution-telemetry.js";
11
+ export { LivedExperienceAuditRecorder, createLivedExperienceAuditRecorder, } from "./services/lived-experience-audit.js";
12
+ export { GovernancePlaneRecorder, createGovernancePlaneRecorder, } from "./services/governance-plane-recorder.js";
13
+ export { queryExplain, } from "./query/explain-query.js";
14
+ export { exportAuditBundle } from "./query/export-audit-bundle.js";
8
15
  export { EvidenceQueryEngine, } from "./query/evidence-query-engine.js";
9
16
  export { projectReflectionAudit, } from "./projections/reflection-audit.js";
10
17
  export { projectOutreachQualityAudit, } from "./projections/outreach-quality-audit.js";
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Operator explain query over append-only audit envelopes (T5.3.1).
3
+ *
4
+ * Core logic: resolve subject to matching envelopes, compose summary + no-user-visible-contact warnings,
5
+ * expose minimal redacted event list for JSON-first read models.
6
+ *
7
+ * Dependencies: AppendOnlyAuditStore list; audit-envelope types; delivery audit payload shape from lived-experience-audit.
8
+ *
9
+ * Test coverage: tests/integration/observability/explain-query-export.test.ts
10
+ */
11
+ import type { AppendOnlyAuditStore } from "../audit/append-only-audit-store.js";
12
+ import type { DeliveryAuditPayload } from "../services/lived-experience-audit.js";
13
+ export type ExplainQuery = {
14
+ kind: "decision";
15
+ decisionId: string;
16
+ } | {
17
+ kind: "fallback";
18
+ fallbackRef: string;
19
+ } | {
20
+ kind: "report";
21
+ reportId: string;
22
+ } | {
23
+ kind: "delivery";
24
+ auditId: string;
25
+ } | {
26
+ kind: "source_ref";
27
+ sourceRefId: string;
28
+ };
29
+ export interface RedactedExplainEvent {
30
+ eventId: string;
31
+ family: string;
32
+ plane: string;
33
+ createdAt: string;
34
+ /** Minimal safe summary — no raw recipient / tokens */
35
+ summary: string;
36
+ }
37
+ export interface OperatorExplainReadModel {
38
+ query: ExplainQuery;
39
+ summary: string;
40
+ warnings: string[];
41
+ deliveryStatus?: DeliveryAuditPayload["status"];
42
+ relatedEventIds: string[];
43
+ events: RedactedExplainEvent[];
44
+ }
45
+ /**
46
+ * Query explain read model from an in-memory append-only audit slice (tests / local tooling).
47
+ */
48
+ export declare function queryExplain(query: ExplainQuery, store: AppendOnlyAuditStore): OperatorExplainReadModel;
@@ -0,0 +1,114 @@
1
+ const NO_USER_VISIBLE = "no_user_visible_contact_claim_prohibited";
2
+ function isNoUserVisibleDelivery(status) {
3
+ if (!status)
4
+ return false;
5
+ return (status === "target_none" ||
6
+ status === "not_sent_fallback" ||
7
+ status === "channel_missing" ||
8
+ status === "host_unsupported" ||
9
+ status === "failed" ||
10
+ status === "ack_dropped");
11
+ }
12
+ function payloadDecisionId(payload) {
13
+ if (!payload || typeof payload !== "object")
14
+ return undefined;
15
+ const p = payload;
16
+ const v = p.decisionId;
17
+ return typeof v === "string" ? v : undefined;
18
+ }
19
+ function payloadFallbackRef(payload) {
20
+ if (!payload || typeof payload !== "object")
21
+ return undefined;
22
+ const p = payload;
23
+ const v = p.fallbackRef;
24
+ return typeof v === "string" ? v : undefined;
25
+ }
26
+ function payloadAuditId(payload) {
27
+ if (!payload || typeof payload !== "object")
28
+ return undefined;
29
+ const p = payload;
30
+ const a = p.auditId;
31
+ if (typeof a === "string")
32
+ return a;
33
+ return undefined;
34
+ }
35
+ function deliveryStatusFrom(payload) {
36
+ if (!payload || typeof payload !== "object")
37
+ return undefined;
38
+ const p = payload;
39
+ const s = p.status;
40
+ return typeof s === "string" ? s : undefined;
41
+ }
42
+ function eventMatchesQuery(envelope, query) {
43
+ const payload = envelope.payload;
44
+ switch (query.kind) {
45
+ case "decision":
46
+ return payloadDecisionId(payload) === query.decisionId;
47
+ case "fallback":
48
+ return payloadFallbackRef(payload) === query.fallbackRef;
49
+ case "report":
50
+ return envelope.eventId === query.reportId || payloadAuditId(payload) === query.reportId;
51
+ case "delivery":
52
+ return (envelope.family === "delivery" &&
53
+ (envelope.eventId === query.auditId || payloadAuditId(payload) === query.auditId));
54
+ case "source_ref": {
55
+ const needle = query.sourceRefId;
56
+ try {
57
+ return JSON.stringify(payload).includes(needle);
58
+ }
59
+ catch {
60
+ return false;
61
+ }
62
+ }
63
+ }
64
+ }
65
+ function summarizeEnvelope(e) {
66
+ const fam = e.family;
67
+ if (fam === "delivery") {
68
+ const st = deliveryStatusFrom(e.payload);
69
+ return `delivery_audit:${st ?? "unknown"}`;
70
+ }
71
+ if (fam === "heartbeat.decision") {
72
+ const outcome = e.payload?.outcome;
73
+ return `decision:${typeof outcome === "string" ? outcome : "unknown"}`;
74
+ }
75
+ return `${fam}`;
76
+ }
77
+ /**
78
+ * Query explain read model from an in-memory append-only audit slice (tests / local tooling).
79
+ */
80
+ export function queryExplain(query, store) {
81
+ const matched = store.list().filter((e) => eventMatchesQuery(e, query));
82
+ const relatedEventIds = matched.map((e) => e.eventId);
83
+ const warnings = [];
84
+ let deliveryStatus;
85
+ for (const e of matched) {
86
+ if (e.family === "delivery") {
87
+ const st = deliveryStatusFrom(e.payload);
88
+ if (st)
89
+ deliveryStatus = st;
90
+ if (isNoUserVisibleDelivery(st)) {
91
+ warnings.push(NO_USER_VISIBLE);
92
+ }
93
+ }
94
+ }
95
+ const uniqueWarnings = [...new Set(warnings)];
96
+ const summary = matched.length === 0
97
+ ? "no_matching_audit_events"
98
+ : `matched_events=${matched.length};subject=${query.kind}`;
99
+ const events = matched.map((e) => ({
100
+ eventId: e.eventId,
101
+ family: e.family,
102
+ plane: e.plane,
103
+ createdAt: e.createdAt,
104
+ summary: summarizeEnvelope(e),
105
+ }));
106
+ return {
107
+ query,
108
+ summary,
109
+ warnings: uniqueWarnings,
110
+ deliveryStatus,
111
+ relatedEventIds,
112
+ events,
113
+ };
114
+ }
@@ -0,0 +1,22 @@
1
+ import type { AuditEnvelope } from "../audit/audit-envelope.js";
2
+ import type { AuditEventFamily } from "../audit/audit-envelope.js";
3
+ import type { AuditExportRange } from "../audit/verify-audit-hash-chain.js";
4
+ export interface AuditBundleExportRange extends AuditExportRange {
5
+ /** Reserved for otel_projection / future formats */
6
+ format?: "json_v1";
7
+ }
8
+ export interface AuditRedactionSummary {
9
+ eventCount: number;
10
+ manifestIds: string[];
11
+ }
12
+ export interface AuditBundle {
13
+ bundleId: string;
14
+ generatedAt: string;
15
+ range: AuditBundleExportRange;
16
+ events: readonly AuditEnvelope<unknown>[];
17
+ redactionSummary: AuditRedactionSummary;
18
+ }
19
+ export interface ExportAuditBundleDeps {
20
+ loadRange(from: string, to: string, families?: AuditEventFamily[]): Promise<readonly AuditEnvelope<unknown>[]>;
21
+ }
22
+ export declare function exportAuditBundle(range: AuditBundleExportRange, deps: ExportAuditBundleDeps): Promise<AuditBundle>;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Redacted audit export bundle for operator / retention tooling (T5.3.1).
3
+ *
4
+ * Core logic: load range, attach export metadata; payloads are already redacted at envelope build time.
5
+ *
6
+ * Dependencies: same range loader pattern as verifyAuditHashChain.
7
+ *
8
+ * Test coverage: tests/integration/observability/explain-query-export.test.ts
9
+ */
10
+ import * as crypto from "node:crypto";
11
+ function summarize(events) {
12
+ const ids = new Set();
13
+ for (const e of events) {
14
+ ids.add(e.redaction.manifestId);
15
+ }
16
+ return { eventCount: events.length, manifestIds: [...ids] };
17
+ }
18
+ export async function exportAuditBundle(range, deps) {
19
+ const events = [...(await deps.loadRange(range.from, range.to, range.families))].sort((a, b) => a.sequence - b.sequence);
20
+ return {
21
+ bundleId: crypto.randomUUID(),
22
+ generatedAt: new Date().toISOString(),
23
+ range,
24
+ events,
25
+ redactionSummary: summarize(events),
26
+ };
27
+ }
@@ -26,7 +26,7 @@ export interface HeartbeatDecisionEvent {
26
26
  traceId: string;
27
27
  runtimeScope: "rhythm" | "user_task" | "user_reply";
28
28
  triggerSource: "heartbeat_bridge" | "user_task" | "user_reply" | "interrupt" | "resume";
29
- decisionStatus: "heartbeat_ok" | "intent_selected" | "denied" | "deferred";
29
+ decisionStatus: "heartbeat_ok" | "intent_selected" | "denied" | "deferred" | "runtime_carrier_only" | "delivery_unavailable";
30
30
  reasons: string[];
31
31
  intentId?: string;
32
32
  mode: "active" | "quiet" | "maintenance_only" | "paused_for_interrupt";
@@ -153,5 +153,9 @@ function mapHeartbeatStatusToVerdict(status) {
153
153
  return "defer";
154
154
  case "heartbeat_ok":
155
155
  return "defer";
156
+ case "runtime_carrier_only":
157
+ return "defer";
158
+ case "delivery_unavailable":
159
+ return "deny";
156
160
  }
157
161
  }
@@ -15,6 +15,20 @@ export declare class GovernanceAudit {
15
15
  private db;
16
16
  constructor(db: ObservabilityDatabase);
17
17
  recordAnchorChangeAudit(event: AnchorChangeAudit): Promise<void>;
18
+ /**
19
+ * Generic governance-plane events (T5.1.2): fallback_written, effect_commit_advanced, connector_failure, etc.
20
+ * traceId is stored on target_asset_id for explain/trace correlation until a dedicated column exists.
21
+ */
22
+ recordOperationalGovernanceEvent(input: {
23
+ id: string;
24
+ eventType: string;
25
+ traceId: string;
26
+ statusTo: string;
27
+ reason: string;
28
+ assetPath?: string;
29
+ supportingSources?: string[];
30
+ createdAt?: string;
31
+ }): Promise<void>;
18
32
  recordCredentialLifecycle(event: CredentialLifecycleAudit): Promise<void>;
19
33
  recordProposalApply(proposalId: string, targetAssetId: string, assetPath: string, beforeHash: string | undefined, afterHash: string | undefined, supportingSources: string[], reason: string): Promise<void>;
20
34
  recordProposalReject(proposalId: string, targetAssetId: string, assetPath: string, reason: string): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import { eq } from "drizzle-orm";
2
2
  import { governanceAudit } from "../db/schema/index.js";
3
- import { redactEvent } from "../redaction/manifest.js";
3
+ import { createEmptyManifest, redactEvent } from "../redaction/manifest.js";
4
4
  import { persistRedactionManifest } from "./redaction-store.js";
5
5
  export class GovernanceAudit {
6
6
  db;
@@ -27,6 +27,30 @@ export class GovernanceAudit {
27
27
  });
28
28
  await persistRedactionManifest(this.db, redacted.id, "anchor.change", manifest);
29
29
  }
30
+ /**
31
+ * Generic governance-plane events (T5.1.2): fallback_written, effect_commit_advanced, connector_failure, etc.
32
+ * traceId is stored on target_asset_id for explain/trace correlation until a dedicated column exists.
33
+ */
34
+ async recordOperationalGovernanceEvent(input) {
35
+ const createdAt = input.createdAt ?? new Date().toISOString();
36
+ await this.db.db.insert(governanceAudit).values({
37
+ id: input.id,
38
+ eventType: input.eventType,
39
+ proposalId: null,
40
+ targetAssetId: input.traceId,
41
+ assetPath: input.assetPath ?? null,
42
+ statusFrom: null,
43
+ statusTo: input.statusTo,
44
+ beforeHash: null,
45
+ afterHash: null,
46
+ supportingSources: JSON.stringify(input.supportingSources ?? []),
47
+ reason: input.reason,
48
+ verificationDeadline: null,
49
+ attemptsRemaining: null,
50
+ createdAt,
51
+ });
52
+ await persistRedactionManifest(this.db, input.id, input.eventType, createEmptyManifest());
53
+ }
30
54
  async recordCredentialLifecycle(event) {
31
55
  const { redacted, manifest } = redactEvent(event);
32
56
  await this.db.db.insert(governanceAudit).values({
@@ -0,0 +1,47 @@
1
+ /**
2
+ * T5.1.2 governance plane: connector attempts + state governance audit append ports.
3
+ *
4
+ * Core logic: connector attempts map to executionAttempts telemetry; governance kinds map to
5
+ * governance_audit rows with traceId on target_asset_id for explain correlation.
6
+ *
7
+ * Test coverage: tests/unit/observability/governance-plane-recorder.test.ts
8
+ */
9
+ import type { ObservabilityDatabase } from "../db/index.js";
10
+ import { ExecutionTelemetry } from "./execution-telemetry.js";
11
+ import { GovernanceAudit } from "./governance-audit.js";
12
+ export interface AuditAppendAck {
13
+ recordId: string;
14
+ appendedAt: string;
15
+ }
16
+ export type ConnectorAttemptOutcome = "started" | "succeeded" | "failed" | "sampled_telemetry";
17
+ export interface ConnectorAttemptAudit {
18
+ traceId: string;
19
+ decisionId: string;
20
+ intentId: string;
21
+ platformId: string;
22
+ capability: string;
23
+ channel: string;
24
+ outcome: ConnectorAttemptOutcome;
25
+ failureClass?: string;
26
+ idempotencyKey?: string;
27
+ metadata?: Record<string, unknown>;
28
+ }
29
+ export type StateGovernanceKind = "fallback_written" | "effect_commit_advanced" | "connector_failure" | "anchor_proposal_received";
30
+ export interface StateGovernanceAudit {
31
+ id: string;
32
+ traceId: string;
33
+ kind: StateGovernanceKind;
34
+ reason: string;
35
+ decisionId?: string;
36
+ artifactPath?: string;
37
+ supportingSources?: string[];
38
+ createdAt?: string;
39
+ }
40
+ export declare class GovernancePlaneRecorder {
41
+ private readonly telemetry;
42
+ private readonly governance;
43
+ constructor(telemetry: ExecutionTelemetry, governance: GovernanceAudit);
44
+ recordConnectorAttempt(audit: ConnectorAttemptAudit): Promise<AuditAppendAck>;
45
+ recordStateGovernance(event: StateGovernanceAudit): Promise<AuditAppendAck>;
46
+ }
47
+ export declare function createGovernancePlaneRecorder(db: ObservabilityDatabase): GovernancePlaneRecorder;
@@ -0,0 +1,55 @@
1
+ import { ExecutionTelemetry } from "./execution-telemetry.js";
2
+ import { GovernanceAudit } from "./governance-audit.js";
3
+ export class GovernancePlaneRecorder {
4
+ telemetry;
5
+ governance;
6
+ constructor(telemetry, governance) {
7
+ this.telemetry = telemetry;
8
+ this.governance = governance;
9
+ }
10
+ async recordConnectorAttempt(audit) {
11
+ const id = `ca-${audit.traceId}-${Date.now()}`;
12
+ const status = audit.outcome === "failed" ? "failed" : audit.outcome === "started" ? "started" : "succeeded";
13
+ const now = new Date().toISOString();
14
+ const attempt = {
15
+ id,
16
+ traceId: audit.traceId,
17
+ decisionId: audit.decisionId,
18
+ intentId: audit.intentId,
19
+ platformId: audit.platformId,
20
+ capability: audit.capability,
21
+ channel: audit.channel,
22
+ status,
23
+ failureClass: audit.failureClass,
24
+ idempotencyKey: audit.idempotencyKey,
25
+ metadata: {
26
+ ...(audit.metadata ?? {}),
27
+ ...(audit.outcome === "sampled_telemetry" ? { sampledTelemetry: true } : {}),
28
+ },
29
+ startedAt: now,
30
+ finishedAt: status === "started" ? undefined : now,
31
+ };
32
+ await this.telemetry.recordExecutionAttempt(attempt);
33
+ return { recordId: id, appendedAt: attempt.finishedAt ?? attempt.startedAt ?? now };
34
+ }
35
+ async recordStateGovernance(event) {
36
+ const createdAt = event.createdAt ?? new Date().toISOString();
37
+ const reason = event.decisionId !== undefined && event.decisionId.length > 0
38
+ ? `${event.reason} decisionId=${event.decisionId}`
39
+ : event.reason;
40
+ await this.governance.recordOperationalGovernanceEvent({
41
+ id: event.id,
42
+ eventType: event.kind,
43
+ traceId: event.traceId,
44
+ statusTo: "recorded",
45
+ reason,
46
+ assetPath: event.artifactPath,
47
+ supportingSources: event.supportingSources,
48
+ createdAt,
49
+ });
50
+ return { recordId: event.id, appendedAt: createdAt };
51
+ }
52
+ }
53
+ export function createGovernancePlaneRecorder(db) {
54
+ return new GovernancePlaneRecorder(new ExecutionTelemetry(db), new GovernanceAudit(db));
55
+ }