Skip to content

Commit 9a4c182

Browse files
replace v1 contracts with v2 boundaries
1 parent 024308a commit 9a4c182

1 file changed

Lines changed: 72 additions & 68 deletions

File tree

Lines changed: 72 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,89 @@
1-
# DocGen Contract Firewall
1+
# DocGen 2 contracts
22

3-
DocGen treats every LLM-produced artifact as untrusted, uncommitted output until it has passed canonicalization and invariant validation.
3+
DocGen 2 treats provider output as untrusted and prevents providers from becoming repository scanners. Deterministic code owns source access, indexing, retrieval, validation, budgets, rendering of low-risk references, and most auditing.
44

55
## Boundary matrix
66

7-
| Stage | Canonical artifact | Canonical arrays/fields |
7+
| Boundary | Canonical artifact | Owner |
88
|---|---|---|
9-
| discover | `.docgen/evidence/index.json` | `artifacts` |
10-
| analyze | `.docgen/model/system.json` | `components`, `relationships`, `workflows`, `unknowns` |
11-
| semantics/business | `.docgen/model/business.json` | `actors`, `capabilities`, `concepts`, `businessRules`, `decisions`, `branchConditions`, `lifecycles`, `invariants`, `useCases`, `unknowns` |
12-
| semantics/flows | `.docgen/model/flows.json` | `businessFlows`, `controlFlows`, `requestFlows`, `trafficFlows`, `dataFlows`, `eventFlows` |
13-
| semantics/catalogs | `.docgen/model/catalogs.json` | `endpoints`, `messageHandlers`, `externalDependencies`, `dataStores`, `scheduledJobs` |
14-
| enterprise/security | `.docgen/model/security.json` | `trustBoundaries`, `principals`, `authenticationFlows`, `authorizationRules`, `permissions`, `serviceIdentities`, `secrets`, `sensitiveData`, `threats`, `controls`, `unknowns` |
15-
| enterprise/operations | `.docgen/model/operations.json` | runtime, health, observability, SLI/SLO, alerts, capacity, scaling, failures, recovery, backup, deployment, runbooks |
16-
| enterprise/testing | `.docgen/model/testing.json` | suites, test types, fixtures, test data, environments, commands, gaps, contract tests, failure injection, quality gates |
17-
| enterprise/data governance | `.docgen/model/data-governance.json` | entities, ownership, sources of truth, classification, retention, transactions, consistency, concurrency, idempotency, reconciliation, lineage, migration, auditability |
18-
| enterprise/decisions | `.docgen/model/decisions.json` | recorded/inferred decisions, alternatives, trade-offs, constraints, consequences, superseded decisions |
19-
| enterprise/configuration | `.docgen/model/configuration.json` | settings, environments, flags, secrets, tuning, validation, reload behavior, deprecations |
20-
| enterprise/change impact | `.docgen/model/change-impact.json` | change surfaces, impact edges, compatibility, extension points, risks, tests, operations and contracts |
21-
| enterprise/ownership | `.docgen/model/ownership.json` | teams, responsibilities, RACI, component/data/operational ownership, approvals and escalation |
22-
| plan | `.docgen/plan/manifest.json` | `navigation`, `pages`, canonical `docs/**/*.md` paths |
23-
| generate/enrich/fix | `docs/**/*.md` | exact manifest target, valid Markdown, Mermaid-only diagrams |
24-
| page traceability | `.docgen/traceability/pages/<page-id>.json` | typed claims, evidence refs, model/catalog/branch coverage, source snapshot |
25-
| cross-page consistency | `.docgen/traceability/{index,contradictions,duplicates,freshness}.json` | unique claim IDs, contradiction groups, duplicate groups, freshness |
26-
| audit | `.docgen/audit/pages/<page-id>.json` | `pageId`, `pagePath`, `pageHash`, `inputHash`, `findings` |
27-
| update-impact | `.docgen/plan/update-plan.json` | `changedPaths`, `affectedEvidenceScopes`, `affectedModels`, `affectedPageIds`, `rationale` |
28-
| publishing | `.docgen/publish/*.json`, `docs/llms*.txt`, page frontmatter | mode, aliases, lifecycle/version metadata, search/navigation/backlink/redirect/example indexes |
9+
| source eligibility | `.docgen/index/inventory.json` | deterministic inventory |
10+
| searchable knowledge | `.docgen/index/semantic.db` | deterministic indexer |
11+
| provider input | `.docgen/context/<stage>/*.json` | bounded context compiler |
12+
| core synthesis | `.docgen/model/{system,business,flows,catalogs}.json` | one bounded provider call + orchestrator validation |
13+
| enterprise synthesis | `.docgen/model/{security,operations,testing,data-governance,decisions,configuration,change-impact,ownership}.json` | one bounded provider call + orchestrator validation |
14+
| page plan | `.docgen/plan/manifest.json` | bounded planner + deterministic canonicalization |
15+
| reference pages | selected `docs/**/*.md` | deterministic renderer |
16+
| narrative pages | selected `docs/**/*.md` | bounded writer |
17+
| page claims | `.docgen/traceability/pages/<page-id>.json` | same generation call or deterministic item mapping |
18+
| structural/grounding audit | `.docgen/audit/deterministic.json` | deterministic auditor |
19+
| semantic risk audit | `.docgen/audit/llm-risk.json` | selective, hash-cached provider call |
20+
| quality summary | `.docgen/audit/quality-summary.json` | deterministic aggregator |
21+
| publishing | `.docgen/publish/*.json`, `docs/llms*.txt` | deterministic publisher |
22+
| provider usage | `.docgen/telemetry/provider-runs.jsonl`, `.docgen/budget/report.json` | orchestrator |
2923

30-
## Invariants
24+
## Hard invariants
3125

32-
1. **Single canonical representation** — aliases are removed from committed artifacts.
33-
2. **Idempotence** — normalizing canonical output again cannot change or duplicate it.
34-
3. **Losslessness for known split aliases** — producers, consumers and listeners are merged into the complete message-handler catalog.
35-
4. **Path safety** — evidence remains under `.docgen/evidence/**`; published pages remain under `docs/**/*.md`.
36-
5. **Identity consistency** — audit page ID/path/hash must match the current manifest/page.
37-
6. **Input consistency** — generated pages and audits are fingerprinted against their declared evidence/model inputs.
38-
7. **Transactional stages** — partial output is quarantined and the previous valid artifact restored.
39-
8. **Dependency invalidation** — rerunning an upstream stage invalidates dependent stage skips.
40-
9. **Typed semantic items** — each model item has stable ID, kind, epistemic classification, confidence, evidence, and source references.
41-
10. **Direct evidence for FACT** — FACT items and claims cannot commit without resolvable repository evidence.
42-
11. **Claim-level traceability** — material page claims map to source and normalized semantic/catalog items.
43-
12. **Cross-page consistency** — claim ID collisions and subject/predicate contradictions fail quality gates.
44-
13. **Freshness** — page, input, Git/source fingerprint changes make traceability stale.
45-
14. **Evidence-centric quality** — grounding and coverage are hard gates; word count is advisory.
46-
15. **Ignore-aware source boundary**`.gitignore`, `.docgenignore`, hard exclusions, and project `config.exclude` produce one canonical source inventory used by every stage.
47-
16. **Ignored evidence rejection** — an ignored path cannot support a typed FACT or page claim.
48-
17. **Enterprise-depth coverage** — security, operations, testing, data governance, decisions, configuration, change impact, and ownership use typed, evidence-backed item contracts.
49-
18. **Binary/non-text budget boundary** — binary extensions, magic signatures, NUL bytes, invalid UTF-8, excessive control characters, and oversized text are excluded before reads, fingerprints, change detection, or evidence validation.
50-
19. **Mode-aware documentation** — every planned page has a canonical document mode and mode-specific structural contract.
51-
20. **Deterministic publishing** — frontmatter, navigation, search, backlinks, redirects, orphan reports, examples indexes, and `llms*.txt` are produced without a provider call.
52-
21. **Evidence-derived examples** — publishable examples must map to page claims and source/model references; generic unsupported examples do not satisfy the quality contract.
26+
1. **Source is indexed once** — provider sessions do not broadly scan repository source.
27+
2. **Canonical inventory**`.gitignore`, nested non-Git fallback, `.docgenignore`, binary signatures, UTF-8 checks, and size limits are applied before indexing.
28+
3. **Context-only provider** — hooks restrict provider reads to declared `.docgen/context/**` packs and stage outputs.
29+
4. **Bounded context** — each pack has an explicit token budget and reports omitted facts/model items.
30+
5. **Content addressing** — contexts, stages, pages, and risk audits are reusable only while selected item hashes remain unchanged.
31+
6. **Hard provider budget** — a call is refused before execution when it would exceed configured call, input-token, output-token, or per-call limits.
32+
7. **Typed models** — semantic items preserve stable identity, kind, classification, confidence, evidence, and unknowns.
33+
8. **Direct evidence for FACT** — deterministic audit rejects FACT page claims without evidence or with evidence outside the canonical inventory.
34+
9. **Qualified model identity** — SQLite item IDs are model-qualified to prevent cross-model collisions.
35+
10. **Deterministic references** — exhaustive low-risk catalogs are rendered without provider calls.
36+
11. **Selective audit** — LLM audit runs only for risk-scored pages and only when page/context hashes change.
37+
12. **No repair loop** — there is no automatic enrich, fix, or full re-audit cycle.
38+
13. **No parent delegation** — provider prompts complete their bounded task directly and do not load agent/skill trees.
39+
14. **Mermaid only** — published diagrams may not use PlantUML, Graphviz, or image-only diagrams.
40+
15. **Breaking migration** — v1 workflow artifacts are archived, not interpreted as v2 checkpoints.
5341

54-
Run the zero-token suite with:
42+
## Core model surfaces
5543

56-
```bash
57-
docgen contract-test
58-
```
44+
- `system.json`: components, relationships, workflows, unknowns;
45+
- `business.json`: actors, capabilities, concepts, rules, decisions, branches, lifecycles, invariants, use cases, unknowns;
46+
- `flows.json`: business, control, request, traffic, data, and event flows;
47+
- `catalogs.json`: endpoints, message handlers, dependencies, data stores, scheduled jobs.
5948

60-
The machine-readable report is written to `.docgen/state/contract-report.json`.
49+
## Enterprise model surfaces
6150

62-
## Trustworthiness reports
51+
- `security.json`
52+
- `operations.json`
53+
- `testing.json`
54+
- `data-governance.json`
55+
- `decisions.json`
56+
- `configuration.json`
57+
- `change-impact.json`
58+
- `ownership.json`
6359

64-
Run `docgen traceability` to rebuild deterministic claim, contradiction, duplicate, and freshness reports. Run `docgen quality` to apply semantic thresholds. Neither command requires an LLM call.
60+
## Page traceability
6561

66-
# P3 workspace contracts
62+
Each page sidecar contains:
6763

68-
A system workspace is rooted by `.docgen-workspace/workspace.json` and references repositories by stable ID plus absolute path. Repository-local `.docgen/model/**` artifacts remain authoritative for repository facts.
64+
```json
65+
{
66+
"schemaVersion": "2.0",
67+
"pageId": "quote-lifecycle",
68+
"pagePath": "docs/business/quote-lifecycle.md",
69+
"pageHash": "...",
70+
"inputHash": "...",
71+
"contextId": "...",
72+
"claims": [
73+
{
74+
"id": "quote-lifecycle:draft-submit",
75+
"statement": "A draft quote can be submitted.",
76+
"classification": "FACT",
77+
"confidence": 1,
78+
"evidence": [{"path": "src/QuoteService.java", "startLine": 120, "endLine": 146}],
79+
"sourceModelRefs": ["business:rule-submit-draft"]
80+
}
81+
]
82+
}
83+
```
6984

70-
P3 canonical workspace outputs:
85+
The orchestrator fills page/input/context hashes after generation.
7186

72-
- `repositories.json`
73-
- `model/system-map.json`
74-
- `model/dependency-graph.json`
75-
- `model/contract-registry.json`
76-
- `model/capability-map.json`
77-
- `model/business-journeys.json`
78-
- `model/request-flows.json`
79-
- `model/event-flows.json`
80-
- `model/data-lineage.json`
81-
- `model/shared-infrastructure.json`
82-
- `model/ownership.json`
83-
- `model/change-impact.json`
87+
## Workspace contracts
8488

85-
Cross-repository edges require explicit registered repository identity, dependency target, shared producer/consumer channel, or repository model reference. Ambiguous relationships remain unresolved. Workspace publishing is Mermaid-only and deterministic.
89+
P3 remains deterministic and consumes current repository models plus commit/source/model hashes. Cross-repository edges require explicit repository identity, dependency targets, shared evidenced producer/consumer channels, or model references. Ambiguous relationships remain unresolved.

0 commit comments

Comments
 (0)