@agentshouse/mdmodel 0.1.0-cd90851746292 → 0.1.0-cdbd463e01dc2

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 (95) hide show
  1. package/API.md +90 -81
  2. package/README.md +6 -4
  3. package/dist/definition.d.ts +1 -1
  4. package/dist/definition.d.ts.map +1 -1
  5. package/dist/definition.js +13 -9
  6. package/dist/event.d.ts +78 -0
  7. package/dist/event.d.ts.map +1 -0
  8. package/dist/event.js +230 -0
  9. package/dist/facts.d.ts +15 -0
  10. package/dist/facts.d.ts.map +1 -0
  11. package/dist/facts.js +39 -0
  12. package/dist/index.d.ts +17 -5
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +10 -3
  15. package/dist/kinds.d.ts +19 -0
  16. package/dist/kinds.d.ts.map +1 -0
  17. package/dist/kinds.js +161 -0
  18. package/dist/query/language.d.ts +223 -0
  19. package/dist/query/language.d.ts.map +1 -0
  20. package/dist/query/language.js +565 -0
  21. package/dist/query/match.d.ts +14 -0
  22. package/dist/query/match.d.ts.map +1 -0
  23. package/dist/query/match.js +121 -0
  24. package/dist/query/rows.d.ts +32 -0
  25. package/dist/query/rows.d.ts.map +1 -0
  26. package/dist/query/rows.js +161 -0
  27. package/dist/query/sql.d.ts +39 -0
  28. package/dist/query/sql.d.ts.map +1 -0
  29. package/dist/query/sql.js +279 -0
  30. package/dist/reserved.d.ts +5 -0
  31. package/dist/reserved.d.ts.map +1 -0
  32. package/dist/reserved.js +20 -0
  33. package/dist/types.d.ts +7 -0
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/validate.d.ts +4 -3
  36. package/dist/validate.d.ts.map +1 -1
  37. package/dist/validate.js +103 -36
  38. package/fixtures/README.md +17 -2
  39. package/fixtures/cases/link-into-a-reserved-name/context.json +1 -0
  40. package/fixtures/cases/link-into-a-reserved-name/expected.json +5 -0
  41. package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +6 -0
  42. package/fixtures/cases/link-into-a-reserved-name/schema.yaml +3 -0
  43. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/context.json +1 -0
  44. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/expected.json +5 -0
  45. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/library/notes/b.md +5 -0
  46. package/fixtures/cases/member-on-an-untyped-document/context.json +1 -0
  47. package/fixtures/cases/member-on-an-untyped-document/expected.json +6 -0
  48. package/fixtures/cases/member-on-an-untyped-document/library/note.md +4 -0
  49. package/fixtures/cases/member-on-another-type/context.json +1 -0
  50. package/fixtures/cases/member-on-another-type/expected.json +6 -0
  51. package/fixtures/cases/member-on-another-type/library/note.md +4 -0
  52. package/fixtures/cases/member-on-another-type/schema.yaml +7 -0
  53. package/fixtures/cases/reference-into-a-reserved-name/context.json +1 -0
  54. package/fixtures/cases/reference-into-a-reserved-name/expected.json +6 -0
  55. package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +4 -0
  56. package/fixtures/cases/reference-into-a-reserved-name/library/settings/brief.md +1 -0
  57. package/fixtures/cases/reference-into-a-reserved-name/schema.yaml +3 -0
  58. package/fixtures/cases/room-md-declares-a-type/context.json +1 -0
  59. package/fixtures/cases/room-md-declares-a-type/expected.json +6 -0
  60. package/fixtures/cases/room-md-declares-a-type/library/ROOM.md +5 -0
  61. package/fixtures/cases/typed-path-names-another-type/context.json +11 -0
  62. package/fixtures/cases/typed-path-names-another-type/expected.json +6 -0
  63. package/fixtures/cases/typed-path-names-another-type/library/settings/prefs/one.md +3 -0
  64. package/fixtures/cases/typed-path-names-another-type/schema.yaml +6 -0
  65. package/fixtures/cases/typed-path-names-its-type/context.json +11 -0
  66. package/fixtures/cases/typed-path-names-its-type/expected.json +3 -0
  67. package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/deeper/two.md +1 -0
  68. package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +4 -0
  69. package/fixtures/cases/typed-path-names-its-type/schema.yaml +6 -0
  70. package/fixtures/cases/typed-path-names-no-type/context.json +11 -0
  71. package/fixtures/cases/typed-path-names-no-type/expected.json +6 -0
  72. package/fixtures/cases/typed-path-names-no-type/library/settings/prefs/one.md +1 -0
  73. package/fixtures/cases/typed-path-names-no-type/schema.yaml +6 -0
  74. package/fixtures/cases/unnamed-typed-path-checks-its-fields/context.json +11 -0
  75. package/fixtures/cases/unnamed-typed-path-checks-its-fields/expected.json +6 -0
  76. package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +4 -0
  77. package/fixtures/cases/unnamed-typed-path-checks-its-fields/schema.yaml +5 -0
  78. package/fixtures/cases/unnamed-typed-path-names-a-type/context.json +11 -0
  79. package/fixtures/cases/unnamed-typed-path-names-a-type/expected.json +6 -0
  80. package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +6 -0
  81. package/fixtures/cases/unnamed-typed-path-names-a-type/schema.yaml +5 -0
  82. package/fixtures/cases/unnamed-typed-path-reads-its-type/context.json +11 -0
  83. package/fixtures/cases/unnamed-typed-path-reads-its-type/expected.json +3 -0
  84. package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/plan.md +1 -0
  85. package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +5 -0
  86. package/fixtures/cases/unnamed-typed-path-reads-its-type/schema.yaml +5 -0
  87. package/fixtures/cases/unnamed-typed-path-without-a-body/context.json +11 -0
  88. package/fixtures/cases/unnamed-typed-path-without-a-body/expected.json +5 -0
  89. package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +5 -0
  90. package/fixtures/cases/unnamed-typed-path-without-a-body/schema.yaml +5 -0
  91. package/fixtures/queries.json +913 -0
  92. package/package.json +1 -1
  93. package/dist/condition.d.ts +0 -180
  94. package/dist/condition.d.ts.map +0 -1
  95. package/dist/condition.js +0 -633
package/dist/types.d.ts CHANGED
@@ -12,9 +12,16 @@ export type ModelVerification = {
12
12
  readonly rule: string;
13
13
  readonly location?: string;
14
14
  };
15
+ export type TypedPath = {
16
+ readonly path: string;
17
+ readonly type: string;
18
+ readonly named: boolean;
19
+ readonly body: boolean;
20
+ };
15
21
  export type ValidationContext = {
16
22
  readonly binaryTargets: readonly string[];
17
23
  readonly anyRoom?: true;
24
+ readonly typedPaths?: readonly TypedPath[];
18
25
  };
19
26
  export type ProjectionContext = {
20
27
  readonly documentTargets: readonly string[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;CAAE,GAC7D;IACE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEN,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EA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QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEN,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAC5D;IACE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,GACD;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC"}
@@ -2,8 +2,9 @@ import { type Definition } from './definition.js';
2
2
  import type { DocumentCheck, Library, ModelVerification, Reached, RoomReference, Validation, ValidationContext, ValidationStep, VerifiedModel } from './types.js';
3
3
  export declare function resolves(reference: Reached, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): boolean;
4
4
  export declare function verify(schema: string, provided?: VerifiedModel): ModelVerification;
5
- export declare function checkDocument(file: string, content: string, model: VerifiedModel, context?: Pick<ValidationContext, 'anyRoom'>): DocumentCheck;
6
- export declare function sectionReferences(file: string, content: string, definition: Definition): readonly Reached[];
5
+ export declare function readTypes(schema: string, provided?: VerifiedModel): VerifiedModel;
6
+ type Placing = Pick<ValidationContext, 'anyRoom' | 'typedPaths'>;
7
+ export declare function checkDocument(file: string, content: string, model: VerifiedModel, context?: Placing): DocumentCheck;
7
8
  export declare function bodyRoomLinks(body: string): RoomReference[];
8
9
  export declare function roomReferences(file: string, content: string, definition?: Definition): readonly RoomReference[];
9
10
  type Placed = {
@@ -20,7 +21,7 @@ export type Assessment = {
20
21
  readonly linked: boolean;
21
22
  readonly sections: readonly Placed[];
22
23
  };
23
- export declare function assess(file: string, content: string, binary: boolean, model?: VerifiedModel, context?: Pick<ValidationContext, 'anyRoom'>): Assessment;
24
+ export declare function assess(file: string, content: string, binary: boolean, model?: VerifiedModel, context?: Placing): Assessment;
24
25
  export type Verdicts = {
25
26
  add(assessment: Assessment, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): number;
26
27
  verdict(): Validation;
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AASzF,OAAO,KAAK,EAEV,aAAa,EAEb,OAAO,EACP,iBAAiB,EACjB,OAAO,EACP,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,EACd,MAAM,YAAY,CAAC;AA8CpB,wBAAgB,QAAQ,CACtB,SAAS,EAAE,OAAO,EAClB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EAC5C,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAChC,OAAO,CAET;AA8BD,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,iBAAiB,CAQlF;AA0ED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAM,GAC/C,aAAa,CA0Bf;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAA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AAO,IAAI,UAAU,CAAC;CACvB,CAAC;AAEF,wBAAgB,QAAQ,IAAI,QAAQ,CA+DnC;AAED,wBAAiB,UAAU,CACzB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,OAAO,GAAE,iBAAyC,EAClD,KAAK,GAAE,aAA6B,GACnC,SAAS,CAAC,cAAc,EAAE,UAAU,EAAE,IAAI,CAAC,CAsB7C;AAED,wBAAgB,QAAQ,CACtB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,iBAAyC,EAClD,KAAK,GAAE,aAA6B,GACnC,UAAU,CAKZ"}
package/dist/validate.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import { ATTACHMENT, BUILT_IN_TYPE, readSchema } from './definition.js';
2
- import { parse } from './document.js';
2
+ import { links, parse } from './document.js';
3
+ import { MEMBER_FIELD } from './fields.js';
3
4
  import { hrefOccurrences, linkInventory } from './links.js';
4
5
  import { classifyHref, roomTarget } from './paths.js';
5
6
  import { references } from './references.js';
7
+ import { isDocumentPath, ROOM_DESCRIPTION } from './reserved.js';
6
8
  import { refusal } from './refuse.js';
7
9
  import { conditionedSections, fitsItem, frontmatterRefusal } from './schema.js';
8
10
  import { openPatternBudget, PatternTooCostly } from './pattern.js';
@@ -11,6 +13,50 @@ import { bodyAfterFrontmatter, bodyStartOf } from './yaml.js';
11
13
  function refuse(file, rule, extra) {
12
14
  return { verdict: 'refuse', ...refusal(file, rule, extra) };
13
15
  }
16
+ function unmarkedMember(file, document, definition) {
17
+ return Object.hasOwn(document.fields, MEMBER_FIELD) && definition?.memberDocument !== true
18
+ ? refuse(file, 'undeclared-field', { location: `/${MEMBER_FIELD}` })
19
+ : null;
20
+ }
21
+ function reservedLink(file, document) {
22
+ return (document.type !== undefined &&
23
+ isDocumentPath(file) &&
24
+ links(document, file).some((link) => !isDocumentPath(link.target)));
25
+ }
26
+ function describedRoom(file, document) {
27
+ return file === ROOM_DESCRIPTION && document.type !== undefined
28
+ ? refuse(file, 'room-md-type', { location: '/type' })
29
+ : null;
30
+ }
31
+ function nameFits(pattern, name) {
32
+ const at = pattern.indexOf('*');
33
+ if (at === -1)
34
+ return pattern === name;
35
+ const head = pattern.slice(0, at);
36
+ const tail = pattern.slice(at + 1);
37
+ return name.length > head.length + tail.length && name.startsWith(head) && name.endsWith(tail);
38
+ }
39
+ function typedPathOf(file, typedPaths = []) {
40
+ const names = file.split('/');
41
+ return typedPaths.find(({ path }) => {
42
+ const patterns = path.split('/');
43
+ return (patterns.length === names.length &&
44
+ patterns.every((pattern, at) => nameFits(pattern, names[at])));
45
+ });
46
+ }
47
+ const HELD_TEXT = /\S/u;
48
+ function typedPathRefusal(file, content, document, typedPath) {
49
+ if (typedPath === undefined)
50
+ return null;
51
+ if (document.type !== (typedPath.named ? typedPath.type : undefined))
52
+ return refuse(file, 'unknown-type', { location: '/type' });
53
+ return typedPath.body && !HELD_TEXT.test(bodyAfterFrontmatter(content))
54
+ ? refuse(file, 'required-body')
55
+ : null;
56
+ }
57
+ function kindOf(document, typedPath) {
58
+ return typedPath !== undefined && !typedPath.named ? typedPath.type : instanceType(document);
59
+ }
14
60
  function instanceType(document) {
15
61
  const raw = document.fields.type;
16
62
  if (raw === undefined || raw === null)
@@ -71,6 +117,12 @@ export function verify(schema, provided) {
71
117
  ...(read.location === undefined ? {} : { location: read.location }),
72
118
  };
73
119
  }
120
+ export function readTypes(schema, provided) {
121
+ const read = readSchema(schema, provided, false);
122
+ if ('types' in read)
123
+ return read;
124
+ throw new Error(`the schema reads as no types: ${read.rule} ${read.location ?? ''}`.trim());
125
+ }
74
126
  function structure(file, content, document, definition) {
75
127
  if (definition === undefined)
76
128
  return { refusal: refuse(file, 'unknown-type', { location: '/type' }) };
@@ -109,7 +161,8 @@ function structure(file, content, document, definition) {
109
161
  });
110
162
  }
111
163
  }
112
- return { sections };
164
+ const member = unmarkedMember(file, document, definition);
165
+ return member === null ? { sections } : { refusal: member };
113
166
  }
114
167
  function linked(file, content) {
115
168
  return hrefOccurrences(bodyAfterFrontmatter(content)).every((occurrence) => classifyHref(file, occurrence.href).kind !== 'invalid');
@@ -118,11 +171,19 @@ function reached(file, href, to) {
118
171
  const resolved = classifyHref(file, href);
119
172
  return { target: resolved.kind === 'path' ? resolved.path : null, to };
120
173
  }
174
+ function referred(file, href, to) {
175
+ const reference = reached(file, href, to);
176
+ return reference.target !== null &&
177
+ isDocumentPath(file) &&
178
+ !isDocumentPath(reference.target) &&
179
+ !to.includes(ATTACHMENT)
180
+ ? { target: null, to }
181
+ : reference;
182
+ }
121
183
  function crossing(file, href, crossRoom) {
122
184
  return crossRoom === true && classifyHref(file, href).kind === 'room';
123
185
  }
124
- function definitionOf(document, model) {
125
- const kind = instanceType(document);
186
+ function definitionOf(kind, model) {
126
187
  return kind === null || !Object.hasOwn(model.types, kind) ? undefined : model.types[kind];
127
188
  }
128
189
  export function checkDocument(file, content, model, context = {}) {
@@ -132,9 +193,17 @@ export function checkDocument(file, content, model, context = {}) {
132
193
  return { ok: false };
133
194
  const document = parsed.document;
134
195
  const type = document.type ?? BUILT_IN_TYPE;
135
- if (instanceType(document) === BUILT_IN_TYPE)
136
- return { ok: true, type, typed: false, references: [] };
137
- const definition = definitionOf(document, model);
196
+ const typedPath = typedPathOf(file, context.typedPaths);
197
+ if (describedRoom(file, document) !== null ||
198
+ typedPathRefusal(file, content, document, typedPath) !== null ||
199
+ reservedLink(file, document))
200
+ return { ok: false };
201
+ const kind = kindOf(document, typedPath);
202
+ if (kind === BUILT_IN_TYPE)
203
+ return unmarkedMember(file, document, undefined) === null
204
+ ? { ok: true, type, typed: false, references: [] }
205
+ : { ok: false };
206
+ const definition = definitionOf(kind, model);
138
207
  const read = structure(file, content, document, definition);
139
208
  if ('refusal' in read || definition === undefined || !linked(file, content))
140
209
  return { ok: false };
@@ -143,32 +212,11 @@ export function checkDocument(file, content, model, context = {}) {
143
212
  type,
144
213
  typed: true,
145
214
  references: [
146
- ...references(document, definition).flatMap(({ value, to, crossRoom }) => crossing(file, value, anyRoom || crossRoom) ? [] : [reached(file, value, to)]),
147
- ...read.sections.flatMap(({ to, crossRoom, hrefs }) => hrefs.flatMap((href) => crossing(file, href, anyRoom || crossRoom) ? [] : [reached(file, href, to)])),
215
+ ...references(document, definition).flatMap(({ value, to, crossRoom }) => crossing(file, value, anyRoom || crossRoom) ? [] : [referred(file, value, to)]),
216
+ ...read.sections.flatMap(({ to, crossRoom, hrefs }) => hrefs.flatMap((href) => crossing(file, href, anyRoom || crossRoom) ? [] : [referred(file, href, to)])),
148
217
  ],
149
218
  };
150
219
  }
151
- export function sectionReferences(file, content, definition) {
152
- const referring = (name) => {
153
- const spec = Object.hasOwn(definition.sections, name) ? definition.sections[name] : undefined;
154
- return spec?.kind === 'list' && spec.items.reference !== undefined ? spec.items : undefined;
155
- };
156
- if (!Object.keys(definition.sections).some((name) => referring(name) !== undefined))
157
- return [];
158
- const uses = usesIn(content);
159
- const found = [];
160
- for (const span of headingSpans(content, bodyStartOf(content))) {
161
- const items = referring(span.name);
162
- if (items === undefined)
163
- continue;
164
- const listed = listItems(content, span.bodyStart, span.bodyEnd);
165
- const hrefs = listed === null ? null : itemHrefs(content, listed, uses);
166
- for (const href of hrefs ?? [])
167
- if (!crossing(file, href, items.crossRoom))
168
- found.push(reached(file, href, items.reference));
169
- }
170
- return found;
171
- }
172
220
  export function bodyRoomLinks(body) {
173
221
  const found = [];
174
222
  for (const href of new Set(hrefOccurrences(body).map((occurrence) => occurrence.href))) {
@@ -233,10 +281,23 @@ export function assess(file, content, binary, model = { types: {} }, context = {
233
281
  const document = parsed.document;
234
282
  const type = document.type ?? BUILT_IN_TYPE;
235
283
  const typed = { file, type, read: null, structured: null };
236
- if (instanceType(document) === BUILT_IN_TYPE) {
237
- return { ...typed, targets: [], fields: [], linked: true, sections: [] };
284
+ const typedPath = typedPathOf(file, context.typedPaths);
285
+ const described = describedRoom(file, document) ?? typedPathRefusal(file, content, document, typedPath);
286
+ if (described !== null)
287
+ return { ...typed, targets: [], structured: described, fields: [], linked: true, sections: [] };
288
+ const kind = kindOf(document, typedPath);
289
+ if (kind === BUILT_IN_TYPE) {
290
+ const structured = unmarkedMember(file, document, undefined);
291
+ return {
292
+ ...typed,
293
+ targets: [],
294
+ structured,
295
+ fields: [],
296
+ linked: !reservedLink(file, document),
297
+ sections: [],
298
+ };
238
299
  }
239
- const definition = definitionOf(document, model);
300
+ const definition = definitionOf(kind, model);
240
301
  try {
241
302
  return structured(file, content, typed, document, definition, context);
242
303
  }
@@ -268,16 +329,22 @@ function structured(file, content, typed, document, definition, context) {
268
329
  const anyRoom = context.anyRoom === true;
269
330
  const fields = references(document, definition).flatMap(({ pointer, value, to, crossRoom }) => crossing(file, value, anyRoom || crossRoom)
270
331
  ? []
271
- : [{ reference: reached(file, value, to), location: pointer }]);
332
+ : [{ reference: referred(file, value, to), location: pointer }]);
272
333
  const sections = read.sections.flatMap(({ section, to, crossRoom, hrefs }) => hrefs.flatMap((href) => crossing(file, href, anyRoom || crossRoom)
273
334
  ? []
274
- : [{ reference: reached(file, href, to), location: section }]));
335
+ : [{ reference: referred(file, href, to), location: section }]));
275
336
  const targets = new Set();
276
337
  for (const { reference } of [...fields, ...sections]) {
277
338
  if (reference.target !== null)
278
339
  targets.add(reference.target);
279
340
  }
280
- return { ...typed, targets: [...targets], fields, linked: linked(file, content), sections };
341
+ return {
342
+ ...typed,
343
+ targets: [...targets],
344
+ fields,
345
+ linked: linked(file, content) && !reservedLink(file, document),
346
+ sections,
347
+ };
281
348
  }
282
349
  export function verdicts() {
283
350
  let read;
@@ -65,6 +65,19 @@ value one span carries part of. `start` and `end` are UTF-8 byte offsets into th
65
65
  source; every source in this corpus is ASCII, so a consumer compares the
66
66
  addressed `source` with an ordinary string slice.
67
67
 
68
+ ## Queries
69
+
70
+ `queries.json` is the one table of cases both query evaluators answer. It carries `schema`,
71
+ one schema text; `documents`, each named and carrying its `path`, the `type` a collection
72
+ stores for it (`any` for an untyped Markdown Document, `null` for one that is not Markdown),
73
+ its `fileId`, the `text` the device holds or `null`, and its `fields`; and `cases`, each with a
74
+ `name`, a `query` of filter parts, the `document` it names and whether it `matches`. Verify
75
+ the schema and plan `{ ...query, select: {} }` with `planOf` against its types. Then
76
+ `matches(plan, candidate)` over the named Document, given its type's definition, and the
77
+ condition `sql.tests` writes over a collection holding every Document of the table with the
78
+ values `indexed` derives from it must both answer `matches`. A new operator adds its cases
79
+ here first.
80
+
68
81
  ## Verdict format
69
82
 
70
83
  Acceptance:
@@ -115,12 +128,14 @@ schema text. The model's own rules:
115
128
  | `reference` | `reference` is not on a string or names something but a type, `any`, `attachment` |
116
129
  | `sections` | A section is not `{ kind: text }` or `{ kind: list, items }` over one scalar |
117
130
  | `member_document` | The mark is not a boolean, or a second type carries it |
118
- | `unknown-type` | A file declares a type absent from the governing schema |
131
+ | `unknown-type` | A file declares a type absent from the governing schema, or other than its typed path requires it to name |
119
132
  | `undeclared-field` | A closed object carries a key it does not declare |
120
133
  | `required-section` | A required section heading is missing |
121
134
  | `conditional-section` | A section its type's `if` branch requires is absent or holds no text |
122
135
  | `unresolved-reference` | A reference at any depth or a section item reaches no member it admits |
123
- | `unresolved-link` | A body link is an absolute path or leaves the collection |
136
+ | `unresolved-link` | A body link is an absolute path, leaves the collection or, from a typed Document at a document path, reaches a reserved name |
137
+ | `room-md-type` | `ROOM.md` declares a type |
138
+ | `required-body` | A file at a typed path that requires a body has a body holding no text |
124
139
  | `structured-section` | A declared list section is not a list of values of its item schema |
125
140
  | `referenced-missing-file` | Remaining files still reference an absent path |
126
141
  | `unwritable-link` | No Markdown destination form can carry a new link destination |
@@ -0,0 +1 @@
1
+ { "binaryTargets": [] }
@@ -0,0 +1,5 @@
1
+ {
2
+ "verdict": "refuse",
3
+ "file": "notes/a.md",
4
+ "rule": "unresolved-link"
5
+ }
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: note
3
+ title: Plan
4
+ ---
5
+
6
+ See [the schema](../settings/schema.yaml).
@@ -0,0 +1,3 @@
1
+ note:
2
+ properties:
3
+ title: { type: string }
@@ -0,0 +1,5 @@
1
+ {
2
+ "verdict": "refuse",
3
+ "file": "notes/b.md",
4
+ "rule": "unresolved-link"
5
+ }
@@ -0,0 +1,5 @@
1
+ ---
2
+ type: any
3
+ ---
4
+
5
+ See [the Room](../Rooms/other/plan.md).
@@ -0,0 +1 @@
1
+ { "binaryTargets": [] }
@@ -0,0 +1,6 @@
1
+ {
2
+ "verdict": "refuse",
3
+ "file": "note.md",
4
+ "location": "/member",
5
+ "rule": "undeclared-field"
6
+ }
@@ -0,0 +1,4 @@
1
+ ---
2
+ member: ana@example.com
3
+ ---
4
+ # Ana
@@ -0,0 +1 @@
1
+ { "binaryTargets": [] }
@@ -0,0 +1,6 @@
1
+ {
2
+ "verdict": "refuse",
3
+ "file": "note.md",
4
+ "location": "/member",
5
+ "rule": "undeclared-field"
6
+ }
@@ -0,0 +1,4 @@
1
+ ---
2
+ type: note
3
+ member: ana@example.com
4
+ ---
@@ -0,0 +1,7 @@
1
+ contact:
2
+ member_document: true
3
+ properties:
4
+ name: { type: string }
5
+ note:
6
+ properties:
7
+ member: { type: string }
@@ -0,0 +1 @@
1
+ { "binaryTargets": [] }
@@ -0,0 +1,6 @@
1
+ {
2
+ "verdict": "refuse",
3
+ "file": "notes/a.md",
4
+ "rule": "unresolved-reference",
5
+ "location": "/brief"
6
+ }
@@ -0,0 +1,4 @@
1
+ ---
2
+ type: task
3
+ brief: ../settings/brief.md
4
+ ---
@@ -0,0 +1,3 @@
1
+ task:
2
+ properties:
3
+ brief: { type: string, reference: any }
@@ -0,0 +1 @@
1
+ { "binaryTargets": [] }
@@ -0,0 +1,6 @@
1
+ {
2
+ "verdict": "refuse",
3
+ "file": "ROOM.md",
4
+ "location": "/type",
5
+ "rule": "room-md-type"
6
+ }
@@ -0,0 +1,5 @@
1
+ ---
2
+ type: any
3
+ ---
4
+
5
+ # Research
@@ -0,0 +1,11 @@
1
+ {
2
+ "binaryTargets": [],
3
+ "typedPaths": [
4
+ {
5
+ "path": "settings/prefs/*.md",
6
+ "type": "prefs",
7
+ "named": true,
8
+ "body": false
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "verdict": "refuse",
3
+ "file": "settings/prefs/one.md",
4
+ "rule": "unknown-type",
5
+ "location": "/type"
6
+ }
@@ -0,0 +1,6 @@
1
+ prefs:
2
+ properties:
3
+ theme: { type: string }
4
+ note:
5
+ properties:
6
+ title: { type: string }
@@ -0,0 +1,11 @@
1
+ {
2
+ "binaryTargets": [],
3
+ "typedPaths": [
4
+ {
5
+ "path": "settings/prefs/*.md",
6
+ "type": "prefs",
7
+ "named": true,
8
+ "body": false
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "verdict": "accept"
3
+ }
@@ -0,0 +1,4 @@
1
+ ---
2
+ type: prefs
3
+ theme: dark
4
+ ---
@@ -0,0 +1,6 @@
1
+ prefs:
2
+ properties:
3
+ theme: { type: string }
4
+ note:
5
+ properties:
6
+ title: { type: string }
@@ -0,0 +1,11 @@
1
+ {
2
+ "binaryTargets": [],
3
+ "typedPaths": [
4
+ {
5
+ "path": "settings/prefs/*.md",
6
+ "type": "prefs",
7
+ "named": true,
8
+ "body": false
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "verdict": "refuse",
3
+ "file": "settings/prefs/one.md",
4
+ "rule": "unknown-type",
5
+ "location": "/type"
6
+ }
@@ -0,0 +1,6 @@
1
+ prefs:
2
+ properties:
3
+ theme: { type: string }
4
+ note:
5
+ properties:
6
+ title: { type: string }
@@ -0,0 +1,11 @@
1
+ {
2
+ "binaryTargets": [],
3
+ "typedPaths": [
4
+ {
5
+ "path": "rooms/*/tasks/*.md",
6
+ "type": "task",
7
+ "named": false,
8
+ "body": true
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "verdict": "refuse",
3
+ "file": "rooms/team/tasks/plan.md",
4
+ "rule": "required",
5
+ "location": "/owner"
6
+ }
@@ -0,0 +1,4 @@
1
+ ---
2
+ title: Plan
3
+ ---
4
+ Write the plan.
@@ -0,0 +1,5 @@
1
+ task:
2
+ properties:
3
+ title: { type: string, maxLength: 20 }
4
+ owner: { type: string, format: uuid }
5
+ required: [title, owner]
@@ -0,0 +1,11 @@
1
+ {
2
+ "binaryTargets": [],
3
+ "typedPaths": [
4
+ {
5
+ "path": "rooms/*/tasks/*.md",
6
+ "type": "task",
7
+ "named": false,
8
+ "body": true
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "verdict": "refuse",
3
+ "file": "rooms/team/tasks/plan.md",
4
+ "rule": "unknown-type",
5
+ "location": "/type"
6
+ }
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: task
3
+ title: Plan
4
+ owner: 019a0000-0000-7000-8000-000000000001
5
+ ---
6
+ Write the plan.
@@ -0,0 +1,5 @@
1
+ task:
2
+ properties:
3
+ title: { type: string, maxLength: 20 }
4
+ owner: { type: string, format: uuid }
5
+ required: [title, owner]