@maycombhq/sdk 2.0.0-beta.10 → 2.0.0-beta.12

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.
@@ -0,0 +1,180 @@
1
+ import type { FactEnd, FactsJoinResult, JoinRepo } from "./facts-join.js";
2
+ import type { TermsResult, TermSeen } from "./facts-terms.js";
3
+ import type { Conventions } from "./schema/conventions.js";
4
+ import type { QuestionDraft } from "./schema/question.js";
5
+ import type { RepoType } from "./schema/repo-type.js";
6
+ import type { ChecklistRule } from "./schema/review.js";
7
+ /**
8
+ * Org notes (ADR 0163): what the organisation's terms mean in a kind of repo, and what must hold
9
+ * there, in its own words. Atticus never parses a note: it hands the notes of a repo's type, and
10
+ * the org-wide ones, to the assistant as data, numbered, and the assistant cites the one a term
11
+ * fact relies on. Everything that follows from them here is deterministic: the notes a read is
12
+ * given, the rule drafts offered for a person to review, the check an accepted rule runs, and the
13
+ * question an unknown term becomes.
14
+ */
15
+ /** A note as a read is handed it: its number (from 1), its key, its words and where it is written. */
16
+ export interface NumberedNote {
17
+ n: number;
18
+ /**
19
+ * A short hash of its words (`noteKey`): what a term fact's `note` and a rule draft's id name,
20
+ * so reordering the notes points nothing at another note, and a changed note is told apart.
21
+ */
22
+ key: string;
23
+ text: string;
24
+ /** `repo-types/<type>/type.yaml` or `conventions.yaml`, relative to the org pack. */
25
+ source: string;
26
+ /** The note's place in that file's `notes`, from 0. */
27
+ index: number;
28
+ }
29
+ /** A note's key: 8 hex digits of the sha256 of its words, spacing and letter case aside. */
30
+ export declare const noteKey: (text: string) => string;
31
+ /**
32
+ * The notes a read of a repo is handed: its repo type's first, then the org-wide ones, numbered
33
+ * from 1 in that order. Empty when neither has any, which is how a read without notes goes.
34
+ */
35
+ export declare function notesFor(type: Pick<RepoType, "id" | "notes"> | undefined, conventions: Pick<Conventions, "notes"> | undefined): NumberedNote[];
36
+ /**
37
+ * The notes as the prompt gives them (review 6): one data block, each note one line, its number,
38
+ * its key and its words JSON-quoted, after the sentence that they are data, never instructions.
39
+ */
40
+ export declare function notesText(notes: readonly NumberedNote[], repoType?: string): string;
41
+ /** The fewest words a term fact quotes a note by: fewer could be found in any note. */
42
+ export declare const NOTE_QUOTE_WORDS = 4;
43
+ /**
44
+ * Whether a term fact's `note` is one of the notes the read was given: a key one of them has, or
45
+ * at least four words found in one of them (spacing and letter case aside). Undefined when it is.
46
+ * `term-note-stale`: a key none of them has now, the note having been changed or removed since
47
+ * the read, so the term is read again by the notes as they are.
48
+ */
49
+ export declare function noteProblem(note: string, notes: readonly NumberedNote[]): {
50
+ code: "term-meaning" | "term-note-stale";
51
+ message: string;
52
+ } | undefined;
53
+ /** A note reads as a rule when it says all, every or must. A draft only: a person decides. */
54
+ export declare const RULE_WORDS: RegExp;
55
+ /** The deterministic check a call rule runs (ADR 0163). */
56
+ export declare const CALL_SECURITY_CHECK = "call-security";
57
+ /** What a person says is done outside the repos, for a call the check would find. */
58
+ export interface DeclaredOutside {
59
+ repo: string;
60
+ /** The call's fact id; left out, every call of the repo the rule covers. */
61
+ call?: string;
62
+ why: string;
63
+ by: string;
64
+ }
65
+ /** The params of a `call-security` rule, as a person sets them. */
66
+ export interface CallSecurityParams {
67
+ /**
68
+ * The calls it covers: those to a system the profile gives boundary `vendor` (`vendor`), those
69
+ * to any system outside the estate, another team's included (`outside`), or every call.
70
+ */
71
+ to: "vendor" | "outside" | "any";
72
+ /** The transport security the call that reaches the target must show. */
73
+ tls?: "mtls" | "tls";
74
+ /** Whether an auth must be shown on the call that reaches the target. */
75
+ auth?: boolean;
76
+ /** What a person says is done outside the repos: recorded as their word, never verified. */
77
+ declared?: DeclaredOutside[];
78
+ }
79
+ /** A rule's params read as `call-security` params, or why they can't be. */
80
+ export declare function callSecurityParams(params: Record<string, unknown>): CallSecurityParams | {
81
+ problem: string;
82
+ };
83
+ /**
84
+ * A checklist rule draft (C3, `status: draft`) for each note that reads as a rule, for a person
85
+ * to review and accept in a pull request. A note about calls and mTLS, TLS or auth is drafted as
86
+ * the deterministic `call-security` check with its params filled from the words it uses; any
87
+ * other as an AI check that quotes the note. The words only fill a draft: a person sets what the
88
+ * accepted rule checks, and the check itself reads facts, never the note.
89
+ */
90
+ export declare function noteRuleDrafts(notes: readonly NumberedNote[]): ChecklistRule[];
91
+ /** What a call shows, and the line each rests on. */
92
+ interface Shown {
93
+ tls?: {
94
+ value: string;
95
+ at: string;
96
+ };
97
+ auth?: {
98
+ value: string;
99
+ at: string;
100
+ };
101
+ }
102
+ export interface CallSecurityResult {
103
+ /** The call the rule judges: the one that reaches the target (a gateway's forwarding call, or a service's own). */
104
+ call: FactEnd;
105
+ /** The gateway route it forwards from, when it does, then the call itself. */
106
+ chain: FactEnd[];
107
+ /** The calls of other repos that land on that route: the legs in front, never judged. */
108
+ callers: FactEnd[];
109
+ target?: string;
110
+ outcome: "pass" | "finding" | "declared";
111
+ /** What the call shows, cited. */
112
+ shown: Shown;
113
+ /** For a finding: what it doesn't show. */
114
+ missing?: ("tls" | "auth")[];
115
+ /** What its code cites as none, for what the rule asks: a finding no person's word covers. */
116
+ none?: Shown;
117
+ /** For a declared one: the person's word, never verified. */
118
+ declared?: DeclaredOutside;
119
+ message: string;
120
+ }
121
+ /** A system of the profiles, as `checkCallSecurity` tells a vendor from another team's system. */
122
+ export interface CallSecuritySystem {
123
+ id: string;
124
+ name?: string;
125
+ boundary: string;
126
+ aliases?: readonly string[];
127
+ }
128
+ /**
129
+ * Every call a `call-security` rule covers, checked on the facts (ADR 0163, review 5): for
130
+ * `to: vendor`, each call the join leaves to a system the profiles give boundary `vendor`; for
131
+ * `to: outside`, each it leaves outside the estate (another team's system too); for `to: any`,
132
+ * every call. The leg judged is the one that reaches the target: the call itself, which for a
133
+ * gateway is its forwarding call. The legs in front of it (a caller's mTLS to the gateway, the
134
+ * route's own client-certificate check) are listed in `callers` and `chain`, never counted. It
135
+ * passes when the call shows the TLS asked for (`tls` with its `tlsCite`) and, if asked, an auth
136
+ * other than none (`auth` with its `authCite`); otherwise it is a finding for the call's repo.
137
+ * A person's word that it is done outside the repos is recorded as declared, theirs, never
138
+ * verified, except where the call's code cites `none` for what is asked: the code is right.
139
+ */
140
+ export declare function checkCallSecurity(params: CallSecurityParams, input: {
141
+ repos: readonly JoinRepo[];
142
+ join: FactsJoinResult;
143
+ /** The profiles' systems, for each outside target's boundary. */
144
+ systems?: readonly CallSecuritySystem[];
145
+ }): CallSecurityResult[];
146
+ /** The step a term question is asked by. */
147
+ export declare const TERM_STEP = "term-meaning";
148
+ export interface TermQuestionDraft {
149
+ draft: QuestionDraft;
150
+ /** The repo the question is raised for (the group's first, by id). */
151
+ repo: string;
152
+ term: string;
153
+ file: string;
154
+ repoType?: string;
155
+ /** Every term fact the answer is about, by repo. */
156
+ terms: TermSeen[];
157
+ }
158
+ /**
159
+ * One question per term, file and repo type for the terms whose role is unknown (ADR 0163):
160
+ * "What does `cmdb` mean in userAccess.json across 3 forge-apigee-proxy repos?". The answer is
161
+ * meant to be saved as a note on the repo type (`atticus repo-type note`), so the next read of
162
+ * every repo of the type records the role, cited. A repo with no type is asked on its own.
163
+ */
164
+ export declare function termQuestionDrafts(result: Pick<TermsResult, "terms">, typeOf: (repo: string) => string | undefined): TermQuestionDraft[];
165
+ /**
166
+ * The note an answered term question offers to save on its repo type: the person's own words,
167
+ * or the option they picked put as a plain sentence about the term and the file.
168
+ */
169
+ export declare function termAnswerNote(o: {
170
+ term: string;
171
+ file: string;
172
+ option?: "owner" | "consumer" | "none";
173
+ text?: string;
174
+ }): string;
175
+ /** The term and file a term question asks about, read back from its words. */
176
+ export declare function termOfQuestion(question: string): {
177
+ term: string;
178
+ file: string;
179
+ } | undefined;
180
+ export {};
@@ -139,7 +139,7 @@ export declare const DEFAULT_RUNTIME: {
139
139
  } | undefined;
140
140
  };
141
141
  export declare const DEFAULT_SOURCES: {
142
- schemaVersion: 3 | 1 | 2;
142
+ schemaVersion: 1 | 2 | 3;
143
143
  layout: {
144
144
  openspec: string;
145
145
  catalog: string;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * profile.yaml version 1 → 2 (ADR 0162 amendment). Version 2 adds a system's `topics`; a file
3
+ * without them names no topic, as version 1 did, so the step writes the new number only and keeps
4
+ * the file's comments, order and line layout. Nothing is moved from `aliases` to `topics`: which
5
+ * alias is a topic is a person's call. A version-1 profile stays valid, so `atticus upgrade` has no
6
+ * step for it; `addProfileSystem` applies this when it writes a topic.
7
+ */
8
+ export declare function migrateProfileText(text: string): {
9
+ text: string;
10
+ changed: boolean;
11
+ };
@@ -154,6 +154,14 @@ export interface RaiseOptions {
154
154
  hold?: (q: Question, answered: Question[]) => boolean;
155
155
  /** Where judgments are kept; default the metarepo's judgments/. */
156
156
  judgments?: JudgmentStore;
157
+ /**
158
+ * Beta.12: an open, unanswered question on file by the draft's id, that this step asked, gets
159
+ * the draft's options and words in place (the same id, its history kept), so what a step
160
+ * offers now (ranked suggestions, their reasons, a repo read since) reaches a question asked
161
+ * before. Returned in `refreshed` (and `known`). An answered or retired question is never
162
+ * touched.
163
+ */
164
+ refresh?: boolean;
157
165
  }
158
166
  /** A question held back: the one it would have been, and the answered ones that may decide it. */
159
167
  export interface HeldQuestion {
@@ -178,7 +186,8 @@ export declare function sameTarget(a: {
178
186
  }, repo?: string): boolean;
179
187
  /**
180
188
  * Write the questions a step raised (ADR 0078, 0089, 0117). One already on file by its id is
181
- * left as it is and returned in `known`. Otherwise it is weighed against the questions on file
189
+ * left as it is and returned in `known` (with `refresh`, an open one this step asked takes the
190
+ * draft's options and words first). Otherwise it is weighed against the questions on file
182
191
  * for the same repo:
183
192
  * 1. the veto: the two name different ids, fields or numbers, so they differ;
184
193
  * 2. the step's own reading (`sameAs`), when the id is a candidate and its words are in it;
@@ -198,6 +207,8 @@ export declare function raiseQuestions(root: string, drafts: QuestionDraft[], by
198
207
  held: HeldQuestion[];
199
208
  /** The answered questions whose answer decides a draft, by the draft's index (ADR 0117 addendum). */
200
209
  decidedBy: Map<number, Question>;
210
+ /** With `refresh`: open questions on file that took the draft's options and words. */
211
+ refreshed: Question[];
201
212
  }>;
202
213
  /**
203
214
  * Rewrite questions/<id>.yaml files written at an older question schema version (1, ADR 0078;
@@ -226,6 +237,15 @@ export declare function retireQuestion(root: string, id: string, o: {
226
237
  replacedBy?: string[];
227
238
  at: string;
228
239
  }): Promise<Question>;
240
+ /**
241
+ * ADR 0162 (F8): open an answered targets question again, because the code read since disagrees
242
+ * with its answer (the repo it named has no route that serves the call). The answer it had is
243
+ * kept under `reopened` with why, so the person sees what they said and what the code says.
244
+ */
245
+ export declare function reopenQuestion(root: string, id: string, o: {
246
+ why: string;
247
+ at: string;
248
+ }): Promise<Question>;
229
249
  export declare function answerWords(q: Question): string | undefined;
230
250
  /**
231
251
  * An answer as a step's next prompt gives it (B-run2-fixes 8): the option picked with what it
@@ -251,6 +271,12 @@ export interface AnswerInput {
251
271
  match?: string;
252
272
  /** ADR 0153 (Q5): the assistant's proposal this answer accepts (acceptProposal sets it). */
253
273
  proposal?: NonNullable<Question["answer"]>["proposal"];
274
+ /**
275
+ * Review item 14: a file change the answer brings (a system written into the profile, ADR
276
+ * 0162), made only once the answer is checked and just before it is written. When it throws,
277
+ * nothing is answered (a `bad-answer` with its first line).
278
+ */
279
+ beforeWrite?: () => Promise<void>;
254
280
  by: string;
255
281
  at: string;
256
282
  }
@@ -3,15 +3,15 @@ import { SCHEMA_VERSION } from "./version.js";
3
3
  /** Current catalog schema version (defined in ./version.js, which loads no schema). */
4
4
  export { SCHEMA_VERSION };
5
5
  /** Every catalog schema version a reader accepts, oldest first. */
6
- export declare const SUPPORTED_SCHEMA_VERSIONS: readonly [1, 2, 3];
6
+ export declare const SUPPORTED_SCHEMA_VERSIONS: readonly [1, 2, 3, 4];
7
7
  /**
8
- * A record's schema version. Version-1 and version-2 files differ from version 3 only in this
9
- * number (nothing they hold changed meaning), so they are read as they are and come back as
10
- * version 3 in memory; writers always write the current version, and `migrateCatalog` rewrites
11
- * old files. The type stays `1 | 2 | 3` so code that builds older records in memory keeps
12
- * compiling until it is updated.
8
+ * A record's schema version. Version-1, -2 and -3 files differ from version 4 only in this
9
+ * number (nothing they hold changed meaning: version 4, ADR 0164, only added `protobuf` to a
10
+ * Schema's formats), so they are read as they are and come back as version 4 in memory; writers
11
+ * always write the current version, and `migrateCatalog` rewrites old files. The type stays
12
+ * `1 | 2 | 3 | 4` so code that builds older records in memory keeps compiling until it is updated.
13
13
  */
14
- export declare const SchemaVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
14
+ export declare const SchemaVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
15
15
  /**
16
16
  * Stable record id. Lowercase slug, safe as a file name on Linux, macOS and Windows
17
17
  * (no ":" or "/"), so every record can live in its own file named by its id.
@@ -85,7 +85,7 @@ export declare const IsoDate: z.ZodISODate;
85
85
  export declare const IsoDateTime: z.ZodISODateTime;
86
86
  /** Fields every record carries. `kind` is added per record type. */
87
87
  export declare const commonFields: {
88
- schemaVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
88
+ schemaVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
89
89
  id: z.ZodString;
90
90
  status: z.ZodEnum<{
91
91
  current: "current";
@@ -6,7 +6,11 @@ import { z } from "zod";
6
6
  * Every key is optional; a key given replaces its default list whole (it doesn't add to it), so
7
7
  * an organisation can take a word out as well as put one in.
8
8
  */
9
- export declare const CONVENTIONS_SCHEMA_VERSION: 1;
9
+ /**
10
+ * Version 2 (ADR 0163) adds `notes`, the organisation-wide notes every read is handed beside its
11
+ * repo type's. A version-1 file reads as it is and comes back as version 2 in memory.
12
+ */
13
+ export declare const CONVENTIONS_SCHEMA_VERSION: 2;
10
14
  /** The folders an API spec is kept in, as a gateway's repo keeps its proxy's spec. */
11
15
  export declare const DEFAULT_API_SPEC_FOLDERS: readonly ["oas", "openapi", "swagger", "asyncapi", "api-spec", "api-specs", "apispec", "apispecs"];
12
16
  /** The folders of a gateway's proxy bundles: an entry under one is a gateway route, whatever the repo. */
@@ -38,7 +42,7 @@ export declare const ConventionFramework: z.ZodObject<{
38
42
  }, z.core.$strict>;
39
43
  export type ConventionFramework = z.infer<typeof ConventionFramework>;
40
44
  export declare const Conventions: z.ZodObject<{
41
- schemaVersion: z.ZodLiteral<1>;
45
+ schemaVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
42
46
  apiSpecFolders: z.ZodDefault<z.ZodArray<z.ZodString>>;
43
47
  gatewayBundleFolders: z.ZodDefault<z.ZodArray<z.ZodString>>;
44
48
  facing: z.ZodDefault<z.ZodObject<{
@@ -59,6 +63,7 @@ export declare const Conventions: z.ZodObject<{
59
63
  notProductFolders: z.ZodDefault<z.ZodArray<z.ZodString>>;
60
64
  notReadFolders: z.ZodDefault<z.ZodArray<z.ZodString>>;
61
65
  housePrefixes: z.ZodDefault<z.ZodArray<z.ZodString>>;
66
+ notes: z.ZodOptional<z.ZodArray<z.ZodString>>;
62
67
  }, z.core.$strict>;
63
68
  export type Conventions = z.infer<typeof Conventions>;
64
69
  /** The conventions of a pack without conventions.yaml: the built-in lists. */
@@ -21,6 +21,7 @@ export declare const FactCorrection: z.ZodObject<{
21
21
  kind: z.ZodEnum<{
22
22
  config: "config";
23
23
  field: "field";
24
+ term: "term";
24
25
  framework: "framework";
25
26
  entry: "entry";
26
27
  store: "store";