@miadi/episodic-memory-schema 0.6.0 → 0.6.2

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.
@@ -15,20 +15,52 @@ export interface EpisodeIdentityCandidate {
15
15
  kind: "episode-number" | "slug" | "title" | "path";
16
16
  value: string;
17
17
  }
18
- export type ArtifactKind = "audio" | "transcript" | "image" | "text" | "midi" | "video" | "other";
18
+ /**
19
+ * The kinds, as a value rather than only as a type.
20
+ *
21
+ * A TypeScript union vanishes at compile time. The device side of this contract
22
+ * — `gmtermux`'s recorder — is plain JavaScript, so a union it cannot import is
23
+ * a contract it cannot check: a misspelled `"capture"` reaches the manifest and
24
+ * is indistinguishable from an absence. Every axis below is therefore published
25
+ * as a frozen array with its type derived FROM the array, so the value and the
26
+ * type cannot drift apart the way two hand-kept copies would.
27
+ */
28
+ export declare const ARTIFACT_KINDS: readonly ["audio", "transcript", "image", "text", "midi", "video", "other"];
29
+ export type ArtifactKind = (typeof ARTIFACT_KINDS)[number];
30
+ /** Narrows an unvalidated string to {@link ArtifactKind}. */
31
+ export declare function isArtifactKind(value: unknown): value is ArtifactKind;
19
32
  /**
20
33
  * How an artifact came to exist — the axis that says what you must never lose.
21
34
  *
22
35
  * `captured` is unrepeatable: a device, an instant, one chance. A take that is
23
36
  * deleted is gone, because the moment it recorded will not happen twice.
24
37
  * `derived` is regenerable from something else that is still held — a
25
- * transcript, a rendered mix, a thumbnail. `authored` was written elsewhere by
26
- * someone, then brought in: a downloaded deep-search markdown, an imported doc.
38
+ * transcript, a rendered mix, a thumbnail. `authored` was WRITTEN rather than
39
+ * captured or generated — composed here by a person or an agent, or written
40
+ * elsewhere and brought in: an `.abc` melody, a downloaded deep-search markdown,
41
+ * an imported doc.
42
+ *
43
+ * The "brought in" half used to be the whole definition, and that was too narrow
44
+ * in the direction that mattered most. Composing a melody in this repository
45
+ * produces a file that is not `captured` (no device, no instant) and not
46
+ * `derived` (made from no other artifact) — so under the old wording the very
47
+ * thing this platform exists to make had no origin it could honestly claim.
48
+ * Found 2026-07-31 by writing one.
27
49
  *
28
50
  * Flattening these three loses the only property that distinguishes an
29
51
  * irreplaceable recording from a file that can be rebuilt on demand.
30
52
  */
31
- export type ArtifactOrigin = "captured" | "derived" | "authored";
53
+ export declare const ARTIFACT_ORIGINS: readonly ["captured", "derived", "authored"];
54
+ export type ArtifactOrigin = (typeof ARTIFACT_ORIGINS)[number];
55
+ /**
56
+ * Narrows an unvalidated string to {@link ArtifactOrigin}.
57
+ *
58
+ * This is the guard that matters most: `origin` is the only field saying what
59
+ * must never be lost, and a value that fails this check must be treated as
60
+ * unknown — never defaulted to `"derived"`, which would mark an unrepeatable
61
+ * take as regenerable.
62
+ */
63
+ export declare function isArtifactOrigin(value: unknown): value is ArtifactOrigin;
32
64
  /**
33
65
  * What a capture records about itself, per `gmtermux/rispecs/recording.spec.md`:
34
66
  * "the filename, the instants it started and stopped, its duration in seconds,
@@ -54,6 +86,39 @@ export interface CaptureProvenance {
54
86
  /** Size of the finished file in bytes. */
55
87
  bytes?: number;
56
88
  }
89
+ /**
90
+ * What may be rebuilt, and what may never be.
91
+ *
92
+ * THREE states, never a boolean, and the third one is the point. `unknown` is
93
+ * what an artifact with no recorded `origin` must report — the *provenance
94
+ * incomplete* state. A boolean forces that case into one bucket or the other,
95
+ * and whichever way it falls it lies: `false` refuses to clean up things that
96
+ * are fine, and `true` marks an unrepeatable take as safe to delete. Absence of
97
+ * evidence is its own answer here and has to survive being read.
98
+ */
99
+ export declare const ARTIFACT_REPLACEABILITY: readonly ["irreplaceable", "regenerable", "unknown"];
100
+ export type ArtifactReplaceability = (typeof ARTIFACT_REPLACEABILITY)[number];
101
+ /**
102
+ * Whether one leaf may be rebuilt. Pure and local — it reads the artifact it is
103
+ * given and performs no walk; a SET's answer is computed by walking members and
104
+ * `sourceArtifact` edges, and any member reporting `unknown` makes the whole set
105
+ * `unknown` rather than the optimistic answer.
106
+ *
107
+ * - `captured` is irreplaceable, always. A device, an instant, one chance.
108
+ * - `authored` is irreplaceable UNLESS it names a `sourceArtifact` — an authored
109
+ * file that was brought in from something still held can be brought in again;
110
+ * one composed here cannot.
111
+ * - `derived` is regenerable, which is the whole meaning of the word.
112
+ * - Absent origin is `unknown`. Never guess it from the file extension.
113
+ *
114
+ * Written 2026-07-31 after composing a melody exposed the hole. The rule this
115
+ * platform had adopted — "a set is unrepeatable exactly when it transitively
116
+ * contains a `captured` leaf" — walks a melody folder, finds an `.abc` and its
117
+ * renders, counts zero captured leaves, and reports the set safe to regenerate.
118
+ * The `.abc` is the only thing in it that cannot be remade. The rule was right
119
+ * about recordings and exactly wrong about the composed work this exists for.
120
+ */
121
+ export declare function artifactReplaceability(artifact: Pick<ArtifactReference, "origin" | "sourceArtifact">): ArtifactReplaceability;
57
122
  export interface ArtifactReference {
58
123
  id: string;
59
124
  kind: ArtifactKind;
@@ -89,7 +154,10 @@ export interface ArtifactReference {
89
154
  * classified — an absence, not an error — and `other` is a set whose source
90
155
  * named a kind this list does not carry yet.
91
156
  */
92
- export type ArtifactSetKind = "inquiry" | "composition" | "episode" | "melody" | "film" | "other";
157
+ export declare const ARTIFACT_SET_KINDS: readonly ["inquiry", "composition", "episode", "melody", "film", "other"];
158
+ export type ArtifactSetKind = (typeof ARTIFACT_SET_KINDS)[number];
159
+ /** Narrows an unvalidated string to {@link ArtifactSetKind}. */
160
+ export declare function isArtifactSetKind(value: unknown): value is ArtifactSetKind;
93
161
  /**
94
162
  * A directory that gathers artifacts and carries its own identity.
95
163
  *
@@ -136,14 +204,20 @@ export interface EpisodeRelation {
136
204
  * Membership direction. Both are carried because a source document states one
137
205
  * or the other, and observation does not invent the inverse it did not read.
138
206
  */
139
- export type ArtifactRelationKind = "member-of" | "gathers";
207
+ export declare const ARTIFACT_RELATION_KINDS: readonly ["member-of", "gathers"];
208
+ export type ArtifactRelationKind = (typeof ARTIFACT_RELATION_KINDS)[number];
209
+ /** Narrows an unvalidated string to {@link ArtifactRelationKind}. */
210
+ export declare function isArtifactRelationKind(value: unknown): value is ArtifactRelationKind;
140
211
  /**
141
212
  * What can sit on the container end of a membership edge. Composition, Episode,
142
213
  * Melody and Film are named at the same level because they are peers under one
143
214
  * root; `artifact-set` covers a gathering whose kind is unclassified, and
144
215
  * `artifact` lets a set be a member of another set.
145
216
  */
146
- export type ArtifactRelationTargetKind = "episode" | "composition" | "melody" | "film" | "artifact-set" | "artifact";
217
+ export declare const ARTIFACT_RELATION_TARGET_KINDS: readonly ["episode", "composition", "melody", "film", "artifact-set", "artifact"];
218
+ export type ArtifactRelationTargetKind = (typeof ARTIFACT_RELATION_TARGET_KINDS)[number];
219
+ /** Narrows an unvalidated string to {@link ArtifactRelationTargetKind}. */
220
+ export declare function isArtifactRelationTargetKind(value: unknown): value is ArtifactRelationTargetKind;
147
221
  /**
148
222
  * The other end of a membership edge.
149
223
  *
@@ -1 +1 @@
1
- {"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,iBAAiB,GACzB,oBAAoB,GACpB,WAAW,GACX,oBAAoB,CAAA;AAExB,MAAM,MAAM,mBAAmB,GAC3B,kBAAkB,GAClB,cAAc,GACd,oBAAoB,GACpB,iBAAiB,CAAA;AAErB,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,mBAAmB,CAAA;IAC3B,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,gBAAgB,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;IAClD,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,YAAY,GACZ,OAAO,GACP,MAAM,GACN,MAAM,GACN,OAAO,GACP,OAAO,CAAA;AAEX;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAA;AAEhE;;;;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AE,iBAAiB,CAAA;IACvB,eAAe,EAAE,iBAAiB,EAAE,CAAA;IACpC,kBAAkB,EAAE,wBAAwB,EAAE,CAAA;IAC9C,cAAc,EAAE,qBAAqB,CAAA;IACrC,SAAS,EAAE,iBAAiB,EAAE,CAAA;IAC9B,SAAS,EAAE,eAAe,EAAE,CAAA;IAC5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,WAAW,EAAE,CAAA;IAC5B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAA;IACtC,WAAW,EAAE,uBAAuB,EAAE,CAAA;IACtC,0DAA0D;IAC1D,OAAO,CAAC,EAAE,0BAA0B,CAAA;IACpC,wEAAwE;IACxE,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACxC;AAED,MAAM,WAAW,iCAAiC;IAChD,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,oBAAoB,CAAA;CAC5B;AAED,MAAM,WAAW,iCAAiC;IAChD,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,WAAW,CAAA;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,SAAS,CAAC,MAAM,GAAG,qBAAqB,CAAC,EAAE,CAAA;CACrD;AAED,MAAM,WAAW,8BAA8B;IAC7C,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,WAAW,CAAA;CACnB"}
@@ -5,5 +5,156 @@
5
5
  * authored EpisodicMemory schema. Consumers can inspect the diagnostics and
6
6
  * decide whether a later, explicit projection is appropriate.
7
7
  */
8
- export {};
8
+ /**
9
+ * The kinds, as a value rather than only as a type.
10
+ *
11
+ * A TypeScript union vanishes at compile time. The device side of this contract
12
+ * — `gmtermux`'s recorder — is plain JavaScript, so a union it cannot import is
13
+ * a contract it cannot check: a misspelled `"capture"` reaches the manifest and
14
+ * is indistinguishable from an absence. Every axis below is therefore published
15
+ * as a frozen array with its type derived FROM the array, so the value and the
16
+ * type cannot drift apart the way two hand-kept copies would.
17
+ */
18
+ export const ARTIFACT_KINDS = Object.freeze([
19
+ "audio",
20
+ "transcript",
21
+ "image",
22
+ "text",
23
+ "midi",
24
+ "video",
25
+ "other",
26
+ ]);
27
+ /** Narrows an unvalidated string to {@link ArtifactKind}. */
28
+ export function isArtifactKind(value) {
29
+ return typeof value === "string" && ARTIFACT_KINDS.includes(value);
30
+ }
31
+ /**
32
+ * How an artifact came to exist — the axis that says what you must never lose.
33
+ *
34
+ * `captured` is unrepeatable: a device, an instant, one chance. A take that is
35
+ * deleted is gone, because the moment it recorded will not happen twice.
36
+ * `derived` is regenerable from something else that is still held — a
37
+ * transcript, a rendered mix, a thumbnail. `authored` was WRITTEN rather than
38
+ * captured or generated — composed here by a person or an agent, or written
39
+ * elsewhere and brought in: an `.abc` melody, a downloaded deep-search markdown,
40
+ * an imported doc.
41
+ *
42
+ * The "brought in" half used to be the whole definition, and that was too narrow
43
+ * in the direction that mattered most. Composing a melody in this repository
44
+ * produces a file that is not `captured` (no device, no instant) and not
45
+ * `derived` (made from no other artifact) — so under the old wording the very
46
+ * thing this platform exists to make had no origin it could honestly claim.
47
+ * Found 2026-07-31 by writing one.
48
+ *
49
+ * Flattening these three loses the only property that distinguishes an
50
+ * irreplaceable recording from a file that can be rebuilt on demand.
51
+ */
52
+ export const ARTIFACT_ORIGINS = Object.freeze(["captured", "derived", "authored"]);
53
+ /**
54
+ * Narrows an unvalidated string to {@link ArtifactOrigin}.
55
+ *
56
+ * This is the guard that matters most: `origin` is the only field saying what
57
+ * must never be lost, and a value that fails this check must be treated as
58
+ * unknown — never defaulted to `"derived"`, which would mark an unrepeatable
59
+ * take as regenerable.
60
+ */
61
+ export function isArtifactOrigin(value) {
62
+ return typeof value === "string" && ARTIFACT_ORIGINS.includes(value);
63
+ }
64
+ /**
65
+ * What may be rebuilt, and what may never be.
66
+ *
67
+ * THREE states, never a boolean, and the third one is the point. `unknown` is
68
+ * what an artifact with no recorded `origin` must report — the *provenance
69
+ * incomplete* state. A boolean forces that case into one bucket or the other,
70
+ * and whichever way it falls it lies: `false` refuses to clean up things that
71
+ * are fine, and `true` marks an unrepeatable take as safe to delete. Absence of
72
+ * evidence is its own answer here and has to survive being read.
73
+ */
74
+ export const ARTIFACT_REPLACEABILITY = Object.freeze([
75
+ "irreplaceable",
76
+ "regenerable",
77
+ "unknown",
78
+ ]);
79
+ /**
80
+ * Whether one leaf may be rebuilt. Pure and local — it reads the artifact it is
81
+ * given and performs no walk; a SET's answer is computed by walking members and
82
+ * `sourceArtifact` edges, and any member reporting `unknown` makes the whole set
83
+ * `unknown` rather than the optimistic answer.
84
+ *
85
+ * - `captured` is irreplaceable, always. A device, an instant, one chance.
86
+ * - `authored` is irreplaceable UNLESS it names a `sourceArtifact` — an authored
87
+ * file that was brought in from something still held can be brought in again;
88
+ * one composed here cannot.
89
+ * - `derived` is regenerable, which is the whole meaning of the word.
90
+ * - Absent origin is `unknown`. Never guess it from the file extension.
91
+ *
92
+ * Written 2026-07-31 after composing a melody exposed the hole. The rule this
93
+ * platform had adopted — "a set is unrepeatable exactly when it transitively
94
+ * contains a `captured` leaf" — walks a melody folder, finds an `.abc` and its
95
+ * renders, counts zero captured leaves, and reports the set safe to regenerate.
96
+ * The `.abc` is the only thing in it that cannot be remade. The rule was right
97
+ * about recordings and exactly wrong about the composed work this exists for.
98
+ */
99
+ export function artifactReplaceability(artifact) {
100
+ switch (artifact.origin) {
101
+ case "captured":
102
+ return "irreplaceable";
103
+ case "derived":
104
+ return "regenerable";
105
+ case "authored":
106
+ return artifact.sourceArtifact ? "regenerable" : "irreplaceable";
107
+ default:
108
+ return "unknown";
109
+ }
110
+ }
111
+ /**
112
+ * What a set gathers.
113
+ *
114
+ * Composition, Episode, Melody and Film are siblings at the same level — none is
115
+ * an extension of another, and none is a special case of a recording. `inquiry`
116
+ * is the IAIP folder. Absent means the gathering was observed without being
117
+ * classified — an absence, not an error — and `other` is a set whose source
118
+ * named a kind this list does not carry yet.
119
+ */
120
+ export const ARTIFACT_SET_KINDS = Object.freeze([
121
+ "inquiry",
122
+ "composition",
123
+ "episode",
124
+ "melody",
125
+ "film",
126
+ "other",
127
+ ]);
128
+ /** Narrows an unvalidated string to {@link ArtifactSetKind}. */
129
+ export function isArtifactSetKind(value) {
130
+ return typeof value === "string" && ARTIFACT_SET_KINDS.includes(value);
131
+ }
132
+ /**
133
+ * Membership direction. Both are carried because a source document states one
134
+ * or the other, and observation does not invent the inverse it did not read.
135
+ */
136
+ export const ARTIFACT_RELATION_KINDS = Object.freeze(["member-of", "gathers"]);
137
+ /** Narrows an unvalidated string to {@link ArtifactRelationKind}. */
138
+ export function isArtifactRelationKind(value) {
139
+ return typeof value === "string" && ARTIFACT_RELATION_KINDS.includes(value);
140
+ }
141
+ /**
142
+ * What can sit on the container end of a membership edge. Composition, Episode,
143
+ * Melody and Film are named at the same level because they are peers under one
144
+ * root; `artifact-set` covers a gathering whose kind is unclassified, and
145
+ * `artifact` lets a set be a member of another set.
146
+ */
147
+ export const ARTIFACT_RELATION_TARGET_KINDS = Object.freeze([
148
+ "episode",
149
+ "composition",
150
+ "melody",
151
+ "film",
152
+ "artifact-set",
153
+ "artifact",
154
+ ]);
155
+ /** Narrows an unvalidated string to {@link ArtifactRelationTargetKind}. */
156
+ export function isArtifactRelationTargetKind(value) {
157
+ return (typeof value === "string" &&
158
+ ARTIFACT_RELATION_TARGET_KINDS.includes(value));
159
+ }
9
160
  //# sourceMappingURL=observation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"observation.js","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
1
+ {"version":3,"file":"observation.js","sour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,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,SAAS;IACT,aAAa;IACb,SAAS;IACT,QAAQ;IACR,MAAM;IACN,OAAO;CACC,CAAC,CAAA;AAIX,gEAAgE;AAChE,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,kBAAwC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC/F,CAAC;AA+CD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,SAAS,CAAU,CAAC,CAAA;AAIvF,qEAAqE;AACrE,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,uBAA6C,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AACpG,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1D,SAAS;IACT,aAAa;IACb,QAAQ;IACR,MAAM;IACN,cAAc;IACd,UAAU;CACF,CAAC,CAAA;AAIX,2EAA2E;AAC3E,MAAM,UAAU,4BAA4B,CAC1C,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACxB,8BAAoD,CAAC,QAAQ,CAAC,KAAK,CAAC,CACtE,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miadi/episodic-memory-schema",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "TypeScript types and JSON Schema for episodic memory — the durable session-to-session memory layer in the Miadi orchestration kit. Narrative layer is NCP-aligned; provenance layer is W3C PROV-DM and OAIS-informed.",
5
5
  "keywords": [
6
6
  "miadi",