@intentset/architecture 0.7.0 → 0.8.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.
@@ -3,17 +3,22 @@
3
3
  * (Core §8, ADR 0013): the files each slice's claims resolve to, the files of
4
4
  * each registry resource, the local files a test imports (resolved with the
5
5
  * same TypeScript-aware resolver as the import graph, and stopping at a
6
- * package boundary), the global inputs expanded to paths, and which files can
7
- * move any subject at all. Pure: it reads the tree it is given and the file
6
+ * package boundary), the global inputs expanded to paths, which resource files a
7
+ * subject hashes (`evidence.resources`, Core §8) and which files can move any
8
+ * subject at all. Pure: it reads the tree it is given and the file
8
9
  * contents through the function it is given.
9
10
  */
10
- import type { Graph, Registries } from "@intentset/core";
11
+ import { type EvidenceDependencies, type EvidenceResources, type Graph, type Registries } from "@intentset/core";
11
12
  import { type ArchitectureConfig } from "./config.ts";
12
13
  export interface SubjectSourceOptions {
13
14
  /** Laid over the defaults and `.intentset/architecture.yaml`, as for `checkArchitecture`. */
14
15
  config?: Partial<ArchitectureConfig>;
15
16
  /** `evidence.globalInputs`: paths, or patterns expanded over the tree. */
16
17
  globalInputs: readonly string[];
18
+ /** `evidence.resources`: `exercised` (the default) or `used`; the evidence package's subject reads it from the source this returns. */
19
+ resources?: EvidenceResources;
20
+ /** `evidence.dependencies`: what a dependency slice contributes; the subject reads it from the source this returns. */
21
+ dependencies?: EvidenceDependencies;
17
22
  /** The bytes of a repository-relative file, or undefined when it does not exist. */
18
23
  readFile: (path: string) => Uint8Array | undefined;
19
24
  }
@@ -27,6 +32,8 @@ export interface ArchitectureSubjectSource {
27
32
  }>;
28
33
  localImports: (path: string) => string[];
29
34
  globalInputs: string[];
35
+ resourceMode: EvidenceResources;
36
+ dependencyMode: EvidenceDependencies;
30
37
  covers: (path: string) => boolean;
31
38
  }
32
39
  export declare function subjectSource(graph: Graph, registries: Registries, tree: {
@@ -1 +1 @@
1
- {"version":3,"file":"subject-source.d.ts","sourceRoot":"","sources":["../src/subject-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAA4B,KAAK,kBAAkB,EAAyC,MAAM,aAAa,CAAC;AAOvH,MAAM,WAAW,oBAAoB;IACnC,6FAA6F;IAC7F,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACrC,0EAA0E;IAC1E,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,oFAAoF;IACpF,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,CAAC;CACpD;AAED,4FAA4F;AAC5F,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,CAAC;IACnD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAClC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAC7D,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IACzC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACnC;AAaD,wBAAgB,aAAa,CAC3B,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE;IAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAC5C,OAAO,EAAE,oBAAoB,GAC5B,yBAAyB,CAuE3B"}
1
+ {"version":3,"file":"subject-source.d.ts","sourceRoot":"","sources":["../src/subject-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAEL,KAAK,oB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5B,yBAAyB,CA6F3B"}
@@ -1,3 +1,14 @@
1
+ /**
2
+ * What the evidence package's subject hash needs from the architecture
3
+ * (Core §8, ADR 0013): the files each slice's claims resolve to, the files of
4
+ * each registry resource, the local files a test imports (resolved with the
5
+ * same TypeScript-aware resolver as the import graph, and stopping at a
6
+ * package boundary), the global inputs expanded to paths, which resource files a
7
+ * subject hashes (`evidence.resources`, Core §8) and which files can move any
8
+ * subject at all. Pure: it reads the tree it is given and the file
9
+ * contents through the function it is given.
10
+ */
11
+ import { DEFAULT_EVIDENCE_DEPENDENCIES, } from "@intentset/core";
1
12
  import { ARCHITECTURE_CONFIG_PATH, readArchitectureConfig, resolveConfig } from "./config.js";
2
13
  import { extractImports } from "./extract.js";
3
14
  import { isCode } from "./paths.js";
@@ -67,6 +78,7 @@ export function subjectSource(graph, registries, tree, options) {
67
78
  return list;
68
79
  };
69
80
  const globalInputs = expandGlobalInputs(options.globalInputs, tree.files.keys());
81
+ const resourceMode = options.resources ?? "exercised";
70
82
  let covered = null;
71
83
  const covers = (path) => {
72
84
  if (covered === null) {
@@ -74,10 +86,21 @@ export function subjectSource(graph, registries, tree, options) {
74
86
  for (const files of sliceFiles.values())
75
87
  for (const file of files)
76
88
  covered.add(file);
89
+ // The resources some subject hashes: under `used`, every one a slice lists; under `exercised`, the ones a slice
90
+ // that implements a behavior lists and also claims a file of (its own), and the ones a verification exercises.
77
91
  const used = new Set();
78
- for (const slice of model.slices)
79
- for (const id of slice.meta.usesResources)
80
- used.add(id);
92
+ for (const slice of model.slices) {
93
+ const implementing = (graph.artifacts.get(slice.id)?.meta.links.implements ?? []).length > 0;
94
+ for (const id of slice.meta.usesResources) {
95
+ if (resourceMode === "used")
96
+ used.add(id);
97
+ else if (implementing) {
98
+ const files = new Set(resources.get(id)?.files ?? []);
99
+ if ((sliceFiles.get(slice.id) ?? []).some((file) => files.has(file)))
100
+ used.add(id);
101
+ }
102
+ }
103
+ }
81
104
  for (const artifact of graph.artifacts.values()) {
82
105
  covered.add(artifact.path);
83
106
  const verification = artifact.meta.verification;
@@ -95,6 +118,16 @@ export function subjectSource(graph, registries, tree, options) {
95
118
  }
96
119
  return covered.has(path);
97
120
  };
98
- return { readFile: options.readFile, sliceFiles, resources, localImports, globalInputs, covers };
121
+ const dependencyMode = options.dependencies ?? DEFAULT_EVIDENCE_DEPENDENCIES;
122
+ return {
123
+ readFile: options.readFile,
124
+ sliceFiles,
125
+ resources,
126
+ localImports,
127
+ globalInputs,
128
+ resourceMode,
129
+ dependencyMode,
130
+ covers,
131
+ };
99
132
  }
100
133
  //# sourceMappingURL=subject-source.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"subject-source.js","sourceRoot":"","sources":["../src/subject-source.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,wBAAwB,EAA2B,sBAAsB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACvH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAqBxC,qIAAqI;AACrI,SAAS,kBAAkB,CAAC,MAAyB,EAAE,KAAuB;IAC5E,MAAM,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;IACvB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;;YACpC,KAAK,MAAM,IAAI,IAAI,GAAG;gBAAE,IAAI,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC;oBAAE,GAAG,CAAC,GAAG,CA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Traceable VSA checks: path claims, import graph, layer matrix, resources, exceptions, baseline.",
5
5
  "keywords": [
6
6
  "intentset",
@@ -36,7 +36,7 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@intentset/core": "^0.7.0"
39
+ "@intentset/core": "^0.8.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "typescript": "^7.0.2"
@@ -3,11 +3,18 @@
3
3
  * (Core §8, ADR 0013): the files each slice's claims resolve to, the files of
4
4
  * each registry resource, the local files a test imports (resolved with the
5
5
  * same TypeScript-aware resolver as the import graph, and stopping at a
6
- * package boundary), the global inputs expanded to paths, and which files can
7
- * move any subject at all. Pure: it reads the tree it is given and the file
6
+ * package boundary), the global inputs expanded to paths, which resource files a
7
+ * subject hashes (`evidence.resources`, Core §8) and which files can move any
8
+ * subject at all. Pure: it reads the tree it is given and the file
8
9
  * contents through the function it is given.
9
10
  */
10
- import type { Graph, Registries } from "@intentset/core";
11
+ import {
12
+ DEFAULT_EVIDENCE_DEPENDENCIES,
13
+ type EvidenceDependencies,
14
+ type EvidenceResources,
15
+ type Graph,
16
+ type Registries,
17
+ } from "@intentset/core";
11
18
  import { ARCHITECTURE_CONFIG_PATH, type ArchitectureConfig, readArchitectureConfig, resolveConfig } from "./config.ts";
12
19
  import { extractImports } from "./extract.ts";
13
20
  import { isCode } from "./paths.ts";
@@ -20,6 +27,10 @@ export interface SubjectSourceOptions {
20
27
  config?: Partial<ArchitectureConfig>;
21
28
  /** `evidence.globalInputs`: paths, or patterns expanded over the tree. */
22
29
  globalInputs: readonly string[];
30
+ /** `evidence.resources`: `exercised` (the default) or `used`; the evidence package's subject reads it from the source this returns. */
31
+ resources?: EvidenceResources;
32
+ /** `evidence.dependencies`: what a dependency slice contributes; the subject reads it from the source this returns. */
33
+ dependencies?: EvidenceDependencies;
23
34
  /** The bytes of a repository-relative file, or undefined when it does not exist. */
24
35
  readFile: (path: string) => Uint8Array | undefined;
25
36
  }
@@ -31,6 +42,8 @@ export interface ArchitectureSubjectSource {
31
42
  resources: Map<string, { record: unknown; files: string[] }>;
32
43
  localImports: (path: string) => string[];
33
44
  globalInputs: string[];
45
+ resourceMode: EvidenceResources;
46
+ dependencyMode: EvidenceDependencies;
34
47
  covers: (path: string) => boolean;
35
48
  }
36
49
 
@@ -100,13 +113,25 @@ export function subjectSource(
100
113
 
101
114
  const globalInputs = expandGlobalInputs(options.globalInputs, tree.files.keys());
102
115
 
116
+ const resourceMode = options.resources ?? "exercised";
103
117
  let covered: Set<string> | null = null;
104
118
  const covers = (path: string): boolean => {
105
119
  if (covered === null) {
106
120
  covered = new Set<string>(globalInputs);
107
121
  for (const files of sliceFiles.values()) for (const file of files) covered.add(file);
122
+ // The resources some subject hashes: under `used`, every one a slice lists; under `exercised`, the ones a slice
123
+ // that implements a behavior lists and also claims a file of (its own), and the ones a verification exercises.
108
124
  const used = new Set<string>();
109
- for (const slice of model.slices) for (const id of slice.meta.usesResources) used.add(id);
125
+ for (const slice of model.slices) {
126
+ const implementing = (graph.artifacts.get(slice.id)?.meta.links.implements ?? []).length > 0;
127
+ for (const id of slice.meta.usesResources) {
128
+ if (resourceMode === "used") used.add(id);
129
+ else if (implementing) {
130
+ const files = new Set(resources.get(id)?.files ?? []);
131
+ if ((sliceFiles.get(slice.id) ?? []).some((file) => files.has(file))) used.add(id);
132
+ }
133
+ }
134
+ }
110
135
  for (const artifact of graph.artifacts.values()) {
111
136
  covered.add(artifact.path);
112
137
  const verification = artifact.meta.verification;
@@ -120,5 +145,15 @@ export function subjectSource(
120
145
  return covered.has(path);
121
146
  };
122
147
 
123
- return { readFile: options.readFile, sliceFiles, resources, localImports, globalInputs, covers };
148
+ const dependencyMode = options.dependencies ?? DEFAULT_EVIDENCE_DEPENDENCIES;
149
+ return {
150
+ readFile: options.readFile,
151
+ sliceFiles,
152
+ resources,
153
+ localImports,
154
+ globalInputs,
155
+ resourceMode,
156
+ dependencyMode,
157
+ covers,
158
+ };
124
159
  }