@mossbear/protocol 0.1.0-alpha.52 → 0.1.0-alpha.54

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.
@@ -79,7 +79,7 @@ export declare function isReservedStatePath(candidate: string): boolean;
79
79
  * component), so a project item declaring one can never be delivered by
80
80
  * `git clone` or `git merge` — which is the only way a project item is supposed
81
81
  * to reach a working tree. The one thing left that could write it is
82
- * `mossbear accept`, and the write is not inert: git reads `.git/config` on the
82
+ * `mossbear promote`, and the write is not inert: git reads `.git/config` on the
83
83
  * next `git status` and runs whatever `core.fsmonitor`, `core.hooksPath` or
84
84
  * `core.pager` names, with no commit for anyone to review. A shared bundle is
85
85
  * writable by every member of its workspace and by any agent holding a
@@ -143,7 +143,7 @@ export function isReservedStatePath(candidate) {
143
143
  * component), so a project item declaring one can never be delivered by
144
144
  * `git clone` or `git merge` — which is the only way a project item is supposed
145
145
  * to reach a working tree. The one thing left that could write it is
146
- * `mossbear accept`, and the write is not inert: git reads `.git/config` on the
146
+ * `mossbear promote`, and the write is not inert: git reads `.git/config` on the
147
147
  * next `git status` and runs whatever `core.fsmonitor`, `core.hooksPath` or
148
148
  * `core.pager` names, with no commit for anyone to review. A shared bundle is
149
149
  * writable by every member of its workspace and by any agent holding a
@@ -1,14 +1,12 @@
1
1
  /**
2
2
  * The one table the context item-kind narrowings derive from.
3
3
  *
4
- * **Why this file exists.** `guide_files.content_type` is a free-text,
5
- * nullable column server-side, narrowed on the wire in three different
6
- * places — what an agent may *read* back
7
- * (`ContextItemTypeSchema`), what it may *push* (`PushContentTypeSchema`), what
8
- * it may *capture* into the inbox (`InboxContentTypeSchema`) — plus a lossy
9
- * `contentType → itemType` mapping and a hand-written SQL inverse of that
10
- * mapping in the items route. Each narrowing had a reason and none of them
11
- * derived from a shared source, so adding a fourth kind meant editing five
4
+ * **Why this file exists.** What an agent may *read* back
5
+ * (`ContextItemTypeSchema`), what it may *push* (`PushContentTypeSchema`) and
6
+ * what it may *capture* into the inbox (`InboxContentTypeSchema`) are three
7
+ * narrowings of the same question, plus a lossy kind → item-type mapping and a
8
+ * SQL inverse of it in the items route. Each narrowing had a reason and none of
9
+ * them derived from a shared source, so adding a fourth kind meant editing five
12
10
  * places and nothing failed if you missed one.
13
11
  *
14
12
  * Now one row per kind answers all of it declaratively. A new kind is a new row
@@ -16,131 +14,152 @@
16
14
  * silently omitted from a narrowing, because no narrowing has its own list any
17
15
  * more.
18
16
  *
19
- * **Strictly a re-derivation.** Every picklist below comes out equal to the
20
- * literal it replaced, values and order alike — `contextKinds.test.ts` pins each
21
- * one against a hand-written copy of today's values, so a row edit that would
22
- * change the wire fails there rather than in a client. Which kinds are pushable
23
- * and capturable are product decisions this table records; changing one is a
24
- * separate, deliberate change to that row.
17
+ * `contextKinds.test.ts` pins each derived picklist against a hand-written copy
18
+ * of today's values, so a row edit that would change the wire fails there rather
19
+ * than in a client. Which kinds are pushable and capturable are product
20
+ * decisions this table records; changing one is a separate, deliberate change to
21
+ * that row.
25
22
  */
26
23
  /**
27
- * The `content_type` values that are addressable as context items on the wire.
24
+ * The stored kinds that are addressable as context items on the wire.
28
25
  *
29
- * `contentType` doubles as the item's `type` in a response — for these kinds the
30
- * two are the same string, which is why there is no separate `itemType` column
31
- * here. Kinds *not* listed (`instructions`, `eval`, `script`, and a legacy NULL)
32
- * are still stored in the column; they collapse onto
26
+ * **Keyed on the `(role, format)` pair, and that is the load-bearing part.**
27
+ * A table keyed on `role` alone would quietly hand a
28
+ * **script** — `content` + `code` — both `pushable` and `capturable`, because
29
+ * nothing would separate it from a markdown document. It must not, and the pair
30
+ * is what stops it. This is the one place the two columns have to be read
31
+ * together; splitting a column does not by itself make every consumer
32
+ * single-column.
33
+ *
34
+ * Pairs *not* listed — `guidance`, `criteria`, `content` + `code`, and a row
35
+ * with no role at all — are still stored. They collapse onto
33
36
  * {@link DEFAULT_CONTEXT_ITEM_TYPE} when serialized, and
34
- * {@link contentTypeFilterForItemTypes} is what keeps SQL agreeing with that.
37
+ * {@link kindFilterForItemTypes} is what keeps SQL agreeing with that.
35
38
  *
36
39
  * Order is the wire order of the derived picklists and is load-bearing for the
37
40
  * pin test; append rather than reorder.
38
41
  */
39
42
  export declare const CONTEXT_CONTENT_KINDS: readonly [{
40
- readonly contentType: "document";
43
+ readonly itemType: "content";
44
+ readonly role: "content";
45
+ readonly format: "markdown";
41
46
  readonly pushable: true;
42
47
  readonly capturable: true;
43
48
  }, {
44
- readonly contentType: "reference";
45
- readonly pushable: true;
46
- readonly capturable: false;
47
- }, {
48
- readonly contentType: "asset";
49
+ readonly itemType: "asset";
50
+ readonly role: "content";
51
+ readonly format: "binary";
49
52
  readonly pushable: true;
50
53
  readonly capturable: true;
51
54
  }];
52
55
  /**
53
56
  * The item type of a `guides` row.
54
57
  *
55
- * A guide is not a `content_type` at all — it is a different table — which is
56
- * why it is named here rather than added to the table above. It is readable as
58
+ * A guide is not a stored `(role, format)` pair at all — it is a different
59
+ * table — which is why it is named here rather than added to the table above. It is readable as
57
60
  * an item and deliberately neither pushable nor capturable: `PushContentType`'s
58
61
  * doc comment on `PushContentTypeSchema` explains why a create cannot honor it.
59
62
  */
60
63
  export declare const GUIDE_ITEM_TYPE = "guide";
61
64
  /**
62
- * What an unlisted or NULL `content_type` serializes as.
65
+ * What an unlisted pair serializes as.
63
66
  *
64
67
  * The default arm exists so a stray row — one written before a kind was
65
68
  * retired, or by a non-context surface — produces a schema-valid response
66
69
  * instead of failing the read. It is what makes the mapping lossy, and so what
67
- * forces {@link contentTypeFilterForItemTypes} to exist.
70
+ * forces {@link kindFilterForItemTypes} to exist.
68
71
  */
69
- export declare const DEFAULT_CONTEXT_ITEM_TYPE = "document";
70
- /** `content_type` values addressable as items, in wire order. */
71
- export declare const CONTEXT_CONTENT_TYPES: ("document" | "reference" | "asset")[];
72
+ export declare const DEFAULT_CONTEXT_ITEM_TYPE = "content";
73
+ /** A stored `(role, format)` pair, as the table and the filters pass it around. */
74
+ export type ContentKind = {
75
+ role: string | null;
76
+ format: string | null;
77
+ };
78
+ /** Item types a stored kind can serialize as, in wire order. */
79
+ export declare const CONTEXT_CONTENT_TYPES: ("content" | "asset")[];
72
80
  /** Item types an agent may read back, in wire order. */
73
81
  export declare const CONTEXT_ITEM_TYPES: string[];
74
- /** `content_type` values a caller may create through the context layer. */
75
- export declare const PUSH_CONTENT_TYPES: ("document" | "reference" | "asset")[];
76
- /** `content_type` values the inbox may capture. */
77
- export declare const INBOX_CONTENT_TYPES: ("document" | "reference" | "asset")[];
82
+ /**
83
+ * Everything `?types=` parses.
84
+ *
85
+ * The same list a read serializes, now that nothing is accepted under a
86
+ * retired name: `document` was mapped through for one release so a filter
87
+ * written against the old vocabulary returned a superset rather than an
88
+ * empty page, and that window closed with the release that moved the CLI's
89
+ * own vocabulary — the same shape `reference`'s retirement closed under (git
90
+ * history has that window's open and close).
91
+ */
92
+ export declare const CONTEXT_ITEM_TYPE_FILTER_VALUES: string[];
93
+ /** Values a caller may create with, in wire order. */
94
+ export declare const PUSH_CONTENT_TYPES: ("content" | "asset")[];
95
+ /** Values the inbox may capture. */
96
+ export declare const INBOX_CONTENT_TYPES: ("content" | "asset")[];
78
97
  /**
79
98
  * Membership kinds in `bundle_items.item_type`.
80
99
  *
81
100
  * **A different axis from everything above, kept here because it is the other
82
101
  * half of "what kind is this item".** `bundle_items.item_type` says which table
83
- * `item_id` points at (`guides` or `guide_files`); it is not a narrowing of
84
- * `content_type`, and a new *content* kind must not add a row here. The review
102
+ * `item_id` points at (`guides` or `guide_files`); it is not a narrowing of the
103
+ * content kinds above, and a new *content* kind must not add a row here. The review
85
104
  * that motivated this file counts it among the "five enums over one column"
86
105
  * (§2.3) — that count is wrong, and the two axes are named separately below so
87
106
  * a later reader does not merge them.
88
107
  */
89
108
  export declare const BUNDLE_MEMBER_TYPES: readonly ["guide_file", "guide"];
90
109
  /**
91
- * The item type a stored `content_type` serializes as.
110
+ * The item type a stored kind serializes as.
92
111
  *
93
- * Anything unrecognized — including NULL — is a {@link DEFAULT_CONTEXT_ITEM_TYPE},
94
- * so a stray row never produces a schema-invalid response. That default is what
95
- * makes this mapping non-injective: `contentType` cannot be recovered from an
96
- * item's `type`, which is why filtering by type in SQL needs
97
- * {@link contentTypeFilterForItemTypes} rather than an inverted lookup.
112
+ * Anything unrecognized — a guidance row, a rubric, a script, an `html` page, a
113
+ * row carrying no role at all — is a {@link DEFAULT_CONTEXT_ITEM_TYPE}, so a
114
+ * stray row never produces a schema-invalid response. That default is what
115
+ * makes this mapping non-injective: the pair cannot be recovered from an item's
116
+ * `type`, which is why filtering by type in SQL needs
117
+ * {@link kindFilterForItemTypes} rather than an inverted lookup.
98
118
  */
99
- export declare function contentTypeToItemType(contentType: string | null): (typeof CONTEXT_ITEM_TYPES)[number];
119
+ export declare function itemTypeForKind(role: string | null, format: string | null): (typeof CONTEXT_ITEM_TYPES)[number];
100
120
  /**
101
- * How to select the rows whose `content_type` serializes as one of
102
- * `wantedItemTypes` — the inverse of {@link contentTypeToItemType}, as data.
121
+ * How to select the rows whose kind serializes as one of `wantedItemTypes` —
122
+ * the inverse of {@link itemTypeForKind}, as data.
103
123
  *
104
124
  * **Data rather than SQL because `packages/` never imports from the dashboard**
105
125
  * (`CLAUDE.md` → Boundary Rules). The caller builds the predicate with its own
106
- * query builder; what it must not have to re-derive is *which* content types
107
- * belong in it, which is exactly the knowledge that drifted.
126
+ * query builder; what it must not have to re-derive is *which* kinds belong in
127
+ * it, which is exactly the knowledge that drifted.
108
128
  *
109
129
  * The two variants are the whole contract, and the second one is why this
110
130
  * returns a tagged shape instead of a bare array:
111
131
  *
112
- * - `{ kind: 'in' }` — match `content_type IN contentTypes`.
113
- * - `{ kind: 'inOrUnlisted' }` — match
114
- * `content_type IN contentTypes OR content_type NOT IN excluding OR content_type IS NULL`.
132
+ * - `{ kind: 'in' }` — match a row whose pair is one of `kinds`.
133
+ * - `{ kind: 'inOrUnlisted' }` — match a row whose pair is one of `kinds`, **or**
134
+ * whose pair is none of `excluding`.
115
135
  *
116
- * **The `IS NULL` arm is part of what `inOrUnlisted` means, not an extra the
117
- * caller adds.** In SQL a NULL column makes `IN` and `NOT IN` alike evaluate to
118
- * NULL, so a plain `NOT IN ('reference','asset')` silently drops exactly the
119
- * legacy NULL rows the serializer still calls documents — the route would then
120
- * contradict itself about the same row (Codex, PR #562). Spelling the arm into
121
- * the variant's definition is what stops the next caller reconstructing the
122
- * predicate without it.
136
+ * **"None of `excluding`" has to be NULL-safe, and that is part of what the
137
+ * variant means rather than an extra the caller adds.** `role` and `format` are
138
+ * NULL on exactly the rows that carry no content — a tombstone — and in SQL a
139
+ * comparison against NULL is NULL, so a predicate written as a plain `!=` pair
140
+ * drops precisely the rows the serializer still calls `content` — the default
141
+ * kind. The route would then contradict itself about the same row, which is the
142
+ * defect this shape was introduced to prevent (Codex, PR #562, when the columns
143
+ * were one).
123
144
  *
124
145
  * `wantedItemTypes` values that are not item types at all (`guide`, or junk)
125
146
  * simply match no kind; guides are not `guide_files` rows and are selected
126
147
  * separately by their caller.
127
148
  */
128
- /**
129
- * A `content_type` addressable through the context layer.
130
- *
131
- * Derived from {@link CONTEXT_CONTENT_KINDS} rather than restated, so the table
132
- * above stays the one definition. `ContentTypeFilter` used to widen these to
133
- * `string[]`, which threw the literals away at the boundary and left every
134
- * consumer unable to prove a filter value was a real content type.
135
- */
136
- export type ContextContentType = (typeof CONTEXT_CONTENT_TYPES)[number];
137
- export type ContentTypeFilter = {
149
+ export type ContentKindFilter = {
138
150
  kind: 'in';
139
- contentTypes: ContextContentType[];
151
+ kinds: ContentKind[];
140
152
  } | {
141
153
  kind: 'inOrUnlisted';
142
- contentTypes: ContextContentType[];
143
- excluding: ContextContentType[];
154
+ kinds: ContentKind[];
155
+ excluding: ContentKind[];
144
156
  };
145
- export declare function contentTypeFilterForItemTypes(wantedItemTypes: Iterable<string>): ContentTypeFilter;
157
+ /**
158
+ * An item type addressable through the context layer.
159
+ *
160
+ * Derived from {@link CONTEXT_CONTENT_TYPES} rather than restated, so the table
161
+ * above stays the one definition.
162
+ */
163
+ export type ContextContentType = (typeof CONTEXT_CONTENT_TYPES)[number];
164
+ export declare function kindFilterForItemTypes(wantedItemTypes: Iterable<string>): ContentKindFilter;
146
165
  //# sourceMappingURL=contextKinds.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contextKinds.d.ts","sourceRoot":"","sources":["../src/contextKinds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;EAQxB,CAAA;AAEV;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,UAAU,CAAA;AAEtC;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,aAAa,CAAA;AAenD,iEAAiE;AACjE,eAAO,MAAM,qBAAqB,wCAAkD,CAAA;AAEpF,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,UAA8C,CAAA;AAE7E,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,wCAAyB,CAAA;AAExD,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,wCAA2B,CAAA;AAE3D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,kCAA2C,CAAA;AAE3E;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,GAAG,IAAI,GACzB,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAGrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvE,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,YAAY,EAAE,kBAAkB,EAAE,CAAA;CAAE,GAClD;IACE,IAAI,EAAE,cAAc,CAAA;IACpB,YAAY,EAAE,kBA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AAC;IAAC,KAAK,EAAE,WAAW,EAAE,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,WAAW,EAAE,CAAC;IAAC,SAAS,EAAE,WAAW,EAAE,CAAA;CAAE,CAAA;AAE5E;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvE,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,GAChC,iBAAiB,CAgBnB"}
@@ -1,14 +1,12 @@
1
1
  /**
2
2
  * The one table the context item-kind narrowings derive from.
3
3
  *
4
- * **Why this file exists.** `guide_files.content_type` is a free-text,
5
- * nullable column server-side, narrowed on the wire in three different
6
- * places — what an agent may *read* back
7
- * (`ContextItemTypeSchema`), what it may *push* (`PushContentTypeSchema`), what
8
- * it may *capture* into the inbox (`InboxContentTypeSchema`) — plus a lossy
9
- * `contentType → itemType` mapping and a hand-written SQL inverse of that
10
- * mapping in the items route. Each narrowing had a reason and none of them
11
- * derived from a shared source, so adding a fourth kind meant editing five
4
+ * **Why this file exists.** What an agent may *read* back
5
+ * (`ContextItemTypeSchema`), what it may *push* (`PushContentTypeSchema`) and
6
+ * what it may *capture* into the inbox (`InboxContentTypeSchema`) are three
7
+ * narrowings of the same question, plus a lossy kind → item-type mapping and a
8
+ * SQL inverse of it in the items route. Each narrowing had a reason and none of
9
+ * them derived from a shared source, so adding a fourth kind meant editing five
12
10
  * places and nothing failed if you missed one.
13
11
  *
14
12
  * Now one row per kind answers all of it declaratively. A new kind is a new row
@@ -16,105 +14,133 @@
16
14
  * silently omitted from a narrowing, because no narrowing has its own list any
17
15
  * more.
18
16
  *
19
- * **Strictly a re-derivation.** Every picklist below comes out equal to the
20
- * literal it replaced, values and order alike — `contextKinds.test.ts` pins each
21
- * one against a hand-written copy of today's values, so a row edit that would
22
- * change the wire fails there rather than in a client. Which kinds are pushable
23
- * and capturable are product decisions this table records; changing one is a
24
- * separate, deliberate change to that row.
17
+ * `contextKinds.test.ts` pins each derived picklist against a hand-written copy
18
+ * of today's values, so a row edit that would change the wire fails there rather
19
+ * than in a client. Which kinds are pushable and capturable are product
20
+ * decisions this table records; changing one is a separate, deliberate change to
21
+ * that row.
25
22
  */
26
23
  /**
27
- * The `content_type` values that are addressable as context items on the wire.
24
+ * The stored kinds that are addressable as context items on the wire.
28
25
  *
29
- * `contentType` doubles as the item's `type` in a response — for these kinds the
30
- * two are the same string, which is why there is no separate `itemType` column
31
- * here. Kinds *not* listed (`instructions`, `eval`, `script`, and a legacy NULL)
32
- * are still stored in the column; they collapse onto
26
+ * **Keyed on the `(role, format)` pair, and that is the load-bearing part.**
27
+ * A table keyed on `role` alone would quietly hand a
28
+ * **script** — `content` + `code` — both `pushable` and `capturable`, because
29
+ * nothing would separate it from a markdown document. It must not, and the pair
30
+ * is what stops it. This is the one place the two columns have to be read
31
+ * together; splitting a column does not by itself make every consumer
32
+ * single-column.
33
+ *
34
+ * Pairs *not* listed — `guidance`, `criteria`, `content` + `code`, and a row
35
+ * with no role at all — are still stored. They collapse onto
33
36
  * {@link DEFAULT_CONTEXT_ITEM_TYPE} when serialized, and
34
- * {@link contentTypeFilterForItemTypes} is what keeps SQL agreeing with that.
37
+ * {@link kindFilterForItemTypes} is what keeps SQL agreeing with that.
35
38
  *
36
39
  * Order is the wire order of the derived picklists and is load-bearing for the
37
40
  * pin test; append rather than reorder.
38
41
  */
39
42
  export const CONTEXT_CONTENT_KINDS = [
40
- { contentType: 'document', pushable: true, capturable: true },
41
- { contentType: 'reference', pushable: true, capturable: false },
43
+ {
44
+ itemType: 'content',
45
+ role: 'content',
46
+ format: 'markdown',
47
+ pushable: true,
48
+ capturable: true,
49
+ },
42
50
  // `capturable` ahead of the upload path it is for: the inbox schema has
43
51
  // admitted `asset` since it was written, with image upload still to land.
44
52
  // The flag records today's wire, which is the only thing this table is
45
53
  // allowed to record.
46
- { contentType: 'asset', pushable: true, capturable: true },
54
+ {
55
+ itemType: 'asset',
56
+ role: 'content',
57
+ format: 'binary',
58
+ pushable: true,
59
+ capturable: true,
60
+ },
47
61
  ];
48
62
  /**
49
63
  * The item type of a `guides` row.
50
64
  *
51
- * A guide is not a `content_type` at all — it is a different table — which is
52
- * why it is named here rather than added to the table above. It is readable as
65
+ * A guide is not a stored `(role, format)` pair at all — it is a different
66
+ * table — which is why it is named here rather than added to the table above. It is readable as
53
67
  * an item and deliberately neither pushable nor capturable: `PushContentType`'s
54
68
  * doc comment on `PushContentTypeSchema` explains why a create cannot honor it.
55
69
  */
56
70
  export const GUIDE_ITEM_TYPE = 'guide';
57
71
  /**
58
- * What an unlisted or NULL `content_type` serializes as.
72
+ * What an unlisted pair serializes as.
59
73
  *
60
74
  * The default arm exists so a stray row — one written before a kind was
61
75
  * retired, or by a non-context surface — produces a schema-valid response
62
76
  * instead of failing the read. It is what makes the mapping lossy, and so what
63
- * forces {@link contentTypeFilterForItemTypes} to exist.
77
+ * forces {@link kindFilterForItemTypes} to exist.
64
78
  */
65
- export const DEFAULT_CONTEXT_ITEM_TYPE = 'document';
79
+ export const DEFAULT_CONTEXT_ITEM_TYPE = 'content';
66
80
  // `Extract` rather than a bare boolean `filter`, because a bare one widens.
67
81
  // `k.pushable` does not narrow `k`, so the derived arrays would type as *every*
68
82
  // content type and `InboxContentType` would silently admit `reference` at the
69
83
  // type level while still rejecting it at runtime — a wire narrowing that no
70
84
  // longer narrows anything a compiler can see. The predicate keeps each derived
71
85
  // picklist as tight as the literal it replaced.
72
- const kindsWhere = (flag) => CONTEXT_CONTENT_KINDS.filter((k) => k[flag]).map((k) => k.contentType);
73
- /** `content_type` values addressable as items, in wire order. */
74
- export const CONTEXT_CONTENT_TYPES = CONTEXT_CONTENT_KINDS.map((k) => k.contentType);
86
+ const kindsWhere = (flag) => CONTEXT_CONTENT_KINDS.filter((k) => k[flag]).map((k) => k.itemType);
87
+ /** Item types a stored kind can serialize as, in wire order. */
88
+ export const CONTEXT_CONTENT_TYPES = CONTEXT_CONTENT_KINDS.map((k) => k.itemType);
75
89
  /** Item types an agent may read back, in wire order. */
76
90
  export const CONTEXT_ITEM_TYPES = [GUIDE_ITEM_TYPE, ...CONTEXT_CONTENT_TYPES];
77
- /** `content_type` values a caller may create through the context layer. */
91
+ /**
92
+ * Everything `?types=` parses.
93
+ *
94
+ * The same list a read serializes, now that nothing is accepted under a
95
+ * retired name: `document` was mapped through for one release so a filter
96
+ * written against the old vocabulary returned a superset rather than an
97
+ * empty page, and that window closed with the release that moved the CLI's
98
+ * own vocabulary — the same shape `reference`'s retirement closed under (git
99
+ * history has that window's open and close).
100
+ */
101
+ export const CONTEXT_ITEM_TYPE_FILTER_VALUES = CONTEXT_ITEM_TYPES;
102
+ /** Values a caller may create with, in wire order. */
78
103
  export const PUSH_CONTENT_TYPES = kindsWhere('pushable');
79
- /** `content_type` values the inbox may capture. */
104
+ /** Values the inbox may capture. */
80
105
  export const INBOX_CONTENT_TYPES = kindsWhere('capturable');
81
106
  /**
82
107
  * Membership kinds in `bundle_items.item_type`.
83
108
  *
84
109
  * **A different axis from everything above, kept here because it is the other
85
110
  * half of "what kind is this item".** `bundle_items.item_type` says which table
86
- * `item_id` points at (`guides` or `guide_files`); it is not a narrowing of
87
- * `content_type`, and a new *content* kind must not add a row here. The review
111
+ * `item_id` points at (`guides` or `guide_files`); it is not a narrowing of the
112
+ * content kinds above, and a new *content* kind must not add a row here. The review
88
113
  * that motivated this file counts it among the "five enums over one column"
89
114
  * (§2.3) — that count is wrong, and the two axes are named separately below so
90
115
  * a later reader does not merge them.
91
116
  */
92
117
  export const BUNDLE_MEMBER_TYPES = ['guide_file', GUIDE_ITEM_TYPE];
93
118
  /**
94
- * The item type a stored `content_type` serializes as.
119
+ * The item type a stored kind serializes as.
95
120
  *
96
- * Anything unrecognized — including NULL — is a {@link DEFAULT_CONTEXT_ITEM_TYPE},
97
- * so a stray row never produces a schema-invalid response. That default is what
98
- * makes this mapping non-injective: `contentType` cannot be recovered from an
99
- * item's `type`, which is why filtering by type in SQL needs
100
- * {@link contentTypeFilterForItemTypes} rather than an inverted lookup.
121
+ * Anything unrecognized — a guidance row, a rubric, a script, an `html` page, a
122
+ * row carrying no role at all — is a {@link DEFAULT_CONTEXT_ITEM_TYPE}, so a
123
+ * stray row never produces a schema-invalid response. That default is what
124
+ * makes this mapping non-injective: the pair cannot be recovered from an item's
125
+ * `type`, which is why filtering by type in SQL needs
126
+ * {@link kindFilterForItemTypes} rather than an inverted lookup.
101
127
  */
102
- export function contentTypeToItemType(contentType) {
103
- const kind = CONTEXT_CONTENT_KINDS.find((k) => k.contentType === contentType);
104
- return kind ? kind.contentType : DEFAULT_CONTEXT_ITEM_TYPE;
128
+ export function itemTypeForKind(role, format) {
129
+ const kind = CONTEXT_CONTENT_KINDS.find((k) => k.role === role && k.format === format);
130
+ return kind ? kind.itemType : DEFAULT_CONTEXT_ITEM_TYPE;
105
131
  }
106
- export function contentTypeFilterForItemTypes(wantedItemTypes) {
132
+ export function kindFilterForItemTypes(wantedItemTypes) {
107
133
  const wanted = new Set(wantedItemTypes);
108
- const contentTypes = CONTEXT_CONTENT_TYPES.filter((ct) => wanted.has(contentTypeToItemType(ct)));
134
+ const kinds = CONTEXT_CONTENT_KINDS.filter((k) => wanted.has(k.itemType)).map((k) => ({ role: k.role, format: k.format }));
109
135
  if (!wanted.has(DEFAULT_CONTEXT_ITEM_TYPE))
110
- return { kind: 'in', contentTypes };
136
+ return { kind: 'in', kinds };
111
137
  return {
112
138
  kind: 'inOrUnlisted',
113
- contentTypes,
114
- // The listed kinds that are *not* the default — i.e. every content type
115
- // whose item type is something other than `document`. A row outside this
116
- // set is a document by the default arm above, NULL included.
117
- excluding: CONTEXT_CONTENT_TYPES.filter((ct) => contentTypeToItemType(ct) !== DEFAULT_CONTEXT_ITEM_TYPE),
139
+ kinds,
140
+ // The listed kinds that are *not* the default — i.e. every pair whose item
141
+ // type is something other than `content`. A row outside this set reads back
142
+ // as `content` by the default arm above, a tombstone's two NULLs included.
143
+ excluding: CONTEXT_CONTENT_KINDS.filter((k) => k.itemType !== DEFAULT_CONTEXT_ITEM_TYPE).map((k) => ({ role: k.role, format: k.format })),
118
144
  };
119
145
  }
120
146
  //# sourceMappingURL=contextKinds.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contextKinds.js","sourceRoot":"","sources":["../src/contextKinds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE;IAC7D,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE;IAC/D,wEAAwE;IACxE,0EAA0E;IAC1E,uEAAuE;IACvE,qBAAqB;IACrB,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE;CAClD,CAAA;AAEV;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAA;AAEtC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAAA;AAInD,4EAA4E;AAC5E,gFAAgF;AAChF,8EAA8E;AAC9E,4EAA4E;AAC5E,+EAA+E;AAC/E,gDAAgD;AAChD,MAAM,UAAU,GAAG,CAA0C,IAAW,EAAE,EAAE,CAC1E,qBAAqB,CAAC,MAAM,CAC1B,CAAC,CAAC,EAAyD,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CACtE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;AAE7B,iEAAiE;AACjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,GAAG,CAAC,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