@intentius/chant 0.85.0 → 0.86.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 (121) hide show
  1. package/dist/cli/main.d.ts.map +1 -1
  2. package/dist/cli/registry.d.ts +11 -1
  3. package/dist/cli/registry.d.ts.map +1 -1
  4. package/dist/lifecycle/gate-ledger.d.ts +13 -0
  5. package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
  6. package/dist/workspace/__fixtures__/sessions.d.ts +23 -0
  7. package/dist/workspace/__fixtures__/sessions.d.ts.map +1 -0
  8. package/dist/workspace/checks/records.d.ts +1 -0
  9. package/dist/workspace/checks/records.d.ts.map +1 -1
  10. package/dist/workspace/checks.d.ts +4 -0
  11. package/dist/workspace/checks.d.ts.map +1 -1
  12. package/dist/workspace/composites.d.ts +14 -1
  13. package/dist/workspace/composites.d.ts.map +1 -1
  14. package/dist/workspace/conformance/index.d.ts +211 -0
  15. package/dist/workspace/conformance/index.d.ts.map +1 -0
  16. package/dist/workspace/conformance/vitest.d.ts +11 -0
  17. package/dist/workspace/conformance/vitest.d.ts.map +1 -0
  18. package/dist/workspace/declaration.d.ts +28 -0
  19. package/dist/workspace/declaration.d.ts.map +1 -1
  20. package/dist/workspace/declaration.schema.json +40 -0
  21. package/dist/workspace/declared-kinds.d.ts +43 -0
  22. package/dist/workspace/declared-kinds.d.ts.map +1 -0
  23. package/dist/workspace/graph-cli.d.ts +11 -0
  24. package/dist/workspace/graph-cli.d.ts.map +1 -1
  25. package/dist/workspace/intent-cli.d.ts +2 -1
  26. package/dist/workspace/intent-cli.d.ts.map +1 -1
  27. package/dist/workspace/intent-joins.d.ts +45 -8
  28. package/dist/workspace/intent-joins.d.ts.map +1 -1
  29. package/dist/workspace/intent.d.ts +66 -7
  30. package/dist/workspace/intent.d.ts.map +1 -1
  31. package/dist/workspace/ls.d.ts +31 -1
  32. package/dist/workspace/ls.d.ts.map +1 -1
  33. package/dist/workspace/reason-codes.d.ts +40 -4
  34. package/dist/workspace/reason-codes.d.ts.map +1 -1
  35. package/dist/workspace/record-sessions.d.ts +51 -0
  36. package/dist/workspace/record-sessions.d.ts.map +1 -0
  37. package/dist/workspace/record-source.d.ts +2 -0
  38. package/dist/workspace/record-source.d.ts.map +1 -1
  39. package/dist/workspace/records-cli.d.ts +65 -4
  40. package/dist/workspace/records-cli.d.ts.map +1 -1
  41. package/dist/workspace/records-since.d.ts +90 -0
  42. package/dist/workspace/records-since.d.ts.map +1 -0
  43. package/dist/workspace/records-write.d.ts +164 -0
  44. package/dist/workspace/records-write.d.ts.map +1 -0
  45. package/dist/workspace/records.d.ts +202 -15
  46. package/dist/workspace/records.d.ts.map +1 -1
  47. package/dist/workspace/runtimes.d.ts +60 -0
  48. package/dist/workspace/runtimes.d.ts.map +1 -0
  49. package/dist/workspace/status-gates.d.ts +90 -0
  50. package/dist/workspace/status-gates.d.ts.map +1 -0
  51. package/dist/workspace/status.d.ts +17 -0
  52. package/dist/workspace/status.d.ts.map +1 -1
  53. package/dist/workspace/work.d.ts +56 -0
  54. package/dist/workspace/work.d.ts.map +1 -0
  55. package/package.json +19 -1
  56. package/src/cli/main.ts +48 -3
  57. package/src/cli/registry.ts +11 -1
  58. package/src/lifecycle/gate-ledger.ts +14 -0
  59. package/src/workspace/__fixtures__/sessions.ts +66 -0
  60. package/src/workspace/checks/records.ts +19 -0
  61. package/src/workspace/checks.test.ts +2 -0
  62. package/src/workspace/checks.ts +7 -1
  63. package/src/workspace/composites.schema.json +65 -3
  64. package/src/workspace/composites.test.ts +95 -5
  65. package/src/workspace/composites.ts +28 -7
  66. package/src/workspace/conformance/__fixture__/app/package.json +7 -0
  67. package/src/workspace/conformance/__fixture__/app/src/server.mjs +29 -0
  68. package/src/workspace/conformance/__fixture__/decisions/decision.kind.mjs +32 -0
  69. package/src/workspace/conformance/__fixture__/decisions/decision.schema.json +364 -0
  70. package/src/workspace/conformance/__fixture__/decisions/fix-001-how-the-app-is-deployed.md +40 -0
  71. package/src/workspace/conformance/__fixture__/delivery/chant.config.ts +7 -0
  72. package/src/workspace/conformance/__fixture__/delivery/lexicon/index.ts +26 -0
  73. package/src/workspace/conformance/__fixture__/delivery/package.json +7 -0
  74. package/src/workspace/conformance/__fixture__/delivery/src/app.component.ts +14 -0
  75. package/src/workspace/conformance/__fixture__/delivery/src/app.ts +4 -0
  76. package/src/workspace/conformance/conformance.test.ts +149 -0
  77. package/src/workspace/conformance/index.mjs +31 -0
  78. package/src/workspace/conformance/index.ts +453 -0
  79. package/src/workspace/conformance/vitest.ts +62 -0
  80. package/src/workspace/declaration.schema.json +40 -0
  81. package/src/workspace/declaration.ts +62 -0
  82. package/src/workspace/declared-kinds.test.ts +321 -0
  83. package/src/workspace/declared-kinds.ts +76 -0
  84. package/src/workspace/graph-cli.ts +8 -0
  85. package/src/workspace/intent-cli.ts +29 -6
  86. package/src/workspace/intent-joins.test.ts +60 -0
  87. package/src/workspace/intent-joins.ts +71 -19
  88. package/src/workspace/intent.schema.json +282 -7
  89. package/src/workspace/intent.test.ts +97 -0
  90. package/src/workspace/intent.ts +332 -45
  91. package/src/workspace/ls.schema.json +34 -0
  92. package/src/workspace/ls.ts +69 -4
  93. package/src/workspace/read-contract.test.ts +30 -9
  94. package/src/workspace/reason-codes.test.ts +15 -4
  95. package/src/workspace/reason-codes.ts +47 -4
  96. package/src/workspace/record-assets.test.ts +3 -1
  97. package/src/workspace/record-sessions.ts +105 -0
  98. package/src/workspace/record-source.ts +14 -5
  99. package/src/workspace/records-amend.schema.json +167 -0
  100. package/src/workspace/records-cli.ts +246 -19
  101. package/src/workspace/records-contract.test.ts +57 -2
  102. package/src/workspace/records-formats.test.ts +640 -0
  103. package/src/workspace/records-new.schema.json +158 -0
  104. package/src/workspace/records-quorum.test.ts +196 -0
  105. package/src/workspace/records-review.schema.json +202 -0
  106. package/src/workspace/records-sessions.test.ts +108 -0
  107. package/src/workspace/records-since.schema.json +193 -0
  108. package/src/workspace/records-since.test.ts +174 -0
  109. package/src/workspace/records-since.ts +259 -0
  110. package/src/workspace/records-write-contract.test.ts +125 -0
  111. package/src/workspace/records-write.test.ts +373 -0
  112. package/src/workspace/records-write.ts +736 -0
  113. package/src/workspace/records.schema.json +187 -9
  114. package/src/workspace/records.ts +631 -41
  115. package/src/workspace/runtimes.ts +107 -0
  116. package/src/workspace/status-contract.test.ts +163 -0
  117. package/src/workspace/status-gates.ts +215 -0
  118. package/src/workspace/status.schema.json +69 -3
  119. package/src/workspace/status.ts +35 -2
  120. package/src/workspace/work.test.ts +388 -0
  121. package/src/workspace/work.ts +163 -0
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Review sessions (#2673, #2650 C10): a record kind whose records are the
3
+ * sessions a group reviewed records in. A session kind names, in its
4
+ * `session` declaration, the list of verdicts a session produced, the field
5
+ * that seals it once closed, and the kind file of the records its verdicts
6
+ * name (the subjects, such as decisions).
7
+ *
8
+ * On read, a closed session's seal has to match its text
9
+ * (`session-seal-mismatch`), and each verdict has to name a subject record
10
+ * that exists (`session-verdict-unknown-record`). Each session also lists the
11
+ * subjects' review entries that name it in their `session` field, as
12
+ * `citedBy`. This module only reads; nothing here writes a seal into a file.
13
+ */
14
+ import { type RecordEntry, type RecordFormat, type RecordKind } from "./records.js";
15
+ /** A subject record's review entry that names a session in its `session` field. */
16
+ export interface SessionCitation {
17
+ /** The subject record's id. */
18
+ id: string;
19
+ /** The subject record's path, from the repository root. */
20
+ path: string;
21
+ /** The entry's position in the subject's reviews list, from 0. */
22
+ index: number;
23
+ /** The reviewer as the entry writes it, or null when it names none. */
24
+ reviewer: string | null;
25
+ /** The verdict as the entry writes it, or null when it names none. */
26
+ verdict: string | null;
27
+ }
28
+ /**
29
+ * The seal of a session record: {@link recordTextDigest} with the seal field
30
+ * in place of the reviews list. That is the lowercase hex SHA-256 of the
31
+ * file's text with LF line endings and without the front-matter line that
32
+ * holds the seal, a quoted string on one line. Every other byte, the `---`
33
+ * lines and the body included, is kept.
34
+ *
35
+ * `awk 'NR==1&&/^---$/{f=1;print;next} f&&/^---$/{f=0} f&&/^closed_digest:/{next} {print}' S-0001.md | shasum -a 256`
36
+ * gives the same value for a file with LF line endings that ends in one.
37
+ * For a session kind of format json (ws-053), the seal member is removed by
38
+ * the JSON rule of {@link recordTextDigest} instead.
39
+ */
40
+ export declare function sessionSeal(text: string, field: string, format?: RecordFormat): string;
41
+ /**
42
+ * Check each session in `entries` against its seal and the subject records,
43
+ * and fill in `citedBy`. `texts` holds each entry's file text by path.
44
+ * `subjects` holds the subject records and the name of their reviews list;
45
+ * it is null when they were not read, and then no verdict is checked.
46
+ */
47
+ export declare function joinSessions(kind: RecordKind, entries: RecordEntry[], texts: Map<string, string>, subjects: {
48
+ records: RecordEntry[];
49
+ reviews: string;
50
+ } | null): void;
51
+ //# sourceMappingURL=record-sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-sessions.d.ts","sourceRoot":"","sources":["../../src/workspace/record-sessions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAEnG,mFAAmF;AACnF,MAAM,WAAW,eAAe;IAC9B,+BAA+B;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,sEAAsE;IACtE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,YAAsC,GAAG,MAAM,CAE/G;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE;IAAE,OAAO,EAAE,WAAW,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,IAAI,CAoDrK"}
@@ -10,6 +10,8 @@ export interface RecordSource {
10
10
  list(dir: string): string[] | undefined;
11
11
  /** The text of a file listed by `list`. */
12
12
  read(path: string): string;
13
+ /** The bytes of a file listed by `list`, for a content-addressed id (ws-053). */
14
+ bytes(path: string): Uint8Array;
13
15
  }
14
16
  /** Records in the working tree under `root`. */
15
17
  export declare function workingTreeSource(root: string): RecordSource;
@@ -1 +1 @@
1
- {"version":3,"file":"record-source.d.ts","sourceRoot":"","sources":["../../src/workspace/record-source.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,MAAM,WAAW,YAAY;IAC3B,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAC;IACd,kHAAkH;IAClH,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IACxC,2CAA2C;IAC3C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B;AAED,gDAAgD;AAChD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAgB5D;AAYD,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMvD;AAED,kEAAkE;AAClE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAOjE;AAED,gGAAgG;AAChG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CA+C5E"}
1
+ {"version":3,"file":"record-source.d.ts","sourceRoot":"","sources":["../../src/workspace/record-source.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,MAAM,WAAW,YAAY;IAC3B,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAC;IACd,kHAAkH;IAClH,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IACxC,2CAA2C;IAC3C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,iFAAiF;IACjF,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CACjC;AAED,gDAAgD;AAChD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAmB5D;AAYD,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMvD;AAED,kEAAkE;AAClE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAOjE;AAED,gGAAgG;AAChG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAmD5E"}
@@ -8,11 +8,19 @@
8
8
  * the exit code is 0 whenever the read itself worked. Only a kind, schema or
9
9
  * revision that cannot be read exits 1.
10
10
  *
11
- * It needs no `chant.workspace.json`. The kind is passed explicitly, so
12
- * nothing is inferred (#2525 rule 1).
11
+ * It needs no `chant.workspace.json`. The kind is passed explicitly, or,
12
+ * without `--kind`, it is every record kind the declaration names (#2680), so
13
+ * nothing is inferred (#2525 rule 1). Several kinds print one document per
14
+ * kind, in the declaration's order, inside one set.
15
+ *
16
+ * With `--since <rev>` it prints what changed between two revisions instead,
17
+ * through `records-since.ts` (#2673).
13
18
  */
14
19
  import type { CommandContext } from "../cli/registry.js";
15
- import { type LoadedRecordKind, type ReadErrorCode, type ReadRecordsResult, type RecordEntry } from "./records.js";
20
+ import { type RecordKindDeclaration } from "./declaration.js";
21
+ import { type LoadedRecordKind, type Quorum, type ReadErrorCode, type ReadRecordsResult, type RecordEntry, type RecordFormat } from "./records.js";
22
+ import { type WorkspaceTree } from "./tree.js";
23
+ import type { DecisionWork } from "./work.js";
16
24
  import { type ProvenanceLevel } from "./trust/attestor.js";
17
25
  import { type BaseSource, type RecordProvenance } from "./trust/provenance.js";
18
26
  /** The version of the `records` output this chant writes. */
@@ -30,10 +38,16 @@ export interface RecordsQuery {
30
38
  /** Where `kind` is resolved from and the repository is found. */
31
39
  cwd: string;
32
40
  }
33
- /** A record as the output carries it: the entry plus its provenance (#2547). */
41
+ /**
42
+ * A record as the output carries it: the entry plus its provenance (#2547),
43
+ * and its quorum when the kind has a reviews list (#2671).
44
+ */
34
45
  export type RecordView = RecordEntry & {
35
46
  provenance: RecordProvenance;
47
+ quorum?: Quorum | null;
36
48
  };
49
+ /** The role in the trust policy whose holders' verdicts the quorum does not count (#2671). */
50
+ export declare const AGENT_ROLE = "agent";
37
51
  /** Where provenance was judged from (#2547). */
38
52
  export interface TrustView {
39
53
  /** The full commit id the policy was read at, or null when there is no base. */
@@ -52,6 +66,7 @@ export type RecordsDocument = {
52
66
  name: string;
53
67
  schema: string;
54
68
  file: string;
69
+ format: RecordFormat;
55
70
  };
56
71
  at: string | null;
57
72
  /** The directory pinned paths resolve in, from the repository root: the workspace holding the kind file, or the repository root (#2549). */
@@ -65,6 +80,8 @@ export type RecordsDocument = {
65
80
  invalid: number;
66
81
  superseded: number;
67
82
  };
83
+ /** For a work kind (#2683): each decision its decision kind reads, with the work records implementing it. */
84
+ decisions?: DecisionWork[];
68
85
  } | {
69
86
  $schema: string;
70
87
  contract: number;
@@ -73,6 +90,41 @@ export type RecordsDocument = {
73
90
  message: string;
74
91
  };
75
92
  };
93
+ /** Where a document in a {@link RecordsSetDocument} comes from: the declaration's entry for its kind (#2680). */
94
+ export interface DeclaredKindView {
95
+ /** The member that declares the kind, or null for the workspace's own. */
96
+ member: string | null;
97
+ /** The kind file from the workspace root. */
98
+ path: string;
99
+ /** The name the declaration gives the kind, or null. */
100
+ name: string | null;
101
+ }
102
+ /**
103
+ * The `records` output without `--kind` when the declaration names record
104
+ * kinds (#2680): one {@link RecordsDocument} per kind, in the declaration's
105
+ * order, each with the entry that declares it.
106
+ */
107
+ export interface RecordsSetDocument {
108
+ $schema: string;
109
+ contract: number;
110
+ kinds: (RecordsDocument & {
111
+ declared: DeclaredKindView;
112
+ })[];
113
+ }
114
+ /**
115
+ * The record kinds the declaration nearest above `cwd` names, in the tree
116
+ * `at` reads, with each kind file on disk. Empty when there is no declaration.
117
+ * Throws a {@link WorkspaceReadError} for one that can't be read.
118
+ */
119
+ export declare function declaredKindFiles(cwd: string, at?: string): {
120
+ declared: RecordKindDeclaration;
121
+ file: string;
122
+ }[];
123
+ /** Read every declared kind in `kinds`, as {@link queryRecords} reads one. */
124
+ export declare function queryDeclaredRecords(kinds: {
125
+ declared: RecordKindDeclaration;
126
+ file: string;
127
+ }[], query: Omit<RecordsQuery, "kind">): Promise<RecordsSetDocument>;
76
128
  /** A records read, before provenance. */
77
129
  export interface RecordsRead {
78
130
  loaded: LoadedRecordKind;
@@ -83,8 +135,16 @@ export interface RecordsRead {
83
135
  at: string | null;
84
136
  /** Where pinned paths resolve, relative to `root` ("." for the root itself). */
85
137
  workspaceRoot: string;
138
+ /** The workspace root's tree, as read: the working tree, or the revision under `--at`. */
139
+ tree: WorkspaceTree;
86
140
  result: ReadRecordsResult;
87
141
  }
142
+ /**
143
+ * Where a kind's pinned paths resolve: the workspace whose declaration sits
144
+ * nearest above the kind file, when it is inside the repository, or else the
145
+ * repository root. Relative to `root`, with / separators.
146
+ */
147
+ export declare function pinRoot(kindFile: string, root: string): string;
88
148
  /**
89
149
  * Load the kind and read its records, in the working tree or at `query.at`,
90
150
  * with each pin checked in the same tree. Throws a {@link RecordReadError}.
@@ -105,6 +165,7 @@ export declare function pinFile(file: string, cwd: string): {
105
165
  error: string;
106
166
  };
107
167
  export declare function runWorkspaceRecords(ctx: CommandContext): Promise<number>;
168
+ export declare function realpathOr(dir: string): string;
108
169
  /** Records whose provenance falls below `required`. Only `attested` can be required. */
109
170
  export declare function belowRequired(records: RecordView[], required: ProvenanceLevel): RecordView[];
110
171
  /** `chant workspace <anything else>`. */
@@ -1 +1 @@
1
- {"version":3,"file":"records-cli.d.ts","sourceRoot":"","sources":["../../src/workspace/records-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAItD,OAAO,EAAgD,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,KAAK,WAAW,EAAsB,MAAM,WAAW,CAAC;AAElL,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAA+C,KAAK,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEzH,6DAA6D;AAC7D,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,kFAAkF;AAClF,eAAO,MAAM,wBAAwB,gFAAgF,CAAC;AAItH,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,2FAA2F;IAC3F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,GAAG,EAAE,MAAM,CAAC;CACb;AAED,gFAAgF;AAChF,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG;IAAE,UAAU,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAExE,gDAAgD;AAChD,MAAM,WAAW,SAAS;IACxB,gFAAgF;IAChF,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAC;IAC5B,uFAAuF;IACvF,MAAM,EAAE,OAAO,CAAC;IAChB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AAC,MAAM,CAAC,CAS9E"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * `chant workspace records --kind <kind file> --since <rev> [--at <rev>]
3
+ * [--json]` (#2673, #2650 C11): what changed in a kind's records between two
4
+ * revisions. It reads the records at `<rev>` and at `--at` (the working tree
5
+ * without it), through the same reader as `records`, and lists new and
6
+ * removed records, state transitions, new verdicts, new supersessions and
7
+ * changed pins. Between a review session's open and close commits, that is
8
+ * what the session did.
9
+ *
10
+ * Records are matched by id. A record whose id could not be read is left
11
+ * out of the comparison, since nothing says which record it was before.
12
+ */
13
+ import { type RecordEntry, type RecordKind } from "./records.js";
14
+ /** `$id` of the JSON Schema for `records --since --json`, shipped beside this file. */
15
+ export declare const RECORDS_SINCE_OUTPUT_SCHEMA_ID = "https://intentius.io/chant/schemas/workspace/records-since/v1/records-since.schema.json";
16
+ /** Why a `--since` read failed: any records read error, or a `--since` that names no commit. Closed. */
17
+ export declare const RECORDS_SINCE_ERROR_CODES: readonly ["kind-unreadable", "kind-invalid", "schema-unreadable", "schema-id-mismatch", "schema-invalid", "location-missing", "not-a-git-repository", "revision-unknown", "since-rev-unknown"];
18
+ export type RecordsSinceErrorCode = (typeof RECORDS_SINCE_ERROR_CODES)[number];
19
+ /** The kinds of change, in the order the output lists them. */
20
+ export declare const SINCE_CHANGE_KINDS: readonly ["new", "removed", "state", "verdict", "supersession", "pin"];
21
+ export type SinceChangeKind = (typeof SINCE_CHANGE_KINDS)[number];
22
+ export type SinceChange = {
23
+ change: "new";
24
+ id: string;
25
+ path: string;
26
+ state: string | null;
27
+ } | {
28
+ change: "removed";
29
+ id: string;
30
+ path: string;
31
+ state: string | null;
32
+ } | {
33
+ change: "state";
34
+ id: string;
35
+ from: string | null;
36
+ to: string | null;
37
+ } | {
38
+ change: "verdict";
39
+ id: string;
40
+ principal: string | null;
41
+ verdict: string | null;
42
+ index: number;
43
+ record?: string;
44
+ session?: string;
45
+ } | {
46
+ change: "supersession";
47
+ id: string;
48
+ supersedes: string;
49
+ } | {
50
+ change: "pin";
51
+ id: string;
52
+ path: string;
53
+ from: string | null;
54
+ to: string | null;
55
+ };
56
+ export type RecordsSinceDocument = {
57
+ $schema: string;
58
+ contract: number;
59
+ kind: {
60
+ name: string;
61
+ schema: string;
62
+ file: string;
63
+ };
64
+ since: string;
65
+ at: string | null;
66
+ changes: SinceChange[];
67
+ summary: Record<SinceChangeKind, number>;
68
+ } | {
69
+ $schema: string;
70
+ contract: number;
71
+ error: {
72
+ code: RecordsSinceErrorCode;
73
+ message: string;
74
+ };
75
+ };
76
+ export interface RecordsSinceQuery {
77
+ kind: string;
78
+ since: string;
79
+ at?: string;
80
+ cwd: string;
81
+ }
82
+ /** Run the comparison and build the document `--json` prints. Never throws a read error. */
83
+ export declare function queryRecordsSince(query: RecordsSinceQuery): Promise<RecordsSinceDocument>;
84
+ /** What changed from `before` to `after`, in the order of {@link SINCE_CHANGE_KINDS} and then by id. */
85
+ export declare function compareRecords(kind: RecordKind, before: RecordEntry[], after: RecordEntry[]): SinceChange[];
86
+ /** The text form: one line per change and a summary. */
87
+ export declare function formatSince(doc: Extract<RecordsSinceDocument, {
88
+ changes: SinceChange[];
89
+ }>): string;
90
+ //# sourceMappingURL=records-since.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records-since.d.ts","sourceRoot":"","sources":["../../src/workspace/records-since.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,EAAgF,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAI5I,uFAAuF;AACvF,eAAO,MAAM,8BAA8B,4FAA4F,CAAC;AAExI,wGAAwG;AACxG,eAAO,MAAM,yBAAyB,gMAII,CAAC;AAC3C,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/E,+DAA+D;AAC/D,eAAO,MAAM,kBAAkB,wEAAyE,CAAC;AACzG,MAAM,MAAM,eAAe,GA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,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;CAC1C,GACD;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE;QAAE,IAAI,EAAE,qBAAqB,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEnG,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAWD,4FAA4F;AAC5F,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAiC/F;AAyED,wGAAwG;AACxG,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAkD3G;AAED,wDAAwD;AACxD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,oBAAoB,EAAE;IAAE,OAAO,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,GAAG,MAAM,CAsBlG"}
@@ -0,0 +1,164 @@
1
+ /**
2
+ * `chant workspace records new|amend|review` (#2670): the commands a UI
3
+ * writes records through, so it never parses or writes a record file itself
4
+ * (ws-052).
5
+ *
6
+ * Each command loads the kind, reads every record it locates, builds the one
7
+ * file it would write, and reads the records again with that file in place,
8
+ * through the same {@link readRecords} a read uses. The write goes ahead only
9
+ * when the written record comes back valid and no other record gains a
10
+ * reason. So a write is refused for exactly what a later read would report,
11
+ * plus the rules only a write has: ids are allocated and never reused, a
12
+ * closed record never changes, an approved one changes only in place of
13
+ * what the approval rule allows, and a dissent needs a note.
14
+ *
15
+ * Every command writes one file or none, never commits, and prints one JSON
16
+ * document with a closed error code on refusal. `--dry-run` prints the
17
+ * document and the text it would write, and writes nothing.
18
+ */
19
+ import type { CommandContext } from "../cli/registry.js";
20
+ import { type RecordEntry, type RecordWarning } from "./records.js";
21
+ /** The version of the write documents this chant prints. */
22
+ export declare const RECORDS_WRITE_CONTRACT_VERSION = 1;
23
+ export declare const RECORDS_NEW_SCHEMA_ID = "https://intentius.io/chant/schemas/workspace/records-new/v1/records-new.schema.json";
24
+ export declare const RECORDS_AMEND_SCHEMA_ID = "https://intentius.io/chant/schemas/workspace/records-amend/v1/records-amend.schema.json";
25
+ export declare const RECORDS_REVIEW_SCHEMA_ID = "https://intentius.io/chant/schemas/workspace/records-review/v1/records-review.schema.json";
26
+ /** Why `records new` wrote nothing. Closed: a reader may switch on it. */
27
+ export declare const NEW_ERROR_CODES: readonly ["kind-unreadable", "kind-invalid", "schema-unreadable", "schema-id-mismatch", "schema-invalid", "location-missing", "write-usage-invalid", "write-input-invalid", "record-id-taken", "record-id-unallocatable", "record-path-unmatched", "record-unparseable", "record-schema-invalid", "record-id-duplicate", "record-supersedes-unknown", "record-supersedes-conflict", "session-seal-mismatch", "session-verdict-unknown-record"];
28
+ /** Why `records amend` wrote nothing. */
29
+ export declare const AMEND_ERROR_CODES: readonly ["kind-unreadable", "kind-invalid", "schema-unreadable", "schema-id-mismatch", "schema-invalid", "location-missing", "write-usage-invalid", "write-input-invalid", "record-not-found", "amend-id-immutable", "record-closed", "amend-supersede-instead", "record-unparseable", "record-schema-invalid", "record-id-duplicate", "record-supersedes-unknown", "record-supersedes-conflict", "session-seal-mismatch", "session-verdict-unknown-record"];
30
+ /** Why `records review` wrote nothing. */
31
+ export declare const REVIEW_ERROR_CODES: readonly ["kind-unreadable", "kind-invalid", "schema-unreadable", "schema-id-mismatch", "schema-invalid", "location-missing", "write-usage-invalid", "record-not-found", "review-unsupported", "record-closed", "review-note-required", "record-unparseable", "record-schema-invalid", "record-id-duplicate", "record-supersedes-unknown", "record-supersedes-conflict", "session-seal-mismatch", "session-verdict-unknown-record"];
32
+ export type NewErrorCode = (typeof NEW_ERROR_CODES)[number];
33
+ export type AmendErrorCode = (typeof AMEND_ERROR_CODES)[number];
34
+ export type ReviewErrorCode = (typeof REVIEW_ERROR_CODES)[number];
35
+ export declare const VERDICTS: readonly ["agree", "dissent", "abstain"];
36
+ export type Verdict = (typeof VERDICTS)[number];
37
+ interface KindView {
38
+ name: string;
39
+ schema: string;
40
+ file: string;
41
+ }
42
+ /** What every write result carries. */
43
+ interface WriteResult {
44
+ $schema: string;
45
+ contract: number;
46
+ kind: KindView;
47
+ /** The record file, from the repository root (the working directory outside git), with / separators. */
48
+ path: string;
49
+ id: string;
50
+ /** True when nothing was written. */
51
+ dryRun: boolean;
52
+ /** The written record's warnings, as `records` would report them. */
53
+ warnings: RecordWarning[];
54
+ /** With --dry-run, the whole text the command would write. */
55
+ text?: string;
56
+ }
57
+ interface WriteFailure<C> {
58
+ $schema: string;
59
+ contract: number;
60
+ error: {
61
+ code: C;
62
+ message: string;
63
+ };
64
+ }
65
+ export type NewDocument = WriteResult | WriteFailure<NewErrorCode>;
66
+ export type AmendDocument = (WriteResult & {
67
+ changed: string[];
68
+ }) | WriteFailure<AmendErrorCode>;
69
+ export type ReviewDocument = (WriteResult & {
70
+ review: Record<string, unknown>;
71
+ }) | WriteFailure<ReviewErrorCode>;
72
+ /**
73
+ * YAML limited to what JSON can say, laid out as the decision README writes a
74
+ * record: every string double-quoted with JSON escapes, block mappings and
75
+ * sequences, and `[]` or `{}` for an empty one. `parseFrontMatter` reads it
76
+ * back to the same value.
77
+ */
78
+ export declare function toYaml(value: unknown, indent?: number): string;
79
+ /** A record file: the front matter, then `body` as it is. */
80
+ export declare function renderRecord(data: Record<string, unknown>, body: string): string;
81
+ /**
82
+ * `text` with the top-level fields in `set` replaced in place, and every
83
+ * other byte kept. A field's block is its key line at column 0 and the lines
84
+ * after it, up to the closing `---`, that start with a space, a tab, `#` or
85
+ * `-`: the block {@link recordTextDigest} cuts for the reviews field. Blank
86
+ * lines ending a block stay where they are. A field the front matter lacks is
87
+ * added before the closing `---`. Line endings become LF. Returns undefined
88
+ * when the text has no front matter, or when the result does not read back
89
+ * as `expected`, so a caller never writes a file it did not mean to.
90
+ */
91
+ export declare function replaceFields(text: string, set: Record<string, unknown>, expected: Record<string, unknown>): string | undefined;
92
+ /** A file-name slug from a title, as `scripts/import-decisions.mjs` makes one. */
93
+ export declare function slug(title: string): string;
94
+ /**
95
+ * The next id: `<prefix>-<n>`, one above the highest number any record in the
96
+ * directory has with that prefix, padded to at least three digits, or to the
97
+ * widest number those records use. Ids come from the records' own id field
98
+ * and, for a file that can't be read, from its name, so an id in use is never
99
+ * handed out again. The shape is derived from the records, with the prefix's
100
+ * case kept: a work kind's `W-001` and `W-002` give `W-003` (#2683), and a
101
+ * decision's `ws-052` gives `ws-053`. The kind's schema still judges the id
102
+ * written. Without `prefix`, every record must share one prefix.
103
+ */
104
+ export declare function allocateId(entries: RecordEntry[], prefix: string | undefined, kind: string): string;
105
+ export interface NewRecordOptions {
106
+ /** The kind file, resolved against `cwd`. */
107
+ kind: string;
108
+ /** The record's fields, as JSON text. */
109
+ fields: string;
110
+ /** The id prefix to allocate under, when the fields hold no id. */
111
+ prefix?: string;
112
+ dryRun?: boolean;
113
+ cwd: string;
114
+ }
115
+ /** `records new`: write one new record from validated fields. */
116
+ export declare function newRecord(opts: NewRecordOptions): Promise<NewDocument>;
117
+ export interface AmendRecordOptions {
118
+ kind: string;
119
+ id: string;
120
+ /** The fields to set, as JSON text. Each replaces the whole top-level field. */
121
+ fields: string;
122
+ dryRun?: boolean;
123
+ cwd: string;
124
+ }
125
+ /**
126
+ * `records amend`: set top-level fields of one record. A record in a closed
127
+ * state never changes. With approval ranks, a record ranked above 0 (such as
128
+ * a decided decision) changes in place only in its state, to one ranked at
129
+ * least as high, its pins field and its reviews: anything else is a new
130
+ * decision, written as a record that supersedes it (#2524 D4).
131
+ */
132
+ export declare function amendRecord(opts: AmendRecordOptions): Promise<AmendDocument>;
133
+ export interface ReviewRecordOptions {
134
+ kind: string;
135
+ id: string;
136
+ verdict: string;
137
+ /** The reviewer, as the caller names them. chant does not check who it is; attestation does (#2547). */
138
+ by: string;
139
+ note?: string;
140
+ /** The review session the verdict was given in. */
141
+ session?: string;
142
+ dryRun?: boolean;
143
+ cwd: string;
144
+ /** The date written as `on`, YYYY-MM-DD. Defaults to today, in UTC. */
145
+ on?: string;
146
+ }
147
+ /**
148
+ * `records review`: append one verdict to a record's reviews, with the date
149
+ * and the digest of the record text it judged ({@link recordTextDigest}).
150
+ */
151
+ export declare function reviewRecord(opts: ReviewRecordOptions): Promise<ReviewDocument>;
152
+ export declare const WRITE_USAGE: string;
153
+ /**
154
+ * The kind file a write names: `arg` itself when it is a file, or else the
155
+ * declared record kind it names (#2683), by the name the declaration gives it
156
+ * or its file's name without `.kind.mjs`, so `records new work` finds
157
+ * `work/work.kind.mjs`. Anything else is returned as given, and loading it
158
+ * fails with kind-unreadable.
159
+ */
160
+ export declare function resolveWriteKind(arg: string, cwd: string): string;
161
+ /** `chant workspace records new|amend|review`. Prints one JSON document; exits 0 when it wrote, or would have with --dry-run. */
162
+ export declare function runRecordsWrite(ctx: CommandContext): Promise<number>;
163
+ export {};
164
+ //# sourceMappingURL=records-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records-write.d.ts","sourceRoot":"","sources":["../../src/workspace/records-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EAQL,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AAOnB,4DAA4D;AAC5D,eAAO,MAAM,8BAA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