agent-doc-system 0.0.0-stage → 1.0.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.
- package/INSTALL_FOR_AGENTS.md +60 -0
- package/LICENSE +21 -0
- package/README.md +151 -2
- package/adapters/cache.mjs +27 -0
- package/adapters/contract-consumers.mjs +56 -0
- package/adapters/database.mjs +116 -0
- package/adapters/deploy-config.mjs +34 -0
- package/adapters/dockerfile.mjs +26 -0
- package/adapters/events.mjs +145 -0
- package/adapters/generic.mjs +86 -0
- package/adapters/github-actions.mjs +106 -0
- package/adapters/go.mjs +91 -0
- package/adapters/graphql.mjs +28 -0
- package/adapters/index.mjs +55 -0
- package/adapters/node.mjs +118 -0
- package/adapters/object-store.mjs +64 -0
- package/adapters/oidc.mjs +56 -0
- package/adapters/openapi.mjs +50 -0
- package/adapters/pnpm.mjs +42 -0
- package/adapters/protobuf.mjs +35 -0
- package/adapters/registry.mjs +27 -0
- package/adapters/resource-client.mjs +61 -0
- package/adapters/turborepo.mjs +135 -0
- package/adapters/typescript.mjs +85 -0
- package/adapters/wrangler.mjs +206 -0
- package/bin/agentdoc.mjs +478 -0
- package/bin/usage.txt +26 -0
- package/core/acceptances.mjs +69 -0
- package/core/audit.mjs +407 -0
- package/core/authority/classes.mjs +39 -0
- package/core/authority/engine.mjs +243 -0
- package/core/authority/facts.mjs +41 -0
- package/core/codes.mjs +119 -0
- package/core/compile.mjs +881 -0
- package/core/contracts.mjs +121 -0
- package/core/derive.mjs +102 -0
- package/core/descriptors.mjs +486 -0
- package/core/determinism.mjs +95 -0
- package/core/discover.mjs +147 -0
- package/core/facts.mjs +53 -0
- package/core/fsx.mjs +342 -0
- package/core/graph.mjs +260 -0
- package/core/impact.mjs +175 -0
- package/core/indexes.mjs +165 -0
- package/core/jsonschema.mjs +298 -0
- package/core/observations.mjs +129 -0
- package/core/provenance.mjs +83 -0
- package/core/query.mjs +384 -0
- package/core/relations.mjs +286 -0
- package/core/scaffold.mjs +322 -0
- package/core/secrets.mjs +92 -0
- package/core/sourcescan.mjs +88 -0
- package/core/toml.mjs +163 -0
- package/core/yaml.mjs +475 -0
- package/docs/ADAPTERS.md +172 -0
- package/docs/AUTHORITY.md +260 -0
- package/docs/CI.md +136 -0
- package/docs/COMPARISON-KODA.md +164 -0
- package/docs/EVALS.md +166 -0
- package/docs/MIGRATION.md +193 -0
- package/docs/PROVENANCE.md +133 -0
- package/docs/QUERY.md +180 -0
- package/docs/SPEC.md +339 -0
- package/docs/VERIFICATION.md +28 -0
- package/docs/ci/generic-ci.sh +28 -0
- package/docs/ci/github-actions.yml +35 -0
- package/evals/harness.mjs +426 -0
- package/evals/scenarios/fixture-a-01-change-api.json +9 -0
- package/evals/scenarios/fixture-a-02-change-db.json +9 -0
- package/evals/scenarios/fixture-a-03-enforce-constraint.json +9 -0
- package/evals/scenarios/fixture-b-01-change-proto.json +9 -0
- package/evals/scenarios/fixture-b-02-change-write-path.json +9 -0
- package/evals/scenarios/fixture-b-03-change-shared-lib.json +9 -0
- package/evals/scenarios/fixture-b-04-journey.json +9 -0
- package/evals/scenarios/fixture-c-01-mixed-runtime-edge.json +19 -0
- package/evals/scenarios/fixture-c-02-stale-doc-contradiction.json +9 -0
- package/evals/scenarios/fixture-c-03-shared-vocabulary.json +9 -0
- package/evals/scenarios/fixture-c-04-contract-change.json +9 -0
- package/evals/scenarios/koda-01-modify-api-consumer.json +26 -0
- package/evals/scenarios/koda-02-change-db-schema.json +20 -0
- package/evals/scenarios/koda-03-change-auth.json +21 -0
- package/evals/scenarios/koda-04-add-event-producer.json +19 -0
- package/evals/scenarios/koda-05-modify-worker-binding.json +25 -0
- package/evals/scenarios/koda-06-change-cross-component-endpoint.json +22 -0
- package/evals/scenarios/koda-07-change-shared-package.json +16 -0
- package/evals/scenarios/koda-08-change-runtime-cron.json +23 -0
- package/evals/scenarios/koda-09-debug-production-mismatch.json +26 -0
- package/evals/thresholds.json +11 -0
- package/package.json +46 -4
- package/schemas/api.schema.json +84 -0
- package/schemas/common.schema.json +107 -0
- package/schemas/component.schema.json +40 -0
- package/schemas/config.schema.json +685 -0
- package/schemas/domain.schema.json +14 -0
- package/schemas/graph.schema.json +1084 -0
- package/schemas/journeys.schema.json +47 -0
- package/schemas/observation.schema.json +143 -0
- package/schemas/resource.schema.json +28 -0
- package/schemas/system.schema.json +26 -0
- package/skills/agent-doc-system/SKILL.md +113 -0
- package/skills/agent-doc-system/references/authority-and-conflicts.md +70 -0
- package/skills/agent-doc-system/references/cli.md +89 -0
- package/skills/agent-doc-system/references/create-migrate.md +101 -0
- package/skills/agent-doc-system/references/maintenance.md +52 -0
- package/templates/ADR.md +26 -0
- package/templates/ARCHITECTURE.md +19 -0
- package/templates/CONSTRAINTS.md +17 -0
- package/templates/PRODUCT.md +17 -0
- package/templates/api.yaml +10 -0
- package/templates/ci.yml +31 -0
- package/templates/component.yaml +14 -0
- package/templates/domain.yaml +6 -0
- package/templates/journey.yaml +7 -0
- package/templates/observation.yaml +19 -0
- package/templates/resource.yaml +8 -0
- package/templates/system.yaml +10 -0
- package/templates/warning-acceptance.yaml +14 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "agentdoc.dev/schema/journeys.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": [
|
|
7
|
+
"schemaVersion",
|
|
8
|
+
"journeys"
|
|
9
|
+
],
|
|
10
|
+
"properties": {
|
|
11
|
+
"schemaVersion": {
|
|
12
|
+
"const": "agentdoc.dev/journeys/v1"
|
|
13
|
+
},
|
|
14
|
+
"journeys": {
|
|
15
|
+
"type": "array",
|
|
16
|
+
"minItems": 0,
|
|
17
|
+
"items": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"additionalProperties": false,
|
|
20
|
+
"required": [
|
|
21
|
+
"id",
|
|
22
|
+
"description",
|
|
23
|
+
"components"
|
|
24
|
+
],
|
|
25
|
+
"properties": {
|
|
26
|
+
"id": {
|
|
27
|
+
"$ref": "common.json#/$defs/name"
|
|
28
|
+
},
|
|
29
|
+
"description": {
|
|
30
|
+
"$ref": "common.json#/$defs/description"
|
|
31
|
+
},
|
|
32
|
+
"components": {
|
|
33
|
+
"type": "array",
|
|
34
|
+
"minItems": 2,
|
|
35
|
+
"uniqueItems": true,
|
|
36
|
+
"items": {
|
|
37
|
+
"$ref": "common.json#/$defs/componentRef"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"notes": {
|
|
41
|
+
"$ref": "common.json#/$defs/rationale"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "agentdoc.dev/schema/observation.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": [
|
|
7
|
+
"apiVersion",
|
|
8
|
+
"kind",
|
|
9
|
+
"metadata",
|
|
10
|
+
"spec"
|
|
11
|
+
],
|
|
12
|
+
"properties": {
|
|
13
|
+
"apiVersion": {
|
|
14
|
+
"const": "agentdoc.dev/observation/v1"
|
|
15
|
+
},
|
|
16
|
+
"kind": {
|
|
17
|
+
"const": "ObservationSet"
|
|
18
|
+
},
|
|
19
|
+
"metadata": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"additionalProperties": false,
|
|
22
|
+
"required": [
|
|
23
|
+
"name",
|
|
24
|
+
"description",
|
|
25
|
+
"environment",
|
|
26
|
+
"capturedAt",
|
|
27
|
+
"sourceSystem",
|
|
28
|
+
"collector",
|
|
29
|
+
"evidenceBundle"
|
|
30
|
+
],
|
|
31
|
+
"properties": {
|
|
32
|
+
"name": {
|
|
33
|
+
"$ref": "common.json#/$defs/name"
|
|
34
|
+
},
|
|
35
|
+
"description": {
|
|
36
|
+
"$ref": "common.json#/$defs/description"
|
|
37
|
+
},
|
|
38
|
+
"environment": {
|
|
39
|
+
"description": "Which environment the observation describes. Never a secret-bearing identifier.",
|
|
40
|
+
"type": "string",
|
|
41
|
+
"minLength": 1,
|
|
42
|
+
"maxLength": 60,
|
|
43
|
+
"pattern": "^[a-z0-9][a-z0-9._-]*$"
|
|
44
|
+
},
|
|
45
|
+
"capturedAt": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
|
|
48
|
+
},
|
|
49
|
+
"maxAgeDays": {
|
|
50
|
+
"type": "integer",
|
|
51
|
+
"minimum": 1,
|
|
52
|
+
"maximum": 3650
|
|
53
|
+
},
|
|
54
|
+
"sourceSystem": {
|
|
55
|
+
"description": "The authoritative external system the facts came from.",
|
|
56
|
+
"type": "string",
|
|
57
|
+
"minLength": 1,
|
|
58
|
+
"maxLength": 80,
|
|
59
|
+
"pattern": "^[a-z0-9][a-z0-9._-]*$"
|
|
60
|
+
},
|
|
61
|
+
"collector": {
|
|
62
|
+
"description": "Retrieval method identity: the command or API used to read the source system.",
|
|
63
|
+
"type": "string",
|
|
64
|
+
"minLength": 1,
|
|
65
|
+
"maxLength": 120,
|
|
66
|
+
"pattern": "^[^\\n\\r]+$"
|
|
67
|
+
},
|
|
68
|
+
"evidenceBundle": {
|
|
69
|
+
"description": "Durable, secret-free, repository-relative reference to the raw observation. Never a temp path, host path or console URL with credentials.",
|
|
70
|
+
"$ref": "common.json#/$defs/repoPath"
|
|
71
|
+
},
|
|
72
|
+
"supersedes": {
|
|
73
|
+
"$ref": "common.json#/$defs/name"
|
|
74
|
+
},
|
|
75
|
+
"provenance": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"maxLength": 280
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"spec": {
|
|
82
|
+
"type": "object",
|
|
83
|
+
"additionalProperties": false,
|
|
84
|
+
"required": [
|
|
85
|
+
"facts"
|
|
86
|
+
],
|
|
87
|
+
"properties": {
|
|
88
|
+
"facts": {
|
|
89
|
+
"type": "array",
|
|
90
|
+
"minItems": 1,
|
|
91
|
+
"items": {
|
|
92
|
+
"type": "object",
|
|
93
|
+
"additionalProperties": false,
|
|
94
|
+
"required": [
|
|
95
|
+
"id",
|
|
96
|
+
"subject",
|
|
97
|
+
"key",
|
|
98
|
+
"value",
|
|
99
|
+
"semantics"
|
|
100
|
+
],
|
|
101
|
+
"properties": {
|
|
102
|
+
"id": {
|
|
103
|
+
"$ref": "common.json#/$defs/name"
|
|
104
|
+
},
|
|
105
|
+
"subject": {
|
|
106
|
+
"$ref": "common.json#/$defs/entityRef"
|
|
107
|
+
},
|
|
108
|
+
"key": {
|
|
109
|
+
"description": "Dotted claim key, e.g. schedule.cron, binding.kv, contract.supports-annotations.",
|
|
110
|
+
"type": "string",
|
|
111
|
+
"minLength": 1,
|
|
112
|
+
"maxLength": 80,
|
|
113
|
+
"pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
|
|
114
|
+
},
|
|
115
|
+
"value": {
|
|
116
|
+
"description": "Observed value. A JSON scalar, array of scalars, or null when the fact is known to be absent."
|
|
117
|
+
},
|
|
118
|
+
"semantics": {
|
|
119
|
+
"description": "What the observed value actually means, in one sentence.",
|
|
120
|
+
"$ref": "common.json#/$defs/rationale"
|
|
121
|
+
},
|
|
122
|
+
"observedRefs": {
|
|
123
|
+
"type": "array",
|
|
124
|
+
"maxItems": 16,
|
|
125
|
+
"uniqueItems": true,
|
|
126
|
+
"items": {
|
|
127
|
+
"$ref": "common.json#/$defs/entityRef"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"detail": {
|
|
131
|
+
"type": "string",
|
|
132
|
+
"maxLength": 600
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"extensions": {
|
|
140
|
+
"$ref": "common.json#/$defs/extensions"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "agentdoc.dev/schema/resource.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["apiVersion", "kind", "metadata", "spec"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"apiVersion": { "const": "agentdoc.dev/v1" },
|
|
9
|
+
"kind": { "const": "Resource" },
|
|
10
|
+
"metadata": { "$ref": "common.json#/$defs/metadata" },
|
|
11
|
+
"spec": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"additionalProperties": false,
|
|
14
|
+
"required": ["type"],
|
|
15
|
+
"properties": {
|
|
16
|
+
"type": { "enum": ["logical-database", "logical-dataset", "event-bus", "queue", "cache", "object-store", "search-index", "secret-store", "other"] },
|
|
17
|
+
"placementRationale": { "$ref": "common.json#/$defs/rationale" },
|
|
18
|
+
"system": { "$ref": "common.json#/$defs/name" },
|
|
19
|
+
"context": { "$ref": "common.json#/$defs/context" }
|
|
20
|
+
},
|
|
21
|
+
"oneOf": [
|
|
22
|
+
{ "required": ["system"] },
|
|
23
|
+
{ "required": ["placementRationale"] }
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"extensions": { "$ref": "common.json#/$defs/extensions" }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "agentdoc.dev/schema/system.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["apiVersion", "kind", "metadata", "spec"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"apiVersion": { "const": "agentdoc.dev/v1" },
|
|
9
|
+
"kind": { "const": "System" },
|
|
10
|
+
"metadata": { "$ref": "common.json#/$defs/metadata" },
|
|
11
|
+
"spec": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"additionalProperties": false,
|
|
14
|
+
"properties": {
|
|
15
|
+
"domain": { "$ref": "common.json#/$defs/name" },
|
|
16
|
+
"placementRationale": { "$ref": "common.json#/$defs/rationale" },
|
|
17
|
+
"context": { "$ref": "common.json#/$defs/context" }
|
|
18
|
+
},
|
|
19
|
+
"oneOf": [
|
|
20
|
+
{ "required": ["domain"], "not": { "required": ["placementRationale"] } },
|
|
21
|
+
{ "required": ["placementRationale"], "not": { "required": ["domain"] } }
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"extensions": { "$ref": "common.json#/$defs/extensions" }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agent-doc-system
|
|
3
|
+
description: Use AgentDoc to create, migrate, query, validate, and maintain an agent-oriented software catalog and documentation system for a codebase. Use when architectural context, dependency impact, documentation drift, provenance, authority conflicts, or repository documentation migration matters.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentDoc
|
|
7
|
+
|
|
8
|
+
AgentDoc is a machine-installed CLI (`agentdoc`) that compiles a repository into
|
|
9
|
+
one deterministic graph and routes a path or entity to the minimum context
|
|
10
|
+
needed to change it safely. This skill teaches you how to operate it.
|
|
11
|
+
|
|
12
|
+
## Prerequisite
|
|
13
|
+
|
|
14
|
+
The CLI must already be installed on this machine:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
agentdoc --version
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
If that fails, AgentDoc is not installed. Stop, report the missing prerequisite,
|
|
21
|
+
and point the user at `INSTALL_FOR_AGENTS.md` in the agent-doc-system
|
|
22
|
+
repository. Do not clone the source repository into the user's project — the
|
|
23
|
+
CLI is installed on the machine, never vendored into a project.
|
|
24
|
+
|
|
25
|
+
## When to use it
|
|
26
|
+
|
|
27
|
+
- The repository contains `agentdoc/agentdoc.config.yaml` — a catalog exists
|
|
28
|
+
and you are using it.
|
|
29
|
+
- You are about to change files and need to know what else must stay
|
|
30
|
+
consistent.
|
|
31
|
+
- You were asked to document a repository, audit its docs, find what depends
|
|
32
|
+
on X, or explain why production disagrees with the manifest.
|
|
33
|
+
|
|
34
|
+
Do not use it to write prose. The system routes facts; prose lives in the files
|
|
35
|
+
it points at.
|
|
36
|
+
|
|
37
|
+
## The mental model
|
|
38
|
+
|
|
39
|
+
Three kinds of claim get conflated in most repositories, and the confusion is
|
|
40
|
+
the main way an agent goes wrong:
|
|
41
|
+
|
|
42
|
+
| kind | who makes it | how it fails |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| what the repository **claims** | authored docs, config, manifests | drifts; states intent, not fact |
|
|
45
|
+
| what is **derived** from code | imports, manifests, contracts | incomplete; cannot know intent |
|
|
46
|
+
| what was **observed** running | schedulers, bindings, live APIs | goes stale; disagrees with intent |
|
|
47
|
+
|
|
48
|
+
A fact carries an evidence class, a confidence, and a pointer to its evidence.
|
|
49
|
+
When classes disagree, the disagreement is **surfaced as a conflict**, not
|
|
50
|
+
reconciled. There is no global precedence order: authority depends on the fact.
|
|
51
|
+
|
|
52
|
+
**Your obligation:** never present a claim from one class as if it came from
|
|
53
|
+
another. If the graph reports a conflict or an unresolved fact, say so.
|
|
54
|
+
|
|
55
|
+
## Pick the workflow
|
|
56
|
+
|
|
57
|
+
| workflow | when | entry point |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| CREATE | no `agentdoc/` config exists | `agentdoc init`, then `scaffold --write` |
|
|
60
|
+
| MIGRATE | established repo, scattered or stale docs | `agentdoc audit`, then work the report |
|
|
61
|
+
| VALIDATE | before committing, in CI | `agentdoc validate` → `compile` → `check` |
|
|
62
|
+
| QUERY | before and during a change | `agentdoc query <path-or-ref>` |
|
|
63
|
+
| MAINTAIN | after a change | `agentdoc impact <paths>` |
|
|
64
|
+
|
|
65
|
+
CREATE versus MIGRATE is not about size: a repository whose existing docs make
|
|
66
|
+
*claims* is a migration, because those claims must be verified. Details:
|
|
67
|
+
[references/create-migrate.md](references/create-migrate.md).
|
|
68
|
+
|
|
69
|
+
## The normal loop
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
agentdoc impact <files I will change> # what this reaches
|
|
73
|
+
agentdoc query <path> # minimum context, compact
|
|
74
|
+
agentdoc query <path> --json # full payload
|
|
75
|
+
# ... make the change ...
|
|
76
|
+
agentdoc impact <files I changed> # what must stay consistent
|
|
77
|
+
agentdoc validate && agentdoc check # prove it
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
If `check` fails, the committed graph no longer describes the repository. Do
|
|
81
|
+
not work around it: run `agentdoc compile`, review the diff, commit the graph.
|
|
82
|
+
|
|
83
|
+
## Rules that are never optional
|
|
84
|
+
|
|
85
|
+
- **Never vendor the CLI.** A project gets `agentdoc/` project data (config,
|
|
86
|
+
descriptors, observations), `docs/` skeletons, `.agentdoc/graph.json` and a
|
|
87
|
+
CI workflow — never a copy of the agentdoc source tree (`core/`, `bin/`,
|
|
88
|
+
`adapters/`, `schemas/`, `templates/`, `evals/`, `tests/`).
|
|
89
|
+
- **Never promote uncertainty.** Heuristic guesses do not become authored
|
|
90
|
+
facts; they become `reviewedOverrides` with evidence, or they stay out.
|
|
91
|
+
- **Never reconcile a conflict by editing one side.** Add an authority rule for
|
|
92
|
+
the key, or report both values to a human. Details:
|
|
93
|
+
[references/authority-and-conflicts.md](references/authority-and-conflicts.md).
|
|
94
|
+
- **Never write a secret** into a descriptor, observation, evidence bundle or
|
|
95
|
+
commit message. Validation fails on secret-shaped input *and* output.
|
|
96
|
+
- **Never hand-edit `.agentdoc/graph.json`.** The gate rejects it, and it would
|
|
97
|
+
be wrong anyway.
|
|
98
|
+
- **Do not trust existing documentation.** In MIGRATE it is evidence of what
|
|
99
|
+
someone once believed; the audit says where that belief contradicts the code.
|
|
100
|
+
|
|
101
|
+
## Deeper references
|
|
102
|
+
|
|
103
|
+
| file | covers |
|
|
104
|
+
|---|---|
|
|
105
|
+
| [references/cli.md](references/cli.md) | every command, flag and exit code |
|
|
106
|
+
| [references/create-migrate.md](references/create-migrate.md) | the two onboarding workflows and the audit report |
|
|
107
|
+
| [references/authority-and-conflicts.md](references/authority-and-conflicts.md) | evidence classes, elections, secrets, descriptors |
|
|
108
|
+
| [references/maintenance.md](references/maintenance.md) | keeping the catalog true: gates, freshness, evidence handover |
|
|
109
|
+
|
|
110
|
+
The normative specification (`docs/SPEC.md`, `docs/AUTHORITY.md`,
|
|
111
|
+
`docs/PROVENANCE.md`, `docs/QUERY.md`, `docs/MIGRATION.md`, `docs/CI.md`) lives
|
|
112
|
+
in the agent-doc-system repository — read it when a rule here needs the full
|
|
113
|
+
contract behind it.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Evidence, authority and conflicts
|
|
2
|
+
|
|
3
|
+
## The three evidence classes
|
|
4
|
+
|
|
5
|
+
| class | source | may be authored? |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `AUTHORED` | a file in the repository you can point at | yes |
|
|
8
|
+
| `DERIVED` | a deterministic extractor produces it | yes, once reviewed |
|
|
9
|
+
| `OBSERVED_RUNTIME` | an `agentdoc/observations/*.yaml` ObservationSet, written after actually reading the external system | **no** — it belongs in an ObservationSet |
|
|
10
|
+
| `REVIEWED_OVERRIDE` | a reviewed human interpretation, citing pinned evidence | yes, with `reviewWhen` and evidence digests |
|
|
11
|
+
|
|
12
|
+
There is no global precedence order. The committed manifest is authoritative
|
|
13
|
+
for *intent*; a live scheduler is authoritative for *what fires*; the canonical
|
|
14
|
+
contract is authoritative for the *desired wire surface* while a live probe is
|
|
15
|
+
authoritative for *what is deployed today*. Which class wins is decided per
|
|
16
|
+
fact key, by an explicit authority rule.
|
|
17
|
+
|
|
18
|
+
## When you cannot establish a fact
|
|
19
|
+
|
|
20
|
+
- **Heuristic guess** — do not write it. Add a `reviewedOverrides` entry with a
|
|
21
|
+
`reason`, a `reviewWhen`, and file-level `evidence` (path + sha256, via
|
|
22
|
+
`agentdoc pin-evidence`), or leave it out.
|
|
23
|
+
- **Two sources disagree** — do not pick one. Either add an authority rule that
|
|
24
|
+
says which class is authoritative *for that key*, or report the contradiction
|
|
25
|
+
to a human. Fail-closed is the default: a disagreeing fact with no governing
|
|
26
|
+
rule is an error, and no gate passes while it stands.
|
|
27
|
+
- **Product or ownership decision** — ask. Do not infer ownership from folder
|
|
28
|
+
names.
|
|
29
|
+
|
|
30
|
+
## Handling a reported conflict
|
|
31
|
+
|
|
32
|
+
`agentdoc query <ref> --json` returns `authority.conflicts`. For each one:
|
|
33
|
+
|
|
34
|
+
1. Read `election.basis` and `election.ruleId`. `basis: none` means no rule
|
|
35
|
+
governs this fact and the system refused to choose.
|
|
36
|
+
2. Both values stay in the graph. Report both to the human, with their evidence
|
|
37
|
+
pointers, and say which one the system elected and why.
|
|
38
|
+
3. If the right answer is "the runtime wins for this key", add an authority
|
|
39
|
+
rule with `elect: [OBSERVED_RUNTIME]`, a `rationale`, and a `reviewWhen`.
|
|
40
|
+
Do not edit the observation to match the manifest, and do not edit the
|
|
41
|
+
manifest to match the observation.
|
|
42
|
+
|
|
43
|
+
## Secrets
|
|
44
|
+
|
|
45
|
+
Never write a credential, token, key or credentialed URL into a descriptor, an
|
|
46
|
+
observation, an evidence bundle, or a commit message. `agentdoc validate`
|
|
47
|
+
fails on secret-shaped input, and the output scanner fails on secret-shaped
|
|
48
|
+
output too. Observations cite a committed, secret-free evidence bundle by
|
|
49
|
+
repository-relative path — a temp path, a console URL with a session token, or
|
|
50
|
+
a screenshot filename is not evidence.
|
|
51
|
+
|
|
52
|
+
## Writing descriptors
|
|
53
|
+
|
|
54
|
+
The templates ship with the CLI (`templates/` in the package). The rules that
|
|
55
|
+
matter:
|
|
56
|
+
|
|
57
|
+
- A Component descriptor lives at the root of the unit it describes, named by
|
|
58
|
+
`discovery.componentDescriptorName` (conventionally `agentdoc.yaml`).
|
|
59
|
+
- `metadata.description` is **one sentence, present tense**, ending in `.`,
|
|
60
|
+
`!` or `?`. It says what the component is *for*.
|
|
61
|
+
- Placement is exactly one of `system`, `domain`, or `placementRationale`.
|
|
62
|
+
- Every durable cross-component boundary has exactly one canonical
|
|
63
|
+
machine-readable contract, and exactly one API descriptor pointing at it.
|
|
64
|
+
Default to OpenAPI 3.1 for JSON HTTP; a protocol's native schema is equally
|
|
65
|
+
valid.
|
|
66
|
+
- You never author a relation. Placement and API provider edges come from the
|
|
67
|
+
descriptor; everything else is derived or reviewed.
|
|
68
|
+
|
|
69
|
+
The full model is `docs/AUTHORITY.md` and `docs/PROVENANCE.md` in the agentdoc
|
|
70
|
+
repository.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# agentdoc CLI reference
|
|
2
|
+
|
|
3
|
+
The binary is `agentdoc`, installed once per machine. Every command that
|
|
4
|
+
operates on a catalog can be run from any subdirectory of the repository: the
|
|
5
|
+
configuration is found by walking up to `agentdoc/agentdoc.config.yaml`. No
|
|
6
|
+
command ever needs the agentdoc source tree or a path to it.
|
|
7
|
+
|
|
8
|
+
Exit codes: `0` ok, `1` failure, `2` usage.
|
|
9
|
+
|
|
10
|
+
## Meta
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
agentdoc --version # installed version
|
|
14
|
+
agentdoc --help # command list (also: agentdoc <command> --help)
|
|
15
|
+
agentdoc doctor # machine check: is this CLI install healthy
|
|
16
|
+
agentdoc doctor --project # the same, plus the current project's catalog health
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`doctor` answers "is the CLI itself healthy": supported Node, schema bundle,
|
|
20
|
+
compiler version. It never fails because a project is not configured yet.
|
|
21
|
+
`doctor --project` additionally checks `agentdoc/agentdoc.config.yaml` exists,
|
|
22
|
+
parses, and that the repository root is writable — run it inside a project.
|
|
23
|
+
|
|
24
|
+
## Onboarding
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
agentdoc init [--force] # write agentdoc/agentdoc.config.yaml + doc skeleton
|
|
28
|
+
agentdoc audit # inventory the repo, classify every fact (JSON)
|
|
29
|
+
agentdoc scaffold [--write] # generate descriptors for what can be proven
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`init` never overwrites an existing file without `--force`, and run inside a
|
|
33
|
+
subdirectory of a cataloged repository it writes at the catalog root, not the
|
|
34
|
+
current directory. `scaffold` is a dry run without `--write`; with `--write` it
|
|
35
|
+
is a superset of `init` — it also installs anything missing from the config,
|
|
36
|
+
doc skeleton and CI workflow, not only component descriptors. `audit` works
|
|
37
|
+
even when the repository cannot compile yet; it reports the compilation
|
|
38
|
+
failures as part of its output.
|
|
39
|
+
|
|
40
|
+
## Validation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
agentdoc validate # sources + schemas + semantic checks
|
|
44
|
+
agentdoc compile [--require-clean] # deterministic graph build, atomic write
|
|
45
|
+
agentdoc check [--require-clean] [--allow-stale-observations]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`compile` writes `.agentdoc/graph.json` (or the path in `output.graph`).
|
|
49
|
+
`check` is the gate: it fails on a stale or hand-edited graph, a compiler or
|
|
50
|
+
schema version mismatch, an observation past its declared `maxAgeDays`, and —
|
|
51
|
+
with `--require-clean` — catalog inputs that differ from `HEAD`.
|
|
52
|
+
|
|
53
|
+
## Query and impact
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
agentdoc query <path|entity-ref> # compact markdown context
|
|
57
|
+
agentdoc query <path|entity-ref> --json # full payload
|
|
58
|
+
agentdoc query <path> --budget relations=10,verification=4
|
|
59
|
+
agentdoc impact <paths...> # what a change forces consistent
|
|
60
|
+
agentdoc impact --diff <git-ref> # the same, for a commit range
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`query` refuses a stale graph — it never falls back to one. `impact` answers a
|
|
64
|
+
question about the working tree, so it compiles in memory instead: run it
|
|
65
|
+
*before* rebuilding.
|
|
66
|
+
|
|
67
|
+
Entity refs look like `component:<namespace>/<name>` — `query --json` returns
|
|
68
|
+
`entity.ref` values you can reuse.
|
|
69
|
+
|
|
70
|
+
## Maintenance
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
agentdoc pin-evidence [--json] # which pinned evidence digests are current
|
|
74
|
+
agentdoc eval routing [--json] # routing evaluation (meaningful on a source
|
|
75
|
+
# checkout; exits SKIP on other repositories)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Reviewed overrides pin their evidence by content hash, re-verified on every
|
|
79
|
+
compile. `pin-evidence` reports `CURRENT` / `STALE` / `MISSING` per entry so a
|
|
80
|
+
digest can be updated without computing SHA-256 by hand. It exits `1` when any
|
|
81
|
+
entry is not current.
|
|
82
|
+
|
|
83
|
+
## Error output
|
|
84
|
+
|
|
85
|
+
Diagnostics are lines of the form `ERROR <CODE>: <message>` on stderr, with a
|
|
86
|
+
JSON stats object. `WARN` lines are non-fatal; `WARN ACCEPTED` lines carry the
|
|
87
|
+
acceptance classification and reason. The full code registry is
|
|
88
|
+
`core/codes.mjs` in the agentdoc source; the operator-facing table is in
|
|
89
|
+
`docs/CI.md` of the repository.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# CREATE and MIGRATE
|
|
2
|
+
|
|
3
|
+
Two onboarding workflows. CREATE for a repository with no catalog; MIGRATE for
|
|
4
|
+
an established one. Both start with the same audit; MIGRATE adds a
|
|
5
|
+
source-of-truth mapping and a reviewed-ambiguity list a human must work
|
|
6
|
+
through.
|
|
7
|
+
|
|
8
|
+
## Choosing
|
|
9
|
+
|
|
10
|
+
| situation | mode |
|
|
11
|
+
|---|---|
|
|
12
|
+
| no `agentdoc/` directory, small or new repository | CREATE |
|
|
13
|
+
| no `agentdoc/`, large or established repository | MIGRATE |
|
|
14
|
+
| an existing catalog, documentation that has drifted | MIGRATE |
|
|
15
|
+
|
|
16
|
+
The test is not size. It is whether the repository has documentation that
|
|
17
|
+
*claims* things. Claims need verifying — that is migration work regardless of
|
|
18
|
+
how few components there are.
|
|
19
|
+
|
|
20
|
+
## CREATE
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
cd <repository root>
|
|
24
|
+
agentdoc doctor --project # expect configurationFound: false for now
|
|
25
|
+
agentdoc init # config skeleton + documentation hierarchy
|
|
26
|
+
$EDITOR agentdoc/agentdoc.config.yaml
|
|
27
|
+
agentdoc audit # what is provable, what is not
|
|
28
|
+
agentdoc scaffold # dry run: what it would write
|
|
29
|
+
agentdoc scaffold --write # write descriptors for provable units
|
|
30
|
+
$EDITOR '**/agentdoc.yaml' # review every generated description
|
|
31
|
+
agentdoc validate && agentdoc compile && agentdoc check
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`init` writes `agentdoc/agentdoc.config.yaml`, the central descriptor files
|
|
35
|
+
(`domains.yaml`, `systems.yaml`, `apis.yaml`, `resources.yaml`),
|
|
36
|
+
`agentdoc/journeys.yaml`, the documentation hierarchy under `docs/`, the
|
|
37
|
+
observations README, and a CI workflow. It writes **project data only** — it
|
|
38
|
+
never copies the agentdoc implementation into the repository.
|
|
39
|
+
|
|
40
|
+
In `agentdoc.config.yaml`:
|
|
41
|
+
|
|
42
|
+
- Set `namespace`, fix `discovery.componentDescriptors` to match the real
|
|
43
|
+
layout, and enable the adapters for the technologies present. `adapters: []`
|
|
44
|
+
is a valid but useless starting point: with no adapter, a component
|
|
45
|
+
descriptor is an unsupported claim and compilation fails on purpose.
|
|
46
|
+
- Three example authority rules are written **commented out**. Uncomment only
|
|
47
|
+
the ones you can justify, with the rationale in your own words. An authority
|
|
48
|
+
rule is a governance decision; the scaffolder does not make it for you.
|
|
49
|
+
|
|
50
|
+
A generated description is a statement about artifact evidence, not a product
|
|
51
|
+
claim. Read every one and fix the ones that are wrong. The scaffolder never
|
|
52
|
+
chooses a `system` or `domain`: placement is an ownership decision, so the
|
|
53
|
+
generated descriptor carries a commented `placementRationale` prompt instead.
|
|
54
|
+
|
|
55
|
+
## The audit report
|
|
56
|
+
|
|
57
|
+
`agentdoc audit` runs even when the repository cannot compile, and inventories
|
|
58
|
+
four truth sources independently: derivable facts, machine-readable contracts,
|
|
59
|
+
authored documentation, and ObservationSets. Key fields:
|
|
60
|
+
|
|
61
|
+
| field | meaning |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `facts` | every major fact classified `CONFIRMED` / `DERIVED` / `OBSERVED` / `CONFLICT` / `UNRESOLVED` |
|
|
64
|
+
| `contradictions`, `documentationContradictions` | where sources disagree |
|
|
65
|
+
| `reviewedAmbiguity` | the list a human must decide |
|
|
66
|
+
| `documentation.orphanDocs` | documents nothing will ever route to |
|
|
67
|
+
| `documentation.undocumentedComponents` | components an agent will get wrong |
|
|
68
|
+
| `contracts.unclaimed` | contract files no API descriptor owns |
|
|
69
|
+
| `scaffold` | what the scaffolder proposes to write |
|
|
70
|
+
|
|
71
|
+
`OBSERVED` facts cannot be authored — they belong in an ObservationSet under
|
|
72
|
+
`agentdoc/observations/`. `CONFLICT` and `UNRESOLVED` need a human.
|
|
73
|
+
|
|
74
|
+
## MIGRATE
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
agentdoc init
|
|
78
|
+
# set componentDescriptors to the real layout; enable the right adapters
|
|
79
|
+
agentdoc audit > migration-report.json
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Then, in order:
|
|
83
|
+
|
|
84
|
+
1. **Source-of-truth mapping.** For each major claim, record which inventory
|
|
85
|
+
supports it. Anything supported by none goes to `reviewedAmbiguity`.
|
|
86
|
+
2. **Contradictions.** Work `contradictions` and `documentationContradictions`.
|
|
87
|
+
Each needs a human decision: fix the docs, fix the code, or add an authority
|
|
88
|
+
rule saying which class wins for that key.
|
|
89
|
+
3. **Orphan docs.** Link each to a component via `context.docs`, or delete it.
|
|
90
|
+
4. **Missing docs.** Work `undocumentedComponents` / `unverifiedComponents`.
|
|
91
|
+
5. **Stale contracts.** Point the API descriptor at the current contract file.
|
|
92
|
+
6. **Ownership.** Placement from code where unambiguous, from a human elsewhere.
|
|
93
|
+
7. **Catalog.** `scaffold --write`, review every generated file.
|
|
94
|
+
8. **Gate.** `validate` → `compile` → `check`, then install CI.
|
|
95
|
+
|
|
96
|
+
**Do not trust existing documentation.** The single most common migration
|
|
97
|
+
failure is copying existing prose into descriptions. If you cannot write a
|
|
98
|
+
one-sentence present-tense statement of a component's current purpose, the
|
|
99
|
+
purpose is not understood yet — that discovery is the point.
|
|
100
|
+
|
|
101
|
+
The full workflow contract is `docs/MIGRATION.md` in the agentdoc repository.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Maintaining the catalog
|
|
2
|
+
|
|
3
|
+
## The gate
|
|
4
|
+
|
|
5
|
+
`agentdoc check` is the contract. Inside it, in order:
|
|
6
|
+
|
|
7
|
+
1. compilation errors;
|
|
8
|
+
2. time-dependent gates (an observation older than its `maxAgeDays`);
|
|
9
|
+
3. graph freshness and byte comparison against a fresh deterministic compile;
|
|
10
|
+
4. `--require-clean` (catalog inputs must match `HEAD`).
|
|
11
|
+
|
|
12
|
+
Step 2 precedes step 3 on purpose: "your observation is five years old" and
|
|
13
|
+
"rebuild the graph" send the reader to different places, and when both are true
|
|
14
|
+
the first is the one that matters.
|
|
15
|
+
|
|
16
|
+
## Discipline
|
|
17
|
+
|
|
18
|
+
- Any PR that changes a compiler input must recompile and commit the graph.
|
|
19
|
+
`agentdoc impact <paths>` tells you which files are inputs.
|
|
20
|
+
- Never hand-edit `.agentdoc/graph.json`. The gate rejects it, and it would be
|
|
21
|
+
wrong anyway.
|
|
22
|
+
- A change to a warning acceptance is a deliberate act: the acceptance pins the
|
|
23
|
+
evidence digests it was written against, and changing the evidence
|
|
24
|
+
invalidates it on purpose.
|
|
25
|
+
- An observation is a promise about freshness. Re-observe before `maxAgeDays`,
|
|
26
|
+
or restate the fact as authored intent if the divergence is intended.
|
|
27
|
+
- Schema and compiler versions are recorded in the graph. Upgrading the CLI
|
|
28
|
+
invalidates every graph; recompile, review the diff, commit.
|
|
29
|
+
- `agentdoc pin-evidence` reports which reviewed-override digests are current
|
|
30
|
+
so stale evidence can be re-pinned without computing SHA-256 by hand.
|
|
31
|
+
|
|
32
|
+
## CI
|
|
33
|
+
|
|
34
|
+
`agentdoc init` writes `.github/workflows/agentdoc.yml`: validate, compile,
|
|
35
|
+
check, `check --require-clean`. The runner installs the CLI
|
|
36
|
+
(`npm install -g github:lbframe/agent-doc-system`). Any other runner works the
|
|
37
|
+
same way — the gate is four commands and an exit code; `docs/CI.md` in the
|
|
38
|
+
repository lists the failure codes and what each one asks of you.
|
|
39
|
+
|
|
40
|
+
## Packaging final evidence
|
|
41
|
+
|
|
42
|
+
When you finish a task in a cataloged repository, hand over:
|
|
43
|
+
|
|
44
|
+
1. `agentdoc check` output (must pass).
|
|
45
|
+
2. `agentdoc query <path> --json` for each surface you touched.
|
|
46
|
+
3. `agentdoc impact <changed files>` showing what you kept consistent.
|
|
47
|
+
4. For any conflict you encountered: both values, their evidence, the election,
|
|
48
|
+
and your recommendation.
|
|
49
|
+
5. Anything left `UNRESOLVED`, stated as unresolved.
|
|
50
|
+
|
|
51
|
+
Do not summarise a conflict away. The value of this system is that it tells you
|
|
52
|
+
when you do not know something.
|