@maycombhq/sdk 2.0.0-beta.1 → 2.0.0-beta.10
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.
- package/{dist → npm}/cache.d.ts +1 -1
- package/npm/core/api.d.ts +7462 -0
- package/npm/core/assistant-actor.d.ts +15 -0
- package/npm/core/audit.d.ts +153 -0
- package/npm/core/branches.d.ts +21 -0
- package/npm/core/cancel.d.ts +9 -0
- package/npm/core/catalog.d.ts +4733 -0
- package/npm/core/change-types-migrate.d.ts +10 -0
- package/npm/core/cite.d.ts +54 -0
- package/npm/core/curated.d.ts +37 -0
- package/npm/core/fact-paths.d.ts +14 -0
- package/npm/core/facts-callers.d.ts +152 -0
- package/npm/core/facts-carry.d.ts +36 -0
- package/npm/core/facts-join-prototype.d.ts +234 -0
- package/npm/core/facts-join-vendor.d.ts +110 -0
- package/npm/core/facts-join.d.ts +482 -0
- package/npm/core/facts.d.ts +94 -0
- package/npm/core/fs.d.ts +47 -0
- package/npm/core/gates-migrate.d.ts +10 -0
- package/npm/core/host-questions.d.ts +66 -0
- package/npm/core/identity.d.ts +17 -0
- package/npm/core/index.d.ts +73 -0
- package/npm/core/json-schema.d.ts +20 -0
- package/npm/core/judgments.d.ts +63 -0
- package/npm/core/light.d.ts +8 -0
- package/npm/core/link-evidence.d.ts +212 -0
- package/npm/core/log.d.ts +49 -0
- package/npm/core/manifest-edit.d.ts +57 -0
- package/npm/core/merge.d.ts +78 -0
- package/npm/core/metarepo.d.ts +91 -0
- package/npm/core/migrate.d.ts +31 -0
- package/npm/core/migration-files.d.ts +13 -0
- package/npm/core/orgpack-defaults.d.ts +199 -0
- package/npm/core/orgpack-load.d.ts +102 -0
- package/npm/core/question-order.d.ts +23 -0
- package/npm/core/question-owners.d.ts +53 -0
- package/npm/core/question-proposals.d.ts +77 -0
- package/npm/core/questions.d.ts +297 -0
- package/npm/core/record-cache.d.ts +52 -0
- package/npm/core/refs.d.ts +9 -0
- package/npm/core/repo-description.d.ts +44 -0
- package/npm/core/repo-reads.d.ts +44 -0
- package/npm/core/roles-migrate.d.ts +9 -0
- package/npm/core/runtime-migrate.d.ts +11 -0
- package/npm/core/schema/ai.d.ts +397 -0
- package/npm/core/schema/change.d.ts +244 -0
- package/npm/core/schema/common.d.ts +135 -0
- package/npm/core/schema/conventions.d.ts +75 -0
- package/npm/core/schema/dialect.d.ts +801 -0
- package/npm/core/schema/executors.d.ts +396 -0
- package/npm/core/schema/fact-corrections.d.ts +55 -0
- package/npm/core/schema/facts.d.ts +1491 -0
- package/npm/core/schema/frameworks.d.ts +371 -0
- package/npm/core/schema/judgment.d.ts +77 -0
- package/npm/core/schema/kinds.d.ts +5166 -0
- package/npm/core/schema/layout.d.ts +25 -0
- package/npm/core/schema/orgpack.d.ts +1185 -0
- package/npm/core/schema/plugin.d.ts +73 -0
- package/npm/core/schema/question.d.ts +195 -0
- package/npm/core/schema/repo-type.d.ts +109 -0
- package/npm/core/schema/review.d.ts +558 -0
- package/npm/core/schema/scan-settings.d.ts +34 -0
- package/npm/core/schema/scan-verify.d.ts +535 -0
- package/npm/core/schema/spec.d.ts +269 -0
- package/npm/core/schema/version.d.ts +9 -0
- package/npm/core/schema/workspace.d.ts +330 -0
- package/npm/core/serialize.d.ts +17 -0
- package/npm/core/shared-maps.d.ts +146 -0
- package/npm/core/sources-migrate.d.ts +15 -0
- package/npm/core/specs.d.ts +66 -0
- package/npm/core/stack-helpers.d.ts +32 -0
- package/npm/core/tar-read.d.ts +13 -0
- package/npm/core/template.d.ts +101 -0
- package/npm/core/words.d.ts +13 -0
- package/npm/core/zip-read.d.ts +37 -0
- package/npm/core/zip.d.ts +13 -0
- package/npm/index.js +9780 -0
- package/{dist → npm}/plugin.d.ts +1 -1
- package/{dist → npm}/runner.d.ts +1 -1
- package/package.json +10 -11
- package/dist/cache.js +0 -115
- package/dist/cache.js.map +0 -1
- package/dist/fs-repo.js +0 -120
- package/dist/fs-repo.js.map +0 -1
- package/dist/index.js +0 -7
- package/dist/index.js.map +0 -1
- package/dist/parse-cache.js +0 -275
- package/dist/parse-cache.js.map +0 -1
- package/dist/plugin.js +0 -85
- package/dist/plugin.js.map +0 -1
- package/dist/runner.js +0 -209
- package/dist/runner.js.map +0 -1
- package/dist/sandbox.js +0 -443
- package/dist/sandbox.js.map +0 -1
- /package/{dist → npm}/fs-repo.d.ts +0 -0
- /package/{dist → npm}/index.d.ts +0 -0
- /package/{dist → npm}/parse-cache.d.ts +0 -0
- /package/{dist → npm}/sandbox.d.ts +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which repo answers on a host (ADR 0088): a scan or atticus estate join asks, as a question
|
|
3
|
+
* file (ADR 0078), for each host the estate's calls name that no repo lists in its `hosts`;
|
|
4
|
+
* the answer writes the host under that repo's `hosts` in its repos.manifest.yaml.
|
|
5
|
+
*/
|
|
6
|
+
/** The step that asks which repo answers on a host. */
|
|
7
|
+
export declare const HOSTS_STEP = "scan-hosts";
|
|
8
|
+
/**
|
|
9
|
+
* The step that asks which repo or system answers a call with no target (the scanner's
|
|
10
|
+
* TARGETS_STEP), and its group question's option that says the calls go to more than one place:
|
|
11
|
+
* named here so an answer's rule (ADR 0153) is checked where it is written.
|
|
12
|
+
*/
|
|
13
|
+
export declare const TARGETS_STEP_ID = "facts-targets";
|
|
14
|
+
export declare const TARGETS_SPLIT_LABEL = "Not all to one place";
|
|
15
|
+
/** The last option of a hosts question: no repo of the estate answers on it. */
|
|
16
|
+
export declare const HOSTS_NONE = "None of these";
|
|
17
|
+
/**
|
|
18
|
+
* The options of a hosts question that say an outside system answers on the host (O1): another
|
|
19
|
+
* team's system (boundary internal, the first, the default) or a vendor's. The answer writes the
|
|
20
|
+
* system into the profile of the repo that asked, with the host as its alias, so the calls to
|
|
21
|
+
* the host go to it (F3: a declared system no estate repo belongs to is outside).
|
|
22
|
+
*/
|
|
23
|
+
export declare const HOSTS_OUTSIDE_INTERNAL = "An outside system (new): another team's";
|
|
24
|
+
export declare const HOSTS_OUTSIDE_VENDOR = "An outside system (new): a vendor";
|
|
25
|
+
/** The boundary an outside-system option of a hosts question gives its system, if it is one. */
|
|
26
|
+
export declare function outsideBoundaryOf(label: string | undefined): "internal" | "vendor" | undefined;
|
|
27
|
+
/** The system an outside-system answer adds for a host: its id and name, both from the host. */
|
|
28
|
+
export declare function outsideSystemOf(host: string): {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
};
|
|
32
|
+
/** The question for a host, with its port when the calls name one: localhost:9966. */
|
|
33
|
+
export declare const hostQuestionText: (host: string) => string;
|
|
34
|
+
/** The host a hosts question asks about, read back from its words. */
|
|
35
|
+
export declare function hostOfQuestion(q: {
|
|
36
|
+
question: string;
|
|
37
|
+
}): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Put an outside system for a host into the profile whose repos.manifest.yaml lists the repo
|
|
40
|
+
* that asked (O1): its id and name from the host, the host as its alias, the boundary given
|
|
41
|
+
* (internal: another team's; vendor). The profile keeps its comments and order, and is made,
|
|
42
|
+
* with the platform's id as its name, when there is none. `added` is false when a system of the
|
|
43
|
+
* profiles already names the host. Throws when no manifest lists the repo, or the profile would
|
|
44
|
+
* not be valid (an id another system has).
|
|
45
|
+
*/
|
|
46
|
+
export declare function addOutsideSystem(root: string, repo: string, host: string, boundary: "internal" | "vendor"): Promise<{
|
|
47
|
+
id: string;
|
|
48
|
+
profile: string;
|
|
49
|
+
added: boolean;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Put a host under a repo's `hosts` in the repos.manifest.yaml that lists it, keeping the
|
|
53
|
+
* file's comments and order. `added` is false when the repo already lists it. Throws when no
|
|
54
|
+
* manifest lists the repo, or the host isn't one the manifest takes.
|
|
55
|
+
*/
|
|
56
|
+
export declare function addManifestHost(root: string, repo: string, host: string,
|
|
57
|
+
/**
|
|
58
|
+
* ADR 0153 (Q2): the path the repo answers under on the host, from an answer's path rule, set
|
|
59
|
+
* as its `basePath`. Refused when the repo gives another one.
|
|
60
|
+
*/
|
|
61
|
+
o?: {
|
|
62
|
+
basePath?: string;
|
|
63
|
+
}): Promise<{
|
|
64
|
+
manifest: string;
|
|
65
|
+
added: boolean;
|
|
66
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalise an HTTP path or topic so the same interface found in different places
|
|
3
|
+
* (caller code, gateway route, callee controller) gets the same identity.
|
|
4
|
+
*
|
|
5
|
+
* - path parameters in any style ({id}, :id, <id>, ${id}) become "{}"
|
|
6
|
+
* - query strings and fragments are dropped
|
|
7
|
+
* - repeated and trailing slashes are removed; a leading slash is ensured for paths
|
|
8
|
+
* - topics (no leading slash in the input and no "/" at all) are returned trimmed
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizePath(input: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Stable interface id: a hash of caller, callee, method and normalised path, so the same
|
|
13
|
+
* edge seen by several extractors merges into one Interface record.
|
|
14
|
+
*/
|
|
15
|
+
export declare function interfaceId(from: string, to: string, method: string | undefined, path: string): string;
|
|
16
|
+
/** Lowercase slug suitable as a record id, built from free text such as a system name. */
|
|
17
|
+
export declare function slugify(text: string): string;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export * from "./schema/common.js";
|
|
2
|
+
export * from "./schema/kinds.js";
|
|
3
|
+
export * from "./schema/facts.js";
|
|
4
|
+
export * from "./schema/fact-corrections.js";
|
|
5
|
+
export * from "./facts.js";
|
|
6
|
+
export * from "./fact-paths.js";
|
|
7
|
+
export * from "./migration-files.js";
|
|
8
|
+
export * from "./facts-join.js";
|
|
9
|
+
export * from "./facts-join-vendor.js";
|
|
10
|
+
export * from "./facts-join-prototype.js";
|
|
11
|
+
export * from "./facts-carry.js";
|
|
12
|
+
export * from "./facts-callers.js";
|
|
13
|
+
export * from "./link-evidence.js";
|
|
14
|
+
export * from "./shared-maps.js";
|
|
15
|
+
export * from "./audit.js";
|
|
16
|
+
export * from "./stack-helpers.js";
|
|
17
|
+
export * from "./cite.js";
|
|
18
|
+
export * from "./catalog.js";
|
|
19
|
+
export * from "./identity.js";
|
|
20
|
+
export * from "./serialize.js";
|
|
21
|
+
export * from "./json-schema.js";
|
|
22
|
+
export * from "./schema/workspace.js";
|
|
23
|
+
export * from "./schema/change.js";
|
|
24
|
+
export * from "./branches.js";
|
|
25
|
+
export * from "./template.js";
|
|
26
|
+
export * from "./schema/dialect.js";
|
|
27
|
+
export * from "./schema/frameworks.js";
|
|
28
|
+
export * from "./schema/scan-settings.js";
|
|
29
|
+
export * from "./schema/scan-verify.js";
|
|
30
|
+
export * from "./schema/repo-type.js";
|
|
31
|
+
export * from "./schema/layout.js";
|
|
32
|
+
export * from "./schema/plugin.js";
|
|
33
|
+
export * from "./schema/review.js";
|
|
34
|
+
export * from "./schema/orgpack.js";
|
|
35
|
+
export * from "./schema/conventions.js";
|
|
36
|
+
export * from "./schema/executors.js";
|
|
37
|
+
export * from "./orgpack-defaults.js";
|
|
38
|
+
export * from "./orgpack-load.js";
|
|
39
|
+
export * from "./schema/ai.js";
|
|
40
|
+
export * as Api from "./api.js";
|
|
41
|
+
export { API_VERSION, DEFAULT_PORT, openApiDocument } from "./api.js";
|
|
42
|
+
export * from "./merge.js";
|
|
43
|
+
export * from "./refs.js";
|
|
44
|
+
export * from "./curated.js";
|
|
45
|
+
export * from "./migrate.js";
|
|
46
|
+
export * from "./gates-migrate.js";
|
|
47
|
+
export * from "./change-types-migrate.js";
|
|
48
|
+
export * from "./sources-migrate.js";
|
|
49
|
+
export * from "./runtime-migrate.js";
|
|
50
|
+
export * from "./roles-migrate.js";
|
|
51
|
+
export * from "./metarepo.js";
|
|
52
|
+
export * from "./fs.js";
|
|
53
|
+
export * from "./record-cache.js";
|
|
54
|
+
export * from "./log.js";
|
|
55
|
+
export * from "./zip.js";
|
|
56
|
+
export * from "./words.js";
|
|
57
|
+
export * from "./zip-read.js";
|
|
58
|
+
export * from "./tar-read.js";
|
|
59
|
+
export * from "./schema/question.js";
|
|
60
|
+
export * from "./questions.js";
|
|
61
|
+
export * from "./schema/judgment.js";
|
|
62
|
+
export * from "./judgments.js";
|
|
63
|
+
export * from "./host-questions.js";
|
|
64
|
+
export * from "./repo-reads.js";
|
|
65
|
+
export * from "./question-order.js";
|
|
66
|
+
export * from "./question-owners.js";
|
|
67
|
+
export * from "./question-proposals.js";
|
|
68
|
+
export * from "./repo-description.js";
|
|
69
|
+
export * from "./manifest-edit.js";
|
|
70
|
+
export * from "./schema/spec.js";
|
|
71
|
+
export * from "./specs.js";
|
|
72
|
+
export * from "./cancel.js";
|
|
73
|
+
export * from "./assistant-actor.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type RecordKind } from "./schema/kinds.js";
|
|
2
|
+
/**
|
|
3
|
+
* JSON Schema for every record kind, generated from the zod source of truth, for editors,
|
|
4
|
+
* other tools and org-pack validation outside TypeScript.
|
|
5
|
+
*/
|
|
6
|
+
export declare function catalogJsonSchemas(): Record<RecordKind, object>;
|
|
7
|
+
/**
|
|
8
|
+
* JSON Schema for the workspace files: repos.manifest.yaml, and a change's repos.yaml,
|
|
9
|
+
* change.yaml (its lifecycle state) and review/outcomes.yaml (ADR 0045), and a view's kept
|
|
10
|
+
* arrangement, diagrams/layouts/<view-key>.yaml (ADR 0081).
|
|
11
|
+
*/
|
|
12
|
+
export declare function workspaceJsonSchemas(): Record<"RepoManifest" | "ChangeRepos" | "ChangeLifecycle" | "ChangeOutcomes" | "CatalogBaseline" | "MetarepoStamp" | "DiagramLayout", object>;
|
|
13
|
+
/** JSON Schema for the dialect rule file (C2) and checklist packs and findings (C3). */
|
|
14
|
+
export declare function rulesJsonSchemas(): Record<"Dialect" | "ChecklistPack" | "Finding", object>;
|
|
15
|
+
/** JSON Schema for every org-pack file (C6). */
|
|
16
|
+
export declare function orgPackJsonSchemas(): Record<string, object>;
|
|
17
|
+
/** JSON Schema for the AI runtime's run files (C5). */
|
|
18
|
+
export declare function aiJsonSchemas(): Record<string, object>;
|
|
19
|
+
/** The facts file the assistant writes (ADR 0124): one Fact per JSON line, or a FactsFile array. */
|
|
20
|
+
export declare function factsJsonSchemas(): Record<"Fact" | "FactsFile", object>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Judgment, type JudgmentConfirmer, type JudgmentVerdict } from "./schema/judgment.js";
|
|
2
|
+
/**
|
|
3
|
+
* The judgments store (ADR 0117): judgments/<kind>/<key>.yaml, the key a hash of the inputs.
|
|
4
|
+
* Any step that asks a model a closed question about meaning keeps the answer here (the judge
|
|
5
|
+
* step in @maycombhq/ai, and the context engine's query expansion and rerank), so the same
|
|
6
|
+
* commit with the same inputs reads the stored verdict and never asks again, and a changed input
|
|
7
|
+
* invalidates only its own judgment.
|
|
8
|
+
*
|
|
9
|
+
* The interface is two calls, get and put by kind and key; `judgmentKey` makes the key.
|
|
10
|
+
*/
|
|
11
|
+
export interface JudgmentStore {
|
|
12
|
+
get(kind: string, key: string): Promise<Judgment | undefined>;
|
|
13
|
+
/**
|
|
14
|
+
* Keep a judgment. A person's verdict on file is never replaced by a model's or a check's:
|
|
15
|
+
* the stored one comes back instead.
|
|
16
|
+
*/
|
|
17
|
+
put(j: Judgment): Promise<Judgment>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The key of a judgment: 24 hex characters of the sha256 of the kind and the inputs in
|
|
21
|
+
* canonical form (keys sorted, undefined left out), so the same inputs in any key order give
|
|
22
|
+
* the same key.
|
|
23
|
+
*/
|
|
24
|
+
export declare function judgmentKey(kind: string, inputs: unknown): string;
|
|
25
|
+
/** A new judgment at the current schema version, its key made from the inputs. */
|
|
26
|
+
export declare function makeJudgment(o: {
|
|
27
|
+
kind: string;
|
|
28
|
+
inputs: Record<string, unknown>;
|
|
29
|
+
verdict: JudgmentVerdict;
|
|
30
|
+
confirmedBy: JudgmentConfirmer;
|
|
31
|
+
at: string;
|
|
32
|
+
value?: unknown;
|
|
33
|
+
quotes?: {
|
|
34
|
+
of: string;
|
|
35
|
+
text: string;
|
|
36
|
+
}[];
|
|
37
|
+
why?: string;
|
|
38
|
+
}): Judgment;
|
|
39
|
+
/** The store in the metarepo: judgments/ (or .atticus/judgments/ when adopted). */
|
|
40
|
+
export declare function fileJudgments(root: string): JudgmentStore & {
|
|
41
|
+
list(kind?: string): Promise<{
|
|
42
|
+
judgments: Judgment[];
|
|
43
|
+
problems: {
|
|
44
|
+
file: string;
|
|
45
|
+
message: string;
|
|
46
|
+
}[];
|
|
47
|
+
}>;
|
|
48
|
+
};
|
|
49
|
+
/** A store in memory, for tests and for a step run without a metarepo. */
|
|
50
|
+
export declare function memoryJudgments(initial?: Judgment[]): JudgmentStore & {
|
|
51
|
+
all(): Judgment[];
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* A person overrides a judgment: their verdict is kept, with the one it replaced under
|
|
55
|
+
* `overrides`. Every step that reads the judgment follows the person from then on.
|
|
56
|
+
*/
|
|
57
|
+
export declare function overrideJudgment(store: JudgmentStore, kind: string, key: string, o: {
|
|
58
|
+
verdict: JudgmentVerdict;
|
|
59
|
+
value?: unknown;
|
|
60
|
+
name: string;
|
|
61
|
+
at: string;
|
|
62
|
+
why?: string;
|
|
63
|
+
}): Promise<Judgment>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@maycombhq/core/light`: the few parts of core the command line needs before it knows which
|
|
3
|
+
* command runs (its help's first line and its log). They load no schema, no zod and no YAML
|
|
4
|
+
* reader, so `atticus --help` and the start of every command don't pay for building C1-C6.
|
|
5
|
+
* Each is the same export as the package's own (`@maycombhq/core`); nothing here is new.
|
|
6
|
+
*/
|
|
7
|
+
export { SCHEMA_VERSION } from "./schema/version.js";
|
|
8
|
+
export { createLog, logFileOf, NO_LOG, type Log, type LogEntry, type LogLevel } from "./log.js";
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CatalogRecord } from "./catalog.js";
|
|
3
|
+
import { type FactsJoinResult, type JoinRepo } from "./facts-join.js";
|
|
4
|
+
import type { EvidenceT } from "./schema/common.js";
|
|
5
|
+
/**
|
|
6
|
+
* Links confirmed from outside the code (ADR 0151): contract files a consumer keeps (J3) and
|
|
7
|
+
* traffic exports a person imported as aggregate counts (J4). Neither makes a link: the join
|
|
8
|
+
* makes links from cited code. They add evidence and a flag to an Interface the join already
|
|
9
|
+
* made, and say where the two disagree: a contract or traffic the join has no link for, a
|
|
10
|
+
* contract naming another provider, a link no traffic used over the range.
|
|
11
|
+
*
|
|
12
|
+
* A contract or traffic never raises a guess (`inferred`) to verified: a guess stays a guess
|
|
13
|
+
* until the code names the callee (ADR 0151 §3). Pure: the same join and evidence files give
|
|
14
|
+
* the same marks and findings, whatever order they come in.
|
|
15
|
+
*/
|
|
16
|
+
/** An Interface a consumer's contract file (a Pact interaction, a consumer-side OpenAPI operation) confirms. */
|
|
17
|
+
export declare const CONFIRMED_BY_CONTRACT = "confirmed-by-contract";
|
|
18
|
+
/** An Interface a contract file names another provider for: a gap a person settles. */
|
|
19
|
+
export declare const CONTRACT_DISAGREES = "contract-disagrees";
|
|
20
|
+
/** An Interface an imported traffic export shows used over its range. */
|
|
21
|
+
export declare const SEEN_IN_TRAFFIC = "seen-in-traffic";
|
|
22
|
+
/** The flags this module writes, and takes off again before every write. */
|
|
23
|
+
export declare const LINK_EVIDENCE_FLAGS: ReadonlySet<string>;
|
|
24
|
+
/** The flags that are evidence a link holds, never a gap (as `JOIN_HOW_FLAGS`). */
|
|
25
|
+
export declare const LINK_EVIDENCE_NOT_GAPS: ReadonlySet<string>;
|
|
26
|
+
/** The `extractor` of the evidence this module adds, so a write takes the last write's off. */
|
|
27
|
+
export declare const CONTRACT_EVIDENCE = "atticus-contract@1";
|
|
28
|
+
export declare const TRAFFIC_EVIDENCE = "atticus-traffic@1";
|
|
29
|
+
/** One request a consumer's contract file says it makes. */
|
|
30
|
+
export declare const ContractEntry: z.ZodObject<{
|
|
31
|
+
format: z.ZodEnum<{
|
|
32
|
+
openapi: "openapi";
|
|
33
|
+
pact: "pact";
|
|
34
|
+
}>;
|
|
35
|
+
file: z.ZodString;
|
|
36
|
+
line: z.ZodNumber;
|
|
37
|
+
consumer: z.ZodOptional<z.ZodString>;
|
|
38
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
39
|
+
hosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
|
+
method: z.ZodOptional<z.ZodString>;
|
|
41
|
+
path: z.ZodString;
|
|
42
|
+
}, z.core.$strict>;
|
|
43
|
+
export type ContractEntryT = z.infer<typeof ContractEntry>;
|
|
44
|
+
/**
|
|
45
|
+
* The facts companion `<repo>.contracts.yaml` (ADR 0151): the contract files read in a repo's
|
|
46
|
+
* checkout at the facts' commit by `atticus verify <repo> --write`, so every later write of any
|
|
47
|
+
* repo reads the same entries without the checkout.
|
|
48
|
+
*/
|
|
49
|
+
export declare const ContractsFile: z.ZodObject<{
|
|
50
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
51
|
+
repo: z.ZodString;
|
|
52
|
+
commit: z.ZodOptional<z.ZodString>;
|
|
53
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
54
|
+
format: z.ZodEnum<{
|
|
55
|
+
openapi: "openapi";
|
|
56
|
+
pact: "pact";
|
|
57
|
+
}>;
|
|
58
|
+
file: z.ZodString;
|
|
59
|
+
line: z.ZodNumber;
|
|
60
|
+
consumer: z.ZodOptional<z.ZodString>;
|
|
61
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
62
|
+
hosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
method: z.ZodOptional<z.ZodString>;
|
|
64
|
+
path: z.ZodString;
|
|
65
|
+
}, z.core.$strict>>;
|
|
66
|
+
}, z.core.$strict>;
|
|
67
|
+
export type ContractsFileT = z.infer<typeof ContractsFile>;
|
|
68
|
+
/** One aggregate of an imported traffic export: never a raw row. */
|
|
69
|
+
export declare const TrafficRow: z.ZodObject<{
|
|
70
|
+
app: z.ZodString;
|
|
71
|
+
component: z.ZodOptional<z.ZodString>;
|
|
72
|
+
method: z.ZodString;
|
|
73
|
+
path: z.ZodString;
|
|
74
|
+
proxy: z.ZodOptional<z.ZodString>;
|
|
75
|
+
basepath: z.ZodOptional<z.ZodString>;
|
|
76
|
+
count: z.ZodNumber;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
export type TrafficRowT = z.infer<typeof TrafficRow>;
|
|
79
|
+
/** `evidence/traffic/<source>-<from>-<to>.yaml`: what an import kept, reviewed in a pull request. */
|
|
80
|
+
export declare const TrafficFile: z.ZodObject<{
|
|
81
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
82
|
+
source: z.ZodString;
|
|
83
|
+
from: z.ZodString;
|
|
84
|
+
to: z.ZodString;
|
|
85
|
+
inputSha256: z.ZodString;
|
|
86
|
+
rows: z.ZodArray<z.ZodObject<{
|
|
87
|
+
app: z.ZodString;
|
|
88
|
+
component: z.ZodOptional<z.ZodString>;
|
|
89
|
+
method: z.ZodString;
|
|
90
|
+
path: z.ZodString;
|
|
91
|
+
proxy: z.ZodOptional<z.ZodString>;
|
|
92
|
+
basepath: z.ZodOptional<z.ZodString>;
|
|
93
|
+
count: z.ZodNumber;
|
|
94
|
+
}, z.core.$strict>>;
|
|
95
|
+
}, z.core.$strict>;
|
|
96
|
+
export type TrafficFileT = z.infer<typeof TrafficFile>;
|
|
97
|
+
/** The file name a traffic aggregate is written under. */
|
|
98
|
+
export declare const trafficFileName: (f: Pick<TrafficFileT, "source" | "from" | "to">) => string;
|
|
99
|
+
/** The canonical text of a traffic aggregate: keys in schema order, one row a block. */
|
|
100
|
+
export declare function trafficFileText(f: TrafficFileT): string;
|
|
101
|
+
/** A traffic file read back, each row with the line it starts on (what its evidence cites). */
|
|
102
|
+
export interface TrafficOnFile {
|
|
103
|
+
/** Its path in the metarepo, forward slashes (`evidence/traffic/...`). */
|
|
104
|
+
rel: string;
|
|
105
|
+
file: TrafficFileT;
|
|
106
|
+
lines: number[];
|
|
107
|
+
}
|
|
108
|
+
/** Read a traffic aggregate with its rows' lines; a problem when it isn't one. */
|
|
109
|
+
export declare function readTrafficFile(rel: string, text: string): {
|
|
110
|
+
ok: true;
|
|
111
|
+
traffic: TrafficOnFile;
|
|
112
|
+
} | {
|
|
113
|
+
ok: false;
|
|
114
|
+
message: string;
|
|
115
|
+
};
|
|
116
|
+
/** A link end as a finding names it. */
|
|
117
|
+
export interface LinkRef {
|
|
118
|
+
interface: string;
|
|
119
|
+
from: string;
|
|
120
|
+
to: string;
|
|
121
|
+
method?: string;
|
|
122
|
+
path: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* What a contract file says that the join doesn't: `provider-differs` (the consumer's request is
|
|
126
|
+
* a link the join made to another component), `no-link` (the join has no link for it),
|
|
127
|
+
* `unknown-provider` (the provider it names is no component or repo of the estate).
|
|
128
|
+
*/
|
|
129
|
+
export interface ContractFinding {
|
|
130
|
+
reason: "provider-differs" | "no-link" | "unknown-provider";
|
|
131
|
+
repo: string;
|
|
132
|
+
/** file:line in the consumer's repo. */
|
|
133
|
+
at: string;
|
|
134
|
+
format: "pact" | "openapi";
|
|
135
|
+
consumer: string;
|
|
136
|
+
provider?: string;
|
|
137
|
+
method?: string;
|
|
138
|
+
path: string;
|
|
139
|
+
/** The links the request matched (for `provider-differs`, `unknown-provider`). */
|
|
140
|
+
links: LinkRef[];
|
|
141
|
+
message: string;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* What a traffic export says that the join doesn't: `missed-link` (traffic no link carries),
|
|
145
|
+
* `unknown-app` (an app named like no component: a person names it in the row's `component`),
|
|
146
|
+
* `unseen-link` (a link the export covers that no traffic used over the range).
|
|
147
|
+
*/
|
|
148
|
+
export interface TrafficFinding {
|
|
149
|
+
reason: "missed-link" | "unknown-app" | "unseen-link";
|
|
150
|
+
/** The traffic file, and the row's line (not for `unseen-link`). */
|
|
151
|
+
file: string;
|
|
152
|
+
at?: string;
|
|
153
|
+
range: {
|
|
154
|
+
from: string;
|
|
155
|
+
to: string;
|
|
156
|
+
};
|
|
157
|
+
app?: string;
|
|
158
|
+
component?: string;
|
|
159
|
+
method?: string;
|
|
160
|
+
path?: string;
|
|
161
|
+
count?: number;
|
|
162
|
+
link?: LinkRef;
|
|
163
|
+
message: string;
|
|
164
|
+
}
|
|
165
|
+
/** A link the traffic showed, with how much and over what range. */
|
|
166
|
+
export interface TrafficSeen extends LinkRef {
|
|
167
|
+
count: number;
|
|
168
|
+
file: string;
|
|
169
|
+
range: {
|
|
170
|
+
from: string;
|
|
171
|
+
to: string;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export interface LinkEvidenceResult {
|
|
175
|
+
/** By Interface id: the flags and evidence to add. */
|
|
176
|
+
marks: Record<string, {
|
|
177
|
+
flags: string[];
|
|
178
|
+
evidence: EvidenceT[];
|
|
179
|
+
}>;
|
|
180
|
+
contracts: {
|
|
181
|
+
entries: number;
|
|
182
|
+
confirmed: LinkRef[];
|
|
183
|
+
findings: ContractFinding[];
|
|
184
|
+
};
|
|
185
|
+
traffic: {
|
|
186
|
+
rows: number;
|
|
187
|
+
seen: TrafficSeen[];
|
|
188
|
+
findings: TrafficFinding[];
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
export interface LinkEvidenceInput {
|
|
192
|
+
/** The whole estate's join (every repo with verified facts). */
|
|
193
|
+
join: FactsJoinResult;
|
|
194
|
+
repos: readonly JoinRepo[];
|
|
195
|
+
contracts?: readonly ContractsFileT[];
|
|
196
|
+
traffic?: readonly TrafficOnFile[];
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Mark the joins the contract files and traffic aggregates bear out, and list where they and the
|
|
200
|
+
* join disagree (ADR 0151).
|
|
201
|
+
*/
|
|
202
|
+
export declare function linkEvidenceOf(input: LinkEvidenceInput): LinkEvidenceResult;
|
|
203
|
+
/**
|
|
204
|
+
* The records without what an earlier write's contract and traffic evidence added: its flags and
|
|
205
|
+
* evidence entries. A record left with no evidence at all (none could be) is dropped.
|
|
206
|
+
*/
|
|
207
|
+
export declare function stripLinkEvidence(records: readonly CatalogRecord[]): CatalogRecord[];
|
|
208
|
+
/**
|
|
209
|
+
* The records with the marks added: each marked Interface gets its flags (after its own) and
|
|
210
|
+
* evidence (after its own, each line once). Its confidence is never changed (ADR 0151 §3).
|
|
211
|
+
*/
|
|
212
|
+
export declare function applyLinkEvidence(records: readonly CatalogRecord[], marks: LinkEvidenceResult["marks"]): CatalogRecord[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The local log (ADR 0050): one JSON object per line in `.atticus/logs/atticus.log`,
|
|
3
|
+
* kept on this machine. It records what ran (command and flag names, never their values),
|
|
4
|
+
* how it ended, how long it took and, on a crash, the error with its stack. Every entry is
|
|
5
|
+
* redacted before it is written: secrets, credentials in URLs, tokens and the person's home
|
|
6
|
+
* folder never reach the file.
|
|
7
|
+
*/
|
|
8
|
+
export type LogLevel = "debug" | "info" | "warn" | "error" | "off";
|
|
9
|
+
export interface LogEntry {
|
|
10
|
+
at: string;
|
|
11
|
+
level: Exclude<LogLevel, "off">;
|
|
12
|
+
event: string;
|
|
13
|
+
[field: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface Log {
|
|
16
|
+
readonly file: string;
|
|
17
|
+
debug(event: string, fields?: Record<string, unknown>): void;
|
|
18
|
+
info(event: string, fields?: Record<string, unknown>): void;
|
|
19
|
+
warn(event: string, fields?: Record<string, unknown>): void;
|
|
20
|
+
error(event: string, err: unknown, fields?: Record<string, unknown>): void;
|
|
21
|
+
}
|
|
22
|
+
export declare const LOG_MAX_BYTES: number;
|
|
23
|
+
export declare const LOG_KEEP = 3;
|
|
24
|
+
/** Where the log of a metarepo lives. */
|
|
25
|
+
export declare const logFileOf: (root: string) => string;
|
|
26
|
+
/** Strings with anything that looks like a secret replaced by "***", and home folders by "~". */
|
|
27
|
+
export declare function redactText(s: string, o?: {
|
|
28
|
+
home?: string;
|
|
29
|
+
user?: string;
|
|
30
|
+
}): string;
|
|
31
|
+
/** A value with secret-named keys masked and every string redacted. */
|
|
32
|
+
export declare function redact(v: unknown, o?: {
|
|
33
|
+
home?: string;
|
|
34
|
+
user?: string;
|
|
35
|
+
}): unknown;
|
|
36
|
+
/** The level from ATTICUS_LOG (debug, info, warn, error or off); info by default. */
|
|
37
|
+
export declare function logLevelFrom(env?: NodeJS.ProcessEnv): LogLevel;
|
|
38
|
+
/**
|
|
39
|
+
* A log for a metarepo. Writing never throws: a log that can't be written (a read-only folder,
|
|
40
|
+
* a full disk) is skipped rather than failing the command it describes.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createLog(root: string, o?: {
|
|
43
|
+
level?: LogLevel;
|
|
44
|
+
now?: () => Date;
|
|
45
|
+
maxBytes?: number;
|
|
46
|
+
keep?: number;
|
|
47
|
+
}): Log;
|
|
48
|
+
/** A log that writes nothing (tests, and commands run with no metarepo). */
|
|
49
|
+
export declare const NO_LOG: Log;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { RepoDescription } from "./schema/workspace.js";
|
|
2
|
+
/**
|
|
3
|
+
* Editing `org-pack/profiles/<platform>/repos.manifest.yaml` in place, keeping the file's
|
|
4
|
+
* comments and the order a person put its entries in: a repo's description (ADR 0128), and the
|
|
5
|
+
* schema-version rewrite `atticus upgrade` runs. Every write is checked against the manifest
|
|
6
|
+
* schema first, so a manifest Atticus can't read is never written.
|
|
7
|
+
*/
|
|
8
|
+
/** One profile's manifest: where it is on disk and how the metarepo names it. */
|
|
9
|
+
export interface ManifestFile {
|
|
10
|
+
path: string;
|
|
11
|
+
rel: string;
|
|
12
|
+
platform: string;
|
|
13
|
+
}
|
|
14
|
+
/** Every profile's manifest, by platform name. */
|
|
15
|
+
export declare function manifestFiles(root: string): Promise<ManifestFile[]>;
|
|
16
|
+
export declare class ManifestEditError extends Error {
|
|
17
|
+
readonly code: "not-found" | "invalid";
|
|
18
|
+
constructor(code: "not-found" | "invalid", message: string);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Set, replace or remove a repo's description in the manifest that lists it. A person's own
|
|
22
|
+
* words come in as `verified`; a draft the assistant wrote comes in as `suggested` with its
|
|
23
|
+
* cites, and stays marked unconfirmed until a person confirms it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function setManifestDescription(root: string, repo: string, description: RepoDescription | undefined): Promise<ManifestFile>;
|
|
26
|
+
/**
|
|
27
|
+
* Add a repo to a platform's manifest, keeping the file's comments and the order its entries
|
|
28
|
+
* are in. The entry is written with the fields that are set and no more, and the whole manifest
|
|
29
|
+
* is checked before it is written, so a duplicate id or a password in the URL is refused here.
|
|
30
|
+
*/
|
|
31
|
+
export declare function addManifestRepo(root: string, platform: string, entry: {
|
|
32
|
+
id: string;
|
|
33
|
+
url: string;
|
|
34
|
+
type: string;
|
|
35
|
+
owner: string;
|
|
36
|
+
/** The branch to read, when known (a clone's current branch); the manifest's default is main. */
|
|
37
|
+
defaultBranch?: string;
|
|
38
|
+
system?: string;
|
|
39
|
+
component?: string;
|
|
40
|
+
description?: RepoDescription;
|
|
41
|
+
}): Promise<ManifestFile>;
|
|
42
|
+
/**
|
|
43
|
+
* F5: move a repo's id in the manifest that lists it, in place (comments and order kept). Refused
|
|
44
|
+
* when no manifest lists the repo, or any lists the new id already (ids are unique across every
|
|
45
|
+
* profile, ADR 0009). Only the id changes; the files filed under it are the caller's to move.
|
|
46
|
+
*/
|
|
47
|
+
export declare function renameManifestRepo(root: string, repo: string, to: string): Promise<ManifestFile>;
|
|
48
|
+
/**
|
|
49
|
+
* Rewrite every manifest at a version below `to` (the current one when left out) at that
|
|
50
|
+
* version, keeping its comments and order (ADR 0009, 0128, 0134). Nothing a person wrote
|
|
51
|
+
* changes: older manifests are read as they are and stay valid, and this only keeps diffs clean.
|
|
52
|
+
* `dryRun` lists what it would change.
|
|
53
|
+
*/
|
|
54
|
+
export declare function migrateManifests(root: string, o?: {
|
|
55
|
+
dryRun?: boolean;
|
|
56
|
+
to?: number;
|
|
57
|
+
}): Promise<string[]>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type CatalogRecord, type RecordIssue } from "./catalog.js";
|
|
2
|
+
/**
|
|
3
|
+
* Merge and identity: turns the records every repo's scan produced into one catalog.
|
|
4
|
+
*
|
|
5
|
+
* - Records with the same identity merge (evidence is unioned, the best value wins).
|
|
6
|
+
* - REST endpoints are keyed by component, method and normalised path and get a canonical id.
|
|
7
|
+
* - Loose ends (Unresolved records, ADR 0016) are resolved: HTTP calls into Interfaces
|
|
8
|
+
* (through the gateway when a route's base path matches), publishes and subscribes into
|
|
9
|
+
* event Interfaces, database access into Tables' readers and writers; GraphQL, gRPC and
|
|
10
|
+
* webhook loose ends (ADR 0040) into Interfaces to the matching typed endpoints.
|
|
11
|
+
* - A direct synchronous call between two components with a `mesh` Setting goes via mesh.
|
|
12
|
+
* - Interfaces are verified only when both ends are seen; otherwise inferred.
|
|
13
|
+
* - Whatever can't be resolved stays as an Unresolved record with its owner.
|
|
14
|
+
*
|
|
15
|
+
* Deterministic: the same input gives the same catalog, sorted by kind and id. See ADR 0017.
|
|
16
|
+
*/
|
|
17
|
+
export interface MergeRepo {
|
|
18
|
+
id: string;
|
|
19
|
+
component?: string;
|
|
20
|
+
system?: string;
|
|
21
|
+
type: string;
|
|
22
|
+
/** Hosts the repo's component (or, for a gateway repo, the gateway) answers on (ADR 0053). */
|
|
23
|
+
hosts?: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface MergeSystem {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
boundary: "product" | "internal" | "vendor";
|
|
29
|
+
owner?: string;
|
|
30
|
+
aliases: string[];
|
|
31
|
+
/** Copied to the System record (ADR 0040: saas marks a SaaS vendor). */
|
|
32
|
+
tags?: string[];
|
|
33
|
+
}
|
|
34
|
+
/** What merge needs from an integration pattern (C6) to infer it on a hop. */
|
|
35
|
+
export interface MergePattern {
|
|
36
|
+
code: string;
|
|
37
|
+
status: string;
|
|
38
|
+
detection: {
|
|
39
|
+
via: string[];
|
|
40
|
+
sync?: string;
|
|
41
|
+
targetBoundary?: string;
|
|
42
|
+
sameSystem?: boolean;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export interface MergeInput {
|
|
46
|
+
records: CatalogRecord[];
|
|
47
|
+
repos: MergeRepo[];
|
|
48
|
+
systems: MergeSystem[];
|
|
49
|
+
patterns?: MergePattern[];
|
|
50
|
+
/** Where the systems came from, for their evidence (e.g. "org-pack/profiles/forge/profile.yaml"). */
|
|
51
|
+
profilePath?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Route a call to an undeclared host through the gateway route its path starts with, as before
|
|
54
|
+
* ADR 0053. Only for callers without the repos manifest (drift on a fetched copy of the
|
|
55
|
+
* catalog), where no host is declared; a full scan never sets it.
|
|
56
|
+
*/
|
|
57
|
+
gatewayByBasepath?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface MergeResult {
|
|
60
|
+
records: CatalogRecord[];
|
|
61
|
+
/** Records merge produced that failed C1 (a bug if ever non-empty). */
|
|
62
|
+
invalid: {
|
|
63
|
+
record: unknown;
|
|
64
|
+
issues: RecordIssue[];
|
|
65
|
+
}[];
|
|
66
|
+
stats: {
|
|
67
|
+
interfaces: number;
|
|
68
|
+
verified: number;
|
|
69
|
+
unresolved: number;
|
|
70
|
+
};
|
|
71
|
+
/** Things worth knowing that aren't wrong, e.g. hosts that look like a gateway nobody declared. */
|
|
72
|
+
notes: string[];
|
|
73
|
+
}
|
|
74
|
+
/** Canonical REST endpoint id: <component>.<method>-<last fixed path segment, singular>. */
|
|
75
|
+
export declare function endpointId(component: string, method: string | undefined, normalizedPath: string): string;
|
|
76
|
+
export declare function mergeCatalog(input: MergeInput): MergeResult;
|
|
77
|
+
/** The Setting key that says a component runs in a service mesh (ADR 0040); its value names the mesh. */
|
|
78
|
+
export declare const MESH_KEY = "mesh";
|