@qmilab/lodestar-core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +216 -0
  2. package/README.md +87 -0
  3. package/dist/index.d.ts +23 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +28 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/registry.d.ts +20 -0
  8. package/dist/registry.d.ts.map +1 -0
  9. package/dist/registry.js +57 -0
  10. package/dist/registry.js.map +1 -0
  11. package/dist/schemas/action.d.ts +378 -0
  12. package/dist/schemas/action.d.ts.map +1 -0
  13. package/dist/schemas/action.js +122 -0
  14. package/dist/schemas/action.js.map +1 -0
  15. package/dist/schemas/actor.d.ts +87 -0
  16. package/dist/schemas/actor.d.ts.map +1 -0
  17. package/dist/schemas/actor.js +48 -0
  18. package/dist/schemas/actor.js.map +1 -0
  19. package/dist/schemas/belief.d.ts +141 -0
  20. package/dist/schemas/belief.d.ts.map +1 -0
  21. package/dist/schemas/belief.js +107 -0
  22. package/dist/schemas/belief.js.map +1 -0
  23. package/dist/schemas/claim.d.ts +234 -0
  24. package/dist/schemas/claim.d.ts.map +1 -0
  25. package/dist/schemas/claim.js +88 -0
  26. package/dist/schemas/claim.js.map +1 -0
  27. package/dist/schemas/common.d.ts +73 -0
  28. package/dist/schemas/common.d.ts.map +1 -0
  29. package/dist/schemas/common.js +45 -0
  30. package/dist/schemas/common.js.map +1 -0
  31. package/dist/schemas/decision.d.ts +102 -0
  32. package/dist/schemas/decision.d.ts.map +1 -0
  33. package/dist/schemas/decision.js +37 -0
  34. package/dist/schemas/decision.js.map +1 -0
  35. package/dist/schemas/event.d.ts +171 -0
  36. package/dist/schemas/event.d.ts.map +1 -0
  37. package/dist/schemas/event.js +55 -0
  38. package/dist/schemas/event.js.map +1 -0
  39. package/dist/schemas/observation.d.ts +88 -0
  40. package/dist/schemas/observation.d.ts.map +1 -0
  41. package/dist/schemas/observation.js +39 -0
  42. package/dist/schemas/observation.js.map +1 -0
  43. package/dist/schemas/revision.d.ts +120 -0
  44. package/dist/schemas/revision.d.ts.map +1 -0
  45. package/dist/schemas/revision.js +72 -0
  46. package/dist/schemas/revision.js.map +1 -0
  47. package/package.json +54 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/schemas/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,6DAA2D,CAAA;AACzF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE3D;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;EAGyC,CAAA;AACzE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;EAIkC,CAAA;AAC9D,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEvD;;GAEG;AACH,eAAO,MAAM,eAAe,aAAwC,CAAA;AACpE,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEvD;;GAEG;AACH,eAAO,MAAM,cAAc,aAAyG,CAAA;AACpI,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AAErD;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;EAIvB,CAAA;AACF,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
@@ -0,0 +1,45 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Sensitivity of content. Affects retrieval, explanation generation,
4
+ * OTel export, and final reports.
5
+ *
6
+ * Sensitivity is a content attribute. It is NOT a lifecycle axis —
7
+ * truth/retrieval/security/freshness describe the *state* of a belief,
8
+ * sensitivity describes its *content*.
9
+ */
10
+ export const SensitivitySchema = z.enum(["public", "internal", "confidential", "secret"]);
11
+ /**
12
+ * Scope a claim, belief, memory, or action applies to. Hierarchical
13
+ * from broadest (global) to narrowest (session).
14
+ */
15
+ export const ResourceScopeSchema = z.object({
16
+ level: z.enum(["global", "organization", "user", "project", "repo", "session"]),
17
+ identifier: z.string().describe("identifier within the scope level, e.g. project_id"),
18
+ }).describe("Scope that bounds where a claim, belief, or memory applies");
19
+ /**
20
+ * Structured predicate for queryable claims and beliefs.
21
+ * Free-form for v0; refined in later versions as the planner matures.
22
+ */
23
+ export const PredicateSchema = z.object({
24
+ subject: z.string(),
25
+ relation: z.string(),
26
+ object: z.unknown(),
27
+ }).describe("Structured form of a claim suitable for queries");
28
+ /**
29
+ * ISO 8601 timestamp string.
30
+ */
31
+ export const TimestampSchema = z.string().datetime({ offset: true });
32
+ /**
33
+ * ISO 8601 duration string (e.g. "P30D", "PT1H").
34
+ */
35
+ export const DurationSchema = z.string().regex(/^P(?:\d+Y)?(?:\d+M)?(?:\d+W)?(?:\d+D)?(?:T(?:\d+H)?(?:\d+M)?(?:\d+(?:\.\d+)?S)?)?$/);
36
+ /**
37
+ * Generic Source reference used in evidence and explanations.
38
+ * Points to an observation, belief, or external identifier.
39
+ */
40
+ export const SourceSchema = z.object({
41
+ type: z.enum(["observation", "belief", "claim", "memory", "skill", "external"]),
42
+ id: z.string(),
43
+ uri: z.string().optional().describe("optional external URI, for type=external"),
44
+ });
45
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/schemas/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB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Q,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;CAChF,CAAC,CAAA"}
@@ -0,0 +1,102 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * One option in a decision.
4
+ */
5
+ export declare const DecisionOptionSchema: z.ZodObject<{
6
+ id: z.ZodString;
7
+ description: z.ZodString;
8
+ expected_outcome: z.ZodOptional<z.ZodString>;
9
+ estimated_cost: z.ZodOptional<z.ZodString>;
10
+ estimated_risk: z.ZodOptional<z.ZodString>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ id: string;
13
+ description: string;
14
+ expected_outcome?: string | undefined;
15
+ estimated_cost?: string | undefined;
16
+ estimated_risk?: string | undefined;
17
+ }, {
18
+ id: string;
19
+ description: string;
20
+ expected_outcome?: string | undefined;
21
+ estimated_cost?: string | undefined;
22
+ estimated_risk?: string | undefined;
23
+ }>;
24
+ export type DecisionOption = z.infer<typeof DecisionOptionSchema>;
25
+ /**
26
+ * A choice among options, justified by beliefs.
27
+ *
28
+ * Decisions sit between Belief and Action in the epistemic chain.
29
+ * Every Decision records its belief_dependencies — the policy can
30
+ * reject Decisions that lack supporting beliefs (governed by
31
+ * ContextPolicy.require_evidence_for_decisions).
32
+ *
33
+ * The rationale_id points to an Explanation generated alongside
34
+ * the decision. This is how the system stays auditable: every
35
+ * decision has a stored reasoning trail, not just a regenerable one.
36
+ */
37
+ export declare const DecisionSchema: z.ZodObject<{
38
+ id: z.ZodString;
39
+ question: z.ZodString;
40
+ options: z.ZodArray<z.ZodObject<{
41
+ id: z.ZodString;
42
+ description: z.ZodString;
43
+ expected_outcome: z.ZodOptional<z.ZodString>;
44
+ estimated_cost: z.ZodOptional<z.ZodString>;
45
+ estimated_risk: z.ZodOptional<z.ZodString>;
46
+ }, "strip", z.ZodTypeAny, {
47
+ id: string;
48
+ description: string;
49
+ expected_outcome?: string | undefined;
50
+ estimated_cost?: string | undefined;
51
+ estimated_risk?: string | undefined;
52
+ }, {
53
+ id: string;
54
+ description: string;
55
+ expected_outcome?: string | undefined;
56
+ estimated_cost?: string | undefined;
57
+ estimated_risk?: string | undefined;
58
+ }>, "many">;
59
+ selected_option_id: z.ZodString;
60
+ rationale_id: z.ZodString;
61
+ belief_dependencies: z.ZodArray<z.ZodString, "many">;
62
+ policy_dependencies: z.ZodArray<z.ZodString, "many">;
63
+ outcome_id: z.ZodOptional<z.ZodString>;
64
+ made_by: z.ZodString;
65
+ made_at: z.ZodString;
66
+ }, "strip", z.ZodTypeAny, {
67
+ options: {
68
+ id: string;
69
+ description: string;
70
+ expected_outcome?: string | undefined;
71
+ estimated_cost?: string | undefined;
72
+ estimated_risk?: string | undefined;
73
+ }[];
74
+ id: string;
75
+ question: string;
76
+ selected_option_id: string;
77
+ rationale_id: string;
78
+ belief_dependencies: string[];
79
+ policy_dependencies: string[];
80
+ made_by: string;
81
+ made_at: string;
82
+ outcome_id?: string | undefined;
83
+ }, {
84
+ options: {
85
+ id: string;
86
+ description: string;
87
+ expected_outcome?: string | undefined;
88
+ estimated_cost?: string | undefined;
89
+ estimated_risk?: string | undefined;
90
+ }[];
91
+ id: string;
92
+ question: string;
93
+ selected_option_id: string;
94
+ rationale_id: string;
95
+ belief_dependencies: string[];
96
+ policy_dependencies: string[];
97
+ made_by: string;
98
+ made_at: string;
99
+ outcome_id?: string | undefined;
100
+ }>;
101
+ export type Decision = z.infer<typeof DecisionSchema>;
102
+ //# sourceMappingURL=decision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../../src/schemas/decision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;EAM/B,CAAA;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWzB,CAAA;AACF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA"}
@@ -0,0 +1,37 @@
1
+ import { z } from "zod";
2
+ import { TimestampSchema } from "./common";
3
+ /**
4
+ * One option in a decision.
5
+ */
6
+ export const DecisionOptionSchema = z.object({
7
+ id: z.string(),
8
+ description: z.string(),
9
+ expected_outcome: z.string().optional(),
10
+ estimated_cost: z.string().optional().describe("free-form for v0; e.g. 'low', 'medium', 'high'"),
11
+ estimated_risk: z.string().optional(),
12
+ });
13
+ /**
14
+ * A choice among options, justified by beliefs.
15
+ *
16
+ * Decisions sit between Belief and Action in the epistemic chain.
17
+ * Every Decision records its belief_dependencies — the policy can
18
+ * reject Decisions that lack supporting beliefs (governed by
19
+ * ContextPolicy.require_evidence_for_decisions).
20
+ *
21
+ * The rationale_id points to an Explanation generated alongside
22
+ * the decision. This is how the system stays auditable: every
23
+ * decision has a stored reasoning trail, not just a regenerable one.
24
+ */
25
+ export const DecisionSchema = z.object({
26
+ id: z.string(),
27
+ question: z.string().describe("human-readable question this decision answers"),
28
+ options: z.array(DecisionOptionSchema).min(1),
29
+ selected_option_id: z.string(),
30
+ rationale_id: z.string().describe("Explanation id"),
31
+ belief_dependencies: z.array(z.string()).describe("belief_ids consulted"),
32
+ policy_dependencies: z.array(z.string()).describe("policy versions consulted"),
33
+ outcome_id: z.string().optional().describe("populated after Action completes"),
34
+ made_by: z.string().describe("actor_id"),
35
+ made_at: TimestampSchema,
36
+ });
37
+ //# sourceMappingURL=decision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision.js","sourceRoot":"","sources":["../../src/schemas/decision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C;;GAEG;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0,0 +1,171 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Version metadata attached to every event.
4
+ *
5
+ * Replay-grade events need to know which model, prompt, tool version,
6
+ * skill version, policy version, and memory snapshot were in effect
7
+ * when the event was produced. Without this, replays cannot reproduce
8
+ * the original conditions.
9
+ */
10
+ export declare const EventVersionsSchema: z.ZodObject<{
11
+ model: z.ZodOptional<z.ZodString>;
12
+ prompt_hash: z.ZodOptional<z.ZodString>;
13
+ tool_version: z.ZodOptional<z.ZodString>;
14
+ skill_hash: z.ZodOptional<z.ZodString>;
15
+ policy_version: z.ZodOptional<z.ZodString>;
16
+ memory_snapshot_id: z.ZodOptional<z.ZodString>;
17
+ schema_registry_version: z.ZodOptional<z.ZodString>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ model?: string | undefined;
20
+ prompt_hash?: string | undefined;
21
+ tool_version?: string | undefined;
22
+ skill_hash?: string | undefined;
23
+ policy_version?: string | undefined;
24
+ memory_snapshot_id?: string | undefined;
25
+ schema_registry_version?: string | undefined;
26
+ }, {
27
+ model?: string | undefined;
28
+ prompt_hash?: string | undefined;
29
+ tool_version?: string | undefined;
30
+ skill_hash?: string | undefined;
31
+ policy_version?: string | undefined;
32
+ memory_snapshot_id?: string | undefined;
33
+ schema_registry_version?: string | undefined;
34
+ }>;
35
+ export type EventVersions = z.infer<typeof EventVersionsSchema>;
36
+ /**
37
+ * The envelope every event in Lodestar is wrapped in.
38
+ *
39
+ * Append-only. NDJSON-friendly. Replay-grade.
40
+ *
41
+ * - `seq` is a monotonic per-partition sequence number; used for
42
+ * deterministic replay ordering.
43
+ * - `logical_clock` is a Lamport-style counter; used to reason about
44
+ * causality across actors within a session.
45
+ * - `causal_parent_ids` form a DAG that lets the harness reconstruct
46
+ * why an event happened.
47
+ * - `payload_hash` is sha-256 of the canonical payload; gives
48
+ * tamper-evidence without requiring per-event signatures.
49
+ * - `signature` is OPTIONAL in v0. Routine internal events rely on
50
+ * the hash + append-only log. Signatures are required only for
51
+ * skills, policy versions, external imports, and secret-signing
52
+ * events. Adding a signature field for every event is overkill in v0.
53
+ */
54
+ export declare const EventEnvelopeSchema: z.ZodObject<{
55
+ id: z.ZodString;
56
+ seq: z.ZodNumber;
57
+ type: z.ZodString;
58
+ schema_version: z.ZodString;
59
+ project_id: z.ZodString;
60
+ session_id: z.ZodString;
61
+ actor_id: z.ZodString;
62
+ timestamp: z.ZodString;
63
+ logical_clock: z.ZodNumber;
64
+ causal_parent_ids: z.ZodArray<z.ZodString, "many">;
65
+ payload_hash: z.ZodString;
66
+ payload: z.ZodUnknown;
67
+ versions: z.ZodObject<{
68
+ model: z.ZodOptional<z.ZodString>;
69
+ prompt_hash: z.ZodOptional<z.ZodString>;
70
+ tool_version: z.ZodOptional<z.ZodString>;
71
+ skill_hash: z.ZodOptional<z.ZodString>;
72
+ policy_version: z.ZodOptional<z.ZodString>;
73
+ memory_snapshot_id: z.ZodOptional<z.ZodString>;
74
+ schema_registry_version: z.ZodOptional<z.ZodString>;
75
+ }, "strip", z.ZodTypeAny, {
76
+ model?: string | undefined;
77
+ prompt_hash?: string | undefined;
78
+ tool_version?: string | undefined;
79
+ skill_hash?: string | undefined;
80
+ policy_version?: string | undefined;
81
+ memory_snapshot_id?: string | undefined;
82
+ schema_registry_version?: string | undefined;
83
+ }, {
84
+ model?: string | undefined;
85
+ prompt_hash?: string | undefined;
86
+ tool_version?: string | undefined;
87
+ skill_hash?: string | undefined;
88
+ policy_version?: string | undefined;
89
+ memory_snapshot_id?: string | undefined;
90
+ schema_registry_version?: string | undefined;
91
+ }>;
92
+ signature: z.ZodOptional<z.ZodObject<{
93
+ signer_id: z.ZodString;
94
+ payload_hash: z.ZodString;
95
+ algorithm: z.ZodLiteral<"ed25519">;
96
+ signature: z.ZodString;
97
+ at: z.ZodString;
98
+ }, "strip", z.ZodTypeAny, {
99
+ at: string;
100
+ signer_id: string;
101
+ payload_hash: string;
102
+ algorithm: "ed25519";
103
+ signature: string;
104
+ }, {
105
+ at: string;
106
+ signer_id: string;
107
+ payload_hash: string;
108
+ algorithm: "ed25519";
109
+ signature: string;
110
+ }>>;
111
+ }, "strip", z.ZodTypeAny, {
112
+ type: string;
113
+ id: string;
114
+ payload_hash: string;
115
+ session_id: string;
116
+ project_id: string;
117
+ actor_id: string;
118
+ seq: number;
119
+ schema_version: string;
120
+ timestamp: string;
121
+ logical_clock: number;
122
+ causal_parent_ids: string[];
123
+ versions: {
124
+ model?: string | undefined;
125
+ prompt_hash?: string | undefined;
126
+ tool_version?: string | undefined;
127
+ skill_hash?: string | undefined;
128
+ policy_version?: string | undefined;
129
+ memory_snapshot_id?: string | undefined;
130
+ schema_registry_version?: string | undefined;
131
+ };
132
+ signature?: {
133
+ at: string;
134
+ signer_id: string;
135
+ payload_hash: string;
136
+ algorithm: "ed25519";
137
+ signature: string;
138
+ } | undefined;
139
+ payload?: unknown;
140
+ }, {
141
+ type: string;
142
+ id: string;
143
+ payload_hash: string;
144
+ session_id: string;
145
+ project_id: string;
146
+ actor_id: string;
147
+ seq: number;
148
+ schema_version: string;
149
+ timestamp: string;
150
+ logical_clock: number;
151
+ causal_parent_ids: string[];
152
+ versions: {
153
+ model?: string | undefined;
154
+ prompt_hash?: string | undefined;
155
+ tool_version?: string | undefined;
156
+ skill_hash?: string | undefined;
157
+ policy_version?: string | undefined;
158
+ memory_snapshot_id?: string | undefined;
159
+ schema_registry_version?: string | undefined;
160
+ };
161
+ signature?: {
162
+ at: string;
163
+ signer_id: string;
164
+ payload_hash: string;
165
+ algorithm: "ed25519";
166
+ signature: string;
167
+ } | undefined;
168
+ payload?: unknown;
169
+ }>;
170
+ export type EventEnvelope = z.infer<typeof EventEnvelopeSchema>;
171
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/schemas/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;EAQ9B,CAAA;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAe9B,CAAA;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
@@ -0,0 +1,55 @@
1
+ import { z } from "zod";
2
+ import { SignatureSchema } from "./actor";
3
+ import { TimestampSchema } from "./common";
4
+ /**
5
+ * Version metadata attached to every event.
6
+ *
7
+ * Replay-grade events need to know which model, prompt, tool version,
8
+ * skill version, policy version, and memory snapshot were in effect
9
+ * when the event was produced. Without this, replays cannot reproduce
10
+ * the original conditions.
11
+ */
12
+ export const EventVersionsSchema = z.object({
13
+ model: z.string().optional().describe("e.g. 'claude-opus-4-7'"),
14
+ prompt_hash: z.string().optional(),
15
+ tool_version: z.string().optional(),
16
+ skill_hash: z.string().optional(),
17
+ policy_version: z.string().optional(),
18
+ memory_snapshot_id: z.string().optional(),
19
+ schema_registry_version: z.string().optional(),
20
+ });
21
+ /**
22
+ * The envelope every event in Lodestar is wrapped in.
23
+ *
24
+ * Append-only. NDJSON-friendly. Replay-grade.
25
+ *
26
+ * - `seq` is a monotonic per-partition sequence number; used for
27
+ * deterministic replay ordering.
28
+ * - `logical_clock` is a Lamport-style counter; used to reason about
29
+ * causality across actors within a session.
30
+ * - `causal_parent_ids` form a DAG that lets the harness reconstruct
31
+ * why an event happened.
32
+ * - `payload_hash` is sha-256 of the canonical payload; gives
33
+ * tamper-evidence without requiring per-event signatures.
34
+ * - `signature` is OPTIONAL in v0. Routine internal events rely on
35
+ * the hash + append-only log. Signatures are required only for
36
+ * skills, policy versions, external imports, and secret-signing
37
+ * events. Adding a signature field for every event is overkill in v0.
38
+ */
39
+ export const EventEnvelopeSchema = z.object({
40
+ id: z.string(),
41
+ seq: z.number().int().nonnegative(),
42
+ type: z.string().describe("e.g. 'action.approved', 'memory.promoted'"),
43
+ schema_version: z.string().describe("semver of this event type"),
44
+ project_id: z.string(),
45
+ session_id: z.string(),
46
+ actor_id: z.string(),
47
+ timestamp: TimestampSchema,
48
+ logical_clock: z.number().int().nonnegative(),
49
+ causal_parent_ids: z.array(z.string()),
50
+ payload_hash: z.string().describe("sha-256 hex"),
51
+ payload: z.unknown(),
52
+ versions: EventVersionsSchema,
53
+ signature: SignatureSchema.optional(),
54
+ });
55
+ //# sourceMappingURL=event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/schemas/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IAC/D,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACrC,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACzC,uBAAuB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/C,CAAC,CAAA;AAGF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACnC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IACtE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;IAChE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,SAAS,EAAE,eAAe;IAC1B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IAC7C,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACtC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC;IAChD,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,QAAQ,EAAE,mBAAmB;IAC7B,SAAS,EAAE,eAAe,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAA"}
@@ -0,0 +1,88 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Trust level of an observation's source.
4
+ *
5
+ * - "raw": just arrived from a tool, not yet validated by schema registry
6
+ * - "validated": validated against its registered schema, ready for cognition
7
+ * - "synthetic": produced by a probe; must not pollute real memory
8
+ */
9
+ export declare const ObservationTrustSchema: z.ZodEnum<["raw", "validated", "synthetic"]>;
10
+ export type ObservationTrust = z.infer<typeof ObservationTrustSchema>;
11
+ /**
12
+ * The first link in the epistemic chain.
13
+ *
14
+ * An Observation is a schema-typed structured input produced by a tool.
15
+ * Free-form strings from a tool are NOT observations until they have
16
+ * been validated against a registered schema.
17
+ *
18
+ * The `schema` field references the registry entry (e.g. "git.status@1").
19
+ * The kernel validates `payload` against that schema before this becomes
20
+ * a `validated` observation.
21
+ */
22
+ export declare const ObservationSchema: z.ZodObject<{
23
+ id: z.ZodString;
24
+ schema: z.ZodString;
25
+ payload: z.ZodUnknown;
26
+ source: z.ZodObject<{
27
+ tool: z.ZodString;
28
+ invocation_id: z.ZodString;
29
+ captured_at: z.ZodString;
30
+ }, "strip", z.ZodTypeAny, {
31
+ tool: string;
32
+ invocation_id: string;
33
+ captured_at: string;
34
+ }, {
35
+ tool: string;
36
+ invocation_id: string;
37
+ captured_at: string;
38
+ }>;
39
+ context: z.ZodObject<{
40
+ session_id: z.ZodString;
41
+ project_id: z.ZodString;
42
+ actor_id: z.ZodString;
43
+ }, "strip", z.ZodTypeAny, {
44
+ session_id: string;
45
+ project_id: string;
46
+ actor_id: string;
47
+ }, {
48
+ session_id: string;
49
+ project_id: string;
50
+ actor_id: string;
51
+ }>;
52
+ trust: z.ZodEnum<["raw", "validated", "synthetic"]>;
53
+ sensitivity: z.ZodEnum<["public", "internal", "confidential", "secret"]>;
54
+ }, "strip", z.ZodTypeAny, {
55
+ id: string;
56
+ schema: string;
57
+ source: {
58
+ tool: string;
59
+ invocation_id: string;
60
+ captured_at: string;
61
+ };
62
+ context: {
63
+ session_id: string;
64
+ project_id: string;
65
+ actor_id: string;
66
+ };
67
+ trust: "raw" | "validated" | "synthetic";
68
+ sensitivity: "public" | "internal" | "confidential" | "secret";
69
+ payload?: unknown;
70
+ }, {
71
+ id: string;
72
+ schema: string;
73
+ source: {
74
+ tool: string;
75
+ invocation_id: string;
76
+ captured_at: string;
77
+ };
78
+ context: {
79
+ session_id: string;
80
+ project_id: string;
81
+ actor_id: string;
82
+ };
83
+ trust: "raw" | "validated" | "synthetic";
84
+ sensitivity: "public" | "internal" | "confidential" | "secret";
85
+ payload?: unknown;
86
+ }>;
87
+ export type Observation = z.infer<typeof ObservationSchema>;
88
+ //# sourceMappingURL=observation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../../src/schemas/observation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,8CAA4C,CAAA;AAC/E,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAErE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgB5B,CAAA;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ import { SensitivitySchema, TimestampSchema } from "./common";
3
+ /**
4
+ * Trust level of an observation's source.
5
+ *
6
+ * - "raw": just arrived from a tool, not yet validated by schema registry
7
+ * - "validated": validated against its registered schema, ready for cognition
8
+ * - "synthetic": produced by a probe; must not pollute real memory
9
+ */
10
+ export const ObservationTrustSchema = z.enum(["raw", "validated", "synthetic"]);
11
+ /**
12
+ * The first link in the epistemic chain.
13
+ *
14
+ * An Observation is a schema-typed structured input produced by a tool.
15
+ * Free-form strings from a tool are NOT observations until they have
16
+ * been validated against a registered schema.
17
+ *
18
+ * The `schema` field references the registry entry (e.g. "git.status@1").
19
+ * The kernel validates `payload` against that schema before this becomes
20
+ * a `validated` observation.
21
+ */
22
+ export const ObservationSchema = z.object({
23
+ id: z.string(),
24
+ schema: z.string().describe("registry key, e.g. 'git.status@1'"),
25
+ payload: z.unknown(),
26
+ source: z.object({
27
+ tool: z.string(),
28
+ invocation_id: z.string(),
29
+ captured_at: TimestampSchema,
30
+ }),
31
+ context: z.object({
32
+ session_id: z.string(),
33
+ project_id: z.string(),
34
+ actor_id: z.string(),
35
+ }),
36
+ trust: ObservationTrustSchema,
37
+ sensitivity: SensitivitySchema,
38
+ });
39
+ //# sourceMappingURL=observation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observation.js","sourceRoot":"","sources":["../../src/schemas/observation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE7D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAA;AAG/E;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IAChE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;QACzB,WAAW,EAAE,eAAe;KAC7B,CAAC;IACF,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;QAChB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;QACtB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;QACtB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;KACrB,CAAC;IACF,KAAK,EAAE,sBAAsB;IAC7B,WAAW,EAAE,iBAAiB;CAC/B,CAAC,CAAA"}