@mnstry/atelier 0.2.0-alpha.4 → 0.2.0-alpha.5
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/CHANGELOG.md +62 -0
- package/README.md +38 -12
- package/contracts/public-api-baseline.json +57 -0
- package/docs/assurance-controls.md +39 -0
- package/docs/atelier-runtime.md +15 -0
- package/docs/blocks/claims.md +15 -9
- package/docs/design.md +12 -6
- package/docs/install.md +26 -4
- package/docs/knowledge-graph.md +8 -4
- package/docs/local-services.md +101 -0
- package/docs/release-engineering.md +75 -10
- package/docs/repo-boundary-guard.md +12 -2
- package/docs/upgrade.md +25 -2
- package/fixtures/projects/sample-workspace/content/source.html.kg.json +4 -1
- package/fixtures/projects/source-formats-workspace/content/data.json.kg.json +4 -1
- package/fixtures/projects/source-formats-workspace/content/logo.png.kg.json +4 -1
- package/fixtures/projects/source-formats-workspace/content/metrics.csv.kg.json +4 -1
- package/fixtures/projects/source-formats-workspace/content/pipeline.yaml.kg.json +4 -1
- package/package.json +12 -5
- package/skills/claude/atelier-local-service/SKILL.md +47 -0
- package/skills/claude/atelier-public-boundary/SKILL.md +31 -0
- package/skills/codex/atelier-local-service/SKILL.md +47 -0
- package/skills/codex/atelier-public-boundary/SKILL.md +31 -0
- package/src/boundary/content-rules.mjs +278 -20
- package/src/boundary/policy.mjs +150 -60
- package/src/cli/execute-command.mjs +36 -0
- package/src/cli/run.mjs +17 -7
- package/src/collaboration/event-ledger.mjs +365 -0
- package/src/collaboration/index.mjs +17 -0
- package/src/collaboration/proposals.mjs +265 -65
- package/src/commands/attestation.mjs +20 -6
- package/src/commands/disclosure.mjs +133 -0
- package/src/commands/distribution.mjs +2 -1
- package/src/commands/extension-pack.mjs +2 -1
- package/src/commands/init.mjs +2 -1
- package/src/commands/server.mjs +1 -4
- package/src/disclosure/content-scan.mjs +193 -0
- package/src/egress/check.mjs +7 -38
- package/src/egress/forbidden-egress.mjs +32 -18
- package/src/graph/graph.mjs +112 -314
- package/src/graph/knowledge-graph.mjs +94 -18
- package/src/harness/context-client.mjs +9 -1
- package/src/index.mjs +12 -0
- package/src/project/config.mjs +66 -7
- package/src/project/file-class.mjs +14 -0
- package/src/project/package-root.mjs +10 -0
- package/src/project/path-match.mjs +38 -15
- package/src/project/private-state.mjs +110 -0
- package/src/server/local-sidecar.mjs +81 -59
- package/src/server/security.mjs +89 -4
- package/src/server/server.mjs +3 -2
- package/src/support/feedback-report.mjs +4 -3
- package/src/upgrade/upgrade.mjs +2 -1
package/src/graph/graph.mjs
CHANGED
|
@@ -1,261 +1,120 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
2
|
import path from 'node:path'
|
|
3
|
-
import { commandProject, gitRemoteUrl, loadRepoAccess,
|
|
4
|
-
import {
|
|
3
|
+
import { commandProject, gitRemoteUrl, loadRepoAccess, remoteHost, writeJson } from '../project/config.mjs'
|
|
4
|
+
import { VALID_AUDIENCES as PROJECTION_AUDIENCES } from '../projection/policy.mjs'
|
|
5
|
+
import {
|
|
6
|
+
REPO_ACCESS_SCHEMA,
|
|
7
|
+
VALID_RELATION_TYPES,
|
|
8
|
+
buildKnowledgeGraph,
|
|
9
|
+
parseYamlSubset,
|
|
10
|
+
} from './knowledge-graph.mjs'
|
|
11
|
+
|
|
12
|
+
// Compatibility exports. Parsing, census, validation, and diagnostics all live
|
|
13
|
+
// in knowledge-graph.mjs; this module only projects its canonical result into
|
|
14
|
+
// the long-standing `atelier graph` artifact shape.
|
|
15
|
+
export const VALID_AUDIENCES = PROJECTION_AUDIENCES
|
|
16
|
+
export const VALID_RELATIONS = VALID_RELATION_TYPES
|
|
17
|
+
export const parseFrontmatterYaml = parseYamlSubset
|
|
18
|
+
|
|
19
|
+
function canonicalInput(project) {
|
|
20
|
+
const loadedAccess = loadRepoAccess(project)
|
|
21
|
+
const managed = []
|
|
22
|
+
const missing = []
|
|
23
|
+
const accessRepos = {}
|
|
5
24
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const slug = (value) => String(value ?? '').toLowerCase().replace(/\.[^.]+$/, '').replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '')
|
|
12
|
-
const relPath = (root, file) => path.relative(root, file).split(path.sep).join('/')
|
|
13
|
-
|
|
14
|
-
// Sidecar-first census. Document extensions are always sources; any other
|
|
15
|
-
// file — json, yaml, csv, binary assets — opts in by carrying an adjacent
|
|
16
|
-
// .kg.json sidecar. The sidecar itself is metadata, never a source asset.
|
|
17
|
-
//
|
|
18
|
-
// Membership asks whether the sidecar is VISIBLE, not whether it happens to
|
|
19
|
-
// exist on this disk. A git-ignored sidecar is machine-local: obeying one
|
|
20
|
-
// enrolls a node that no tracked file declares — audience and all — so a
|
|
21
|
-
// clean checkout builds a different graph than the machine that wrote it.
|
|
22
|
-
function isSourceFile(name, sidecarVisible) {
|
|
23
|
-
if (name.endsWith('.kg.json')) return false
|
|
24
|
-
if (DOC_EXTS.has(path.extname(name).toLowerCase())) return true
|
|
25
|
-
return sidecarVisible === true
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function sidecarIsVisible(abs, root, isIgnored) {
|
|
29
|
-
const sidecar = sidecarFor(abs)
|
|
30
|
-
return fs.existsSync(sidecar) && !isIgnored(relPath(root, sidecar))
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function walk(dir, root, acc = [], isIgnored = gitIgnoreFilter(root)) {
|
|
34
|
-
for (const ent of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
35
|
-
if (ent.name.startsWith('.') || SKIP_DIRS.has(ent.name)) continue
|
|
36
|
-
const abs = path.join(dir, ent.name)
|
|
37
|
-
if (isIgnored(relPath(root, abs))) continue
|
|
38
|
-
if (ent.isDirectory()) walk(abs, root, acc, isIgnored)
|
|
39
|
-
if (!ent.isFile() || ent.name.endsWith('.kg.json')) continue
|
|
40
|
-
const ext = path.extname(ent.name).toLowerCase()
|
|
41
|
-
// Markdown carries its own front matter and never consults a sidecar.
|
|
42
|
-
const sidecarVisible = ext === '.md' ? false : sidecarIsVisible(abs, root, isIgnored)
|
|
43
|
-
if (isSourceFile(ent.name, sidecarVisible)) acc.push({ abs, rel: relPath(root, abs), ext, sidecarVisible })
|
|
44
|
-
}
|
|
45
|
-
return acc
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function splitFrontmatter(raw) {
|
|
49
|
-
if (!raw.startsWith('---\n')) return null
|
|
50
|
-
const end = raw.indexOf('\n---', 4)
|
|
51
|
-
if (end === -1) return null
|
|
52
|
-
return raw.slice(4, end)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function parseValue(value) {
|
|
56
|
-
const text = String(value ?? '').trim()
|
|
57
|
-
if (!text) return ''
|
|
58
|
-
if ((text.startsWith('"') && text.endsWith('"')) || (text.startsWith("'") && text.endsWith("'"))) return text.slice(1, -1)
|
|
59
|
-
if (text === 'true') return true
|
|
60
|
-
if (text === 'false') return false
|
|
61
|
-
return text
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function setPath(target, keys, value) {
|
|
65
|
-
let cursor = target
|
|
66
|
-
for (const key of keys.slice(0, -1)) {
|
|
67
|
-
cursor[key] ??= {}
|
|
68
|
-
cursor = cursor[key]
|
|
69
|
-
}
|
|
70
|
-
cursor[keys.at(-1)] = value
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function parseFrontmatterYaml(yaml) {
|
|
74
|
-
const out = {}
|
|
75
|
-
const lines = String(yaml ?? '').split('\n')
|
|
76
|
-
const stack = [{ indent: -1, value: out, key: null }]
|
|
77
|
-
for (let index = 0; index < lines.length; index += 1) {
|
|
78
|
-
const raw = lines[index]
|
|
79
|
-
if (!raw.trim() || raw.trim().startsWith('#')) continue
|
|
80
|
-
const indent = raw.match(/^\s*/)[0].length
|
|
81
|
-
const line = raw.trim()
|
|
82
|
-
while (stack.length > 1 && indent <= stack.at(-1).indent) stack.pop()
|
|
83
|
-
const parent = stack.at(-1).value
|
|
84
|
-
if (line.startsWith('- ')) {
|
|
85
|
-
if (!Array.isArray(parent)) continue
|
|
86
|
-
parent.push(parseValue(line.slice(2)))
|
|
25
|
+
for (const repo of project.repos ?? []) {
|
|
26
|
+
if (repo.external) continue
|
|
27
|
+
if (!repo.name || !repo.path || !fs.existsSync(repo.path)) {
|
|
28
|
+
missing.push(`configured repo is missing or unreadable: ${repo.name ?? '(unnamed)'}`)
|
|
87
29
|
continue
|
|
88
30
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
parent[key] = nextYamlContainer(lines, index, indent)
|
|
94
|
-
stack.push({ indent, value: parent[key], key })
|
|
95
|
-
} else if (rest === '[]') {
|
|
96
|
-
parent[key] = []
|
|
97
|
-
stack.push({ indent, value: parent[key], key })
|
|
98
|
-
} else {
|
|
99
|
-
parent[key] = parseValue(rest)
|
|
31
|
+
managed.push({ name: repo.name, path: repo.path })
|
|
32
|
+
accessRepos[repo.name] = {
|
|
33
|
+
readBoundary:
|
|
34
|
+
loadedAccess.repos?.[repo.name]?.readBoundary ?? repo.readBoundary ?? loadedAccess.defaultReadBoundary ?? 'team',
|
|
100
35
|
}
|
|
101
36
|
}
|
|
102
|
-
return out
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function nextYamlContainer(lines, fromIndex, indent) {
|
|
106
|
-
for (let index = fromIndex + 1; index < lines.length; index += 1) {
|
|
107
|
-
const raw = lines[index]
|
|
108
|
-
if (!raw.trim() || raw.trim().startsWith('#')) continue
|
|
109
|
-
const nextIndent = raw.match(/^\s*/)[0].length
|
|
110
|
-
if (nextIndent <= indent) return {}
|
|
111
|
-
return raw.trim().startsWith('- ') ? [] : {}
|
|
112
|
-
}
|
|
113
|
-
return {}
|
|
114
|
-
}
|
|
115
37
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
38
|
+
return {
|
|
39
|
+
missing,
|
|
40
|
+
options: {
|
|
41
|
+
workspaceRoot: project.workspaceRoot,
|
|
42
|
+
repoEntries: managed,
|
|
43
|
+
repoAccessConfig: {
|
|
44
|
+
schema: REPO_ACCESS_SCHEMA,
|
|
45
|
+
defaultReadBoundary: loadedAccess.defaultReadBoundary ?? 'team',
|
|
46
|
+
repos: accessRepos,
|
|
47
|
+
},
|
|
48
|
+
repoAccessConfigPath: project.repoAccessPath,
|
|
49
|
+
externalRelationPrefixes: Array.isArray(project.config.graph?.externalRelationPrefixes)
|
|
50
|
+
? project.config.graph.externalRelationPrefixes
|
|
51
|
+
: [],
|
|
52
|
+
externalRelationIds: Array.isArray(project.config.graph?.externalRelationIds) ? project.config.graph.externalRelationIds : [],
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function compatibilityError(message) {
|
|
58
|
+
return String(message)
|
|
59
|
+
.replace(': missing non-Markdown sidecar ', ': non-Markdown source requires sidecar ')
|
|
60
|
+
.replace(/: active orphan sidecar has no adjacent source .+$/, ': sidecar has no matching source asset')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function compatibilityNode(node) {
|
|
64
|
+
return {
|
|
65
|
+
id: node.id,
|
|
66
|
+
title: node.title,
|
|
67
|
+
summary: node.summary,
|
|
68
|
+
repo: node.repo,
|
|
69
|
+
path: node.path,
|
|
70
|
+
type: node.kgType,
|
|
71
|
+
status: node.status,
|
|
72
|
+
audience: node.audience,
|
|
73
|
+
...(node.classification === 'unclassified'
|
|
74
|
+
? { classification: 'unclassified', classificationReason: node.classificationReason }
|
|
75
|
+
: {}),
|
|
76
|
+
tags: node.tags,
|
|
77
|
+
relations: node.relations,
|
|
78
|
+
repoAccess: node.repoAccess,
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function compatibilityDiagnostic(diagnostic) {
|
|
83
|
+
if (diagnostic.code === 'unclassified-content') return diagnostic
|
|
84
|
+
return {
|
|
85
|
+
severity: diagnostic.severity,
|
|
86
|
+
code: 'audience-wider-repo-boundary',
|
|
87
|
+
node: diagnostic.node,
|
|
88
|
+
message: diagnostic.message,
|
|
123
89
|
}
|
|
124
|
-
return out
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function sidecarFor(file) {
|
|
128
|
-
return `${file}.kg.json`
|
|
129
90
|
}
|
|
130
91
|
|
|
131
|
-
function
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
92
|
+
function externalRepos(project) {
|
|
93
|
+
return (project.repos ?? [])
|
|
94
|
+
.filter((repo) => repo.external)
|
|
95
|
+
.map((repo) => ({
|
|
96
|
+
name: repo.name,
|
|
97
|
+
path: repo.path ?? null,
|
|
98
|
+
remoteHost: remoteHost(gitRemoteUrl(repo.path)),
|
|
99
|
+
}))
|
|
100
|
+
.sort((a, b) => String(a.name).localeCompare(String(b.name)))
|
|
140
101
|
}
|
|
141
102
|
|
|
142
|
-
function
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
const parsed = parseFrontmatterYaml(fm)
|
|
147
|
-
const kg = parsed.kg ?? {}
|
|
148
|
-
if (!kg.id) errors.push(`${repo.name}/${file.rel}: kg.id is required`)
|
|
149
|
-
if (!kg.audience) errors.push(`${repo.name}/${file.rel}: kg.audience is required`)
|
|
150
|
-
if (kg.visibility) errors.push(`${repo.name}/${file.rel}: kg.visibility is invalid; use kg.audience`)
|
|
151
|
-
return {
|
|
152
|
-
id: kg.id || `${repo.name}:${slug(file.rel)}`,
|
|
153
|
-
title: parsed.title || kg.title || path.basename(file.rel, file.ext),
|
|
154
|
-
summary: parsed.summary || '',
|
|
155
|
-
repo: repo.name,
|
|
156
|
-
path: file.rel,
|
|
157
|
-
type: kg.type || 'document',
|
|
158
|
-
status: kg.status || 'active',
|
|
159
|
-
audience: kg.audience || 'private',
|
|
160
|
-
tags: Array.isArray(parsed.tags) ? parsed.tags : [],
|
|
161
|
-
relations: normalizeRelations(kg.relations),
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function nodeFromSidecar(repo, file, errors) {
|
|
166
|
-
const sidecar = sidecarFor(file.abs)
|
|
167
|
-
// Visibility again, and for the same reason: a git-ignored sidecar must not
|
|
168
|
-
// supply identity, audience, or relations. A document-extension asset whose
|
|
169
|
-
// only sidecar is ignored therefore fails closed with the ordinary
|
|
170
|
-
// missing-sidecar error — the same verdict a clean checkout reaches.
|
|
171
|
-
if (!file.sidecarVisible) {
|
|
172
|
-
errors.push(`${repo.name}/${file.rel}: non-Markdown source requires sidecar ${path.basename(sidecar)}`)
|
|
173
|
-
return null
|
|
174
|
-
}
|
|
175
|
-
const meta = readJson(sidecar)
|
|
176
|
-
validateSidecar(meta, repo, file, errors)
|
|
177
|
-
const kg = meta.kg ?? {}
|
|
178
|
-
if (meta.assetFilename && meta.assetFilename !== path.basename(file.abs)) errors.push(`${repo.name}/${file.rel}: sidecar assetFilename must match source filename`)
|
|
179
|
-
if (!kg.id) errors.push(`${repo.name}/${file.rel}: sidecar kg.id is required`)
|
|
180
|
-
if (!kg.audience) errors.push(`${repo.name}/${file.rel}: sidecar kg.audience is required`)
|
|
181
|
-
if (kg.visibility) errors.push(`${repo.name}/${file.rel}: sidecar kg.visibility is invalid; use kg.audience`)
|
|
182
|
-
return {
|
|
183
|
-
id: kg.id || `${repo.name}:${slug(file.rel)}-${file.ext.slice(1)}`,
|
|
184
|
-
title: meta.title || kg.title || path.basename(file.rel, file.ext),
|
|
185
|
-
summary: meta.summary || '',
|
|
186
|
-
repo: repo.name,
|
|
187
|
-
path: file.rel,
|
|
188
|
-
type: kg.type || file.ext.slice(1),
|
|
189
|
-
status: kg.status || 'active',
|
|
190
|
-
audience: kg.audience || 'private',
|
|
191
|
-
tags: Array.isArray(meta.tags) ? meta.tags : [],
|
|
192
|
-
relations: normalizeRelations(kg.relations),
|
|
193
|
-
}
|
|
103
|
+
function canonicalBuild(project) {
|
|
104
|
+
const input = canonicalInput(project)
|
|
105
|
+
const result = buildKnowledgeGraph(input.options)
|
|
106
|
+
return { input, result }
|
|
194
107
|
}
|
|
195
108
|
|
|
196
109
|
export function buildGraph(project) {
|
|
197
|
-
const
|
|
198
|
-
const
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
const
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
for (const repo of project.repos) {
|
|
207
|
-
if (repo.external) {
|
|
208
|
-
// Identity acknowledged, nothing walked: the workspace does not own this
|
|
209
|
-
// content and cannot answer for its metadata.
|
|
210
|
-
external.push({ name: repo.name, path: repo.path ?? null, remoteHost: remoteHost(gitRemoteUrl(repo.path)) })
|
|
211
|
-
continue
|
|
212
|
-
}
|
|
213
|
-
if (!repo.name || !repo.path || !fs.existsSync(repo.path)) {
|
|
214
|
-
errors.push(`configured repo is missing or unreadable: ${repo.name ?? '(unnamed)'}`)
|
|
215
|
-
continue
|
|
216
|
-
}
|
|
217
|
-
// One batched ignore lookup per repo, shared by every walk below.
|
|
218
|
-
const isIgnored = gitIgnoreFilter(repo.path)
|
|
219
|
-
for (const file of walk(repo.path, repo.path, [], isIgnored)) {
|
|
220
|
-
// Markdown is the one inline metadata format; every other source is
|
|
221
|
-
// sidecar-described and its own bytes are never read.
|
|
222
|
-
const node = file.ext === '.md' ? nodeFromMarkdown(repo, file, errors) : nodeFromSidecar(repo, file, errors)
|
|
223
|
-
if (!node) continue
|
|
224
|
-
const boundary = repoAccess.repos?.[repo.name]?.readBoundary ?? repo.readBoundary ?? repoAccess.defaultReadBoundary ?? 'team'
|
|
225
|
-
node.repoAccess = { readBoundary: boundary }
|
|
226
|
-
if (['private', 'sensitive'].includes(node.audience) && boundary !== 'private') {
|
|
227
|
-
diagnostics.push({
|
|
228
|
-
severity: 'warning',
|
|
229
|
-
code: 'audience-wider-repo-boundary',
|
|
230
|
-
node: node.id,
|
|
231
|
-
message: `${node.id}: audience ${node.audience} is in a ${boundary}-readable repo`,
|
|
232
|
-
})
|
|
233
|
-
}
|
|
234
|
-
nodes.push(node)
|
|
235
|
-
}
|
|
236
|
-
for (const orphan of findOrphanSidecars(repo.path, isIgnored)) {
|
|
237
|
-
errors.push(`${repo.name}/${orphan}: sidecar has no matching source asset`)
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const ids = new Set()
|
|
242
|
-
for (const node of nodes) {
|
|
243
|
-
if (ids.has(node.id)) errors.push(`duplicate kg.id: ${node.id}`)
|
|
244
|
-
ids.add(node.id)
|
|
245
|
-
if (!VALID_AUDIENCES.has(node.audience)) errors.push(`${node.id}: invalid audience ${node.audience}`)
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
for (const node of nodes) {
|
|
249
|
-
for (const [type, targets] of Object.entries(node.relations ?? {})) {
|
|
250
|
-
if (!VALID_RELATIONS.has(type)) errors.push(`${node.id}: invalid relation type ${type}`)
|
|
251
|
-
for (const target of targets) {
|
|
252
|
-
if (!ids.has(target) && !isExternalRelationTarget(target, { externalRelationPrefixes, externalRelationIds })) {
|
|
253
|
-
errors.push(`${node.id}: relation target not found: ${target}`)
|
|
254
|
-
}
|
|
255
|
-
edges.push({ source: node.id, target, type, declared: true })
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
110
|
+
const { input, result } = canonicalBuild(project)
|
|
111
|
+
const canonical = result.workspaceGraph ?? { nodes: [], edges: [], diagnostics: [] }
|
|
112
|
+
const nodes = canonical.nodes.map(compatibilityNode)
|
|
113
|
+
// The legacy artifact exposes declared relations only. Derived Markdown-link
|
|
114
|
+
// edges remain available from buildKnowledgeGraph without changing this API.
|
|
115
|
+
const edges = canonical.edges.filter((edge) => edge.declared === true)
|
|
116
|
+
const diagnostics = canonical.diagnostics.map(compatibilityDiagnostic)
|
|
117
|
+
const errors = [...input.missing, ...result.errors.map(compatibilityError)]
|
|
259
118
|
|
|
260
119
|
return {
|
|
261
120
|
schema: 'mnstry.atelier-knowledge-graph@v1',
|
|
@@ -265,83 +124,22 @@ export function buildGraph(project) {
|
|
|
265
124
|
nodes,
|
|
266
125
|
edges,
|
|
267
126
|
diagnostics,
|
|
268
|
-
external:
|
|
127
|
+
external: externalRepos(project),
|
|
269
128
|
errors,
|
|
270
129
|
}
|
|
271
130
|
}
|
|
272
131
|
|
|
273
|
-
|
|
274
|
-
if (externalRelationIds.has(target)) return true
|
|
275
|
-
const prefix = String(target).split(':')[0]
|
|
276
|
-
return externalRelationPrefixes.has(prefix)
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function findOrphanSidecars(root, isIgnored = gitIgnoreFilter(root)) {
|
|
280
|
-
const orphans = []
|
|
281
|
-
function visit(dir) {
|
|
282
|
-
for (const ent of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
283
|
-
if (ent.name.startsWith('.') || SKIP_DIRS.has(ent.name)) continue
|
|
284
|
-
const abs = path.join(dir, ent.name)
|
|
285
|
-
if (isIgnored(relPath(root, abs))) continue
|
|
286
|
-
if (ent.isDirectory()) visit(abs)
|
|
287
|
-
else if (ent.isFile() && ent.name.endsWith('.kg.json')) {
|
|
288
|
-
const asset = abs.slice(0, -'.kg.json'.length)
|
|
289
|
-
if (!fs.existsSync(asset)) orphans.push(relPath(root, abs))
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
visit(root)
|
|
294
|
-
return orphans
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// Sidecars that exist on disk but are git-ignored, next to a file the census
|
|
298
|
-
// can see. Refused, never obeyed — and never silently: dropping them without a
|
|
299
|
-
// word is what let an untracked sidecar mint a public node.
|
|
300
|
-
function findIgnoredSidecars(root, isIgnored = gitIgnoreFilter(root)) {
|
|
301
|
-
const found = []
|
|
302
|
-
function visit(dir) {
|
|
303
|
-
for (const ent of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
304
|
-
if (ent.name.startsWith('.') || SKIP_DIRS.has(ent.name)) continue
|
|
305
|
-
const abs = path.join(dir, ent.name)
|
|
306
|
-
const rel = relPath(root, abs)
|
|
307
|
-
if (ent.isDirectory()) {
|
|
308
|
-
if (!isIgnored(rel)) visit(abs)
|
|
309
|
-
continue
|
|
310
|
-
}
|
|
311
|
-
if (!ent.isFile() || !ent.name.endsWith('.kg.json') || !isIgnored(rel)) continue
|
|
312
|
-
const assetRel = rel.slice(0, -'.kg.json'.length)
|
|
313
|
-
// Nothing was refused if the asset is itself machine-local or absent, and
|
|
314
|
-
// Markdown never reads a sidecar in the first place.
|
|
315
|
-
if (assetRel.toLowerCase().endsWith('.md')) continue
|
|
316
|
-
if (isIgnored(assetRel) || !fs.existsSync(path.join(root, assetRel))) continue
|
|
317
|
-
found.push({ path: assetRel, sidecar: rel })
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
visit(root)
|
|
321
|
-
return found
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// Deliberately NOT part of buildGraph's return value: that object is written
|
|
325
|
-
// verbatim to the graph artifact, so a machine-local observation inside it
|
|
326
|
-
// would make the artifact differ between a developer's tree and a clean
|
|
327
|
-
// checkout — the exact churn the ignore filter exists to prevent. The operator
|
|
328
|
-
// hears about the refusal; the shared artifact never does.
|
|
132
|
+
// Machine-local ignored-sidecar observations stay outside generated artifacts.
|
|
329
133
|
export function ignoredSidecarWarnings(project) {
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
sidecar: found.sidecar,
|
|
340
|
-
message: `${repo.name}/${found.sidecar}: sidecar is git-ignored and was refused; it cannot enroll ${found.path} or describe it`,
|
|
341
|
-
})
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
return warnings
|
|
134
|
+
const { result } = canonicalBuild(project)
|
|
135
|
+
return (result.ignoredSidecars ?? []).map((found) => ({
|
|
136
|
+
severity: 'warning',
|
|
137
|
+
code: 'ignored-sidecar',
|
|
138
|
+
repo: found.repo,
|
|
139
|
+
path: found.path,
|
|
140
|
+
sidecar: found.sidecar,
|
|
141
|
+
message: `${found.repo}/${found.sidecar}: sidecar is git-ignored and was refused; it cannot enroll ${found.path} or describe it`,
|
|
142
|
+
}))
|
|
345
143
|
}
|
|
346
144
|
|
|
347
145
|
export function runGraphCommand(argv = process.argv.slice(2)) {
|