Skip to content

feat(adf): typed-data-access policy module + named-scaffold registry (#69 Session 1)#96

Merged
stackbilt-admin merged 2 commits intomainfrom
feat/typed-data-access-adf-69
Apr 9, 2026
Merged

feat(adf): typed-data-access policy module + named-scaffold registry (#69 Session 1)#96
stackbilt-admin merged 2 commits intomainfrom
feat/typed-data-access-adf-69

Conversation

@stackbilt-admin
Copy link
Copy Markdown
Member

Summary

Session 1 of #69. Ships the typed data access + ontology enforcement policy as a charter ADF module, plus the named-scaffold registry infrastructure that lets consumer repos adopt it with `charter adf create typed-data-access`.

Scope boundaries

In: policy module content, scaffold wiring, default triggers, tests, charter self-dogfood
Out: governance check for unregistered terms, doctor integration, codebeast DATA_AUTHORITY wiring, AEGIS firewall hot-reload from charter, bootstrap auto-scaffold (all deferred to Sessions 2-4)

What ships

Policy module

  • `.ai/typed-data-access.adf` — dogfooded in charter itself. Documents the canonical data registry at `stackbilt_llc/policies/data-registry.yaml`, the six sensitivity tiers (`public`, `service_internal`, `cross_service_rpc`, `pii_scoped`, `billing_critical`, `secrets`), load-bearing access constraints, and the disambiguation protocol (HALT on undefined concepts).
  • `.ai/manifest.adf` — new ON_DEMAND entry so the charter dev agent loads the policy whenever work touches tenant / user / subscription / quota / sensitivity / DATA_AUTHORITY / etc. keywords.

Scaffold registry infrastructure

  • `TYPED_DATA_ACCESS_SCAFFOLD` export in `packages/cli/src/commands/adf.ts` — the policy content as a reusable const.
  • `NAMED_MODULE_SCAFFOLDS` map — extensible registry that `buildModuleScaffold` consults before falling back to the generic empty placeholder. First entry is `typed-data-access`. Future sessions can add more canonical modules (governance policies, compliance checks, audit scaffolds) behind the same mechanism without touching buildModuleScaffold again.
  • `NAMED_MODULE_DEFAULT_TRIGGERS` map — default manifest trigger keywords for named modules. When `charter adf create ` is called without explicit `--triggers`, these auto-populate the ON_DEMAND entry.
  • `adfCreate` wiring — explicit `--triggers` still wins; named-module defaults only apply on fallback.

Validation

Unit tests (9 new, 354 total)

  • Scaffold registry contains typed-data-access entry ✅
  • Scaffold is valid ADF 0.1 ✅
  • Declares all six sensitivity tiers ✅
  • References canonical registry path (`stackbilt_llc/policies/data-registry.yaml`) ✅
  • Includes load-bearing disambiguation constraint (HALT on undefined) ✅
  • Default triggers include canonical business concepts (tenant, user, subscription, quota) ✅
  • Default triggers include policy keywords (sensitivity, DATA_AUTHORITY, disambiguation) ✅
  • Every named scaffold has registered default triggers (structural invariant) ✅

End-to-end test in a clean temp repo

```bash
$ charter adf create typed-data-access
[ok] Created .ai/typed-data-access.adf
[ok] Registered typed-data-access.adf in ON_DEMAND

$ cat .ai/manifest.adf
...
📂 ON_DEMAND:

  • typed-data-access.adf (Triggers on: tenant, user, subscription, quota, credit, mrr, pii, sensitivity, data registry, ontology, disambiguation, DATA_AUTHORITY, raw D1, service boundary, auth_scoped, billing_critical)
    ```
    Single command produces rich scaffold + fully-wired 16-keyword ON_DEMAND entry. No explicit flags needed.

Full suite

  • typecheck: clean
  • build: clean
  • test: 354/354 passing (+9 from 345)

Known issue (pre-existing, not fixed here)

Empty `📂 ON_DEMAND:` sections cause `charter adf create` to fail with "ON_DEMAND must be a list section in manifest.adf" because the parser sees an empty key as a non-list. Workaround: manifests need at least one ON_DEMAND entry before `adf create` can append. This affects any `adf create` usage, not just named-scaffold modules — worth filing as a separate issue.

Next sessions (#69 roadmap)

  • Session 2: Governance check in `@stackbilt/validate` that scans commit diffs for references to unregistered business terms, with `--policy typed-data-access` flag
  • Session 3: `charter doctor` check that warns when a repo references concepts not in its configured registry path
  • Session 4: Wire codebeast DATA_AUTHORITY + AEGIS disambiguation hot-reload to consume a charter-managed registry path (probably via `.charter/config.json` extension)

References

🤖 Generated with Claude Code

Kurt Overmier added 2 commits April 9, 2026 14:08
…69)

Session 1 of charter#69 — typed data access + ontology enforcement policy.
Ships the policy module and the infrastructure for consumer repos to adopt
it via `charter adf create typed-data-access`.

## What this lands

- **`.ai/typed-data-access.adf`** — dogfood module for charter itself.
  Documents the canonical data registry, 6 sensitivity tiers (public,
  service_internal, cross_service_rpc, pii_scoped, billing_critical,
  secrets), the disambiguation protocol, and the load-bearing access
  constraints (e.g., never leak billing_critical over RPC, HALT on
  undefined concepts instead of guessing).

- **`.ai/manifest.adf`** — new ON_DEMAND entry so charter's own dev
  agent loads typed-data-access whenever work touches tenant/user/
  subscription/quota/sensitivity/DATA_AUTHORITY/etc. keywords.

- **`TYPED_DATA_ACCESS_SCAFFOLD` export in adf.ts** — the scaffold
  template as a reusable const, so consumer repos can adopt the policy
  with a single command.

- **`NAMED_MODULE_SCAFFOLDS` registry + `NAMED_MODULE_DEFAULT_TRIGGERS`**
  — extensible map that `buildModuleScaffold` and `adfCreate` consult
  before falling back to the generic empty scaffold. First entry is
  typed-data-access; follow-up sessions can add more canonical modules
  (governance policies, compliance checks, etc.) behind the same
  mechanism.

- **`adfCreate` change** — when the module name matches a named scaffold
  and no explicit `--triggers` is provided, the default trigger set is
  auto-applied so `charter adf create typed-data-access` produces a
  fully-wired ON_DEMAND entry with 16 business-concept keywords.

## What this does NOT land (Session 2+)

- Charter governance check that flags references to unregistered terms
  (requires classify/validate integration)
- `charter doctor` check for unregistered concepts
- Codebeast DATA_AUTHORITY wiring
- AEGIS disambiguation firewall integration with the canonical registry
  path (already consumes a build-time snapshot — see aegis
  web/src/lib/data-registry.ts — but doesn't hot-reload from charter)
- Auto-scaffold via `charter bootstrap` (opt-in only via `charter adf
  create` for now — not every repo needs ontology enforcement)

## Validation

- 9 new unit tests covering named scaffold registry, default triggers,
  sensitivity tier presence, registry path reference, and the
  load-bearing disambiguation constraint
- 354/354 tests passing (+9 from 345)
- End-to-end verification in a clean temp repo: `charter adf create
  typed-data-access` writes the rich scaffold AND registers it in
  ON_DEMAND with the 16 default triggers, no explicit flags needed
- Full typecheck + build clean

## Known issue (pre-existing, not fixed here)

Empty `📂 ON_DEMAND:` sections in a manifest cause `charter adf create`
to fail with "ON_DEMAND must be a list section in manifest.adf" because
the parser sees an empty key as a non-list. Workaround: manifests need
at least one ON_DEMAND entry before `adf create` can append. Worth
filing as a separate issue since it affects any `adf create` usage.

## References

- Closes part of #69 (Session 1 of 4)
- Registry source of truth: Stackbilt-dev/stackbilt_llc/policies/data-registry.yaml
- Downstream: aegis web/src/lib/data-registry.ts (compiled consumer),
  aegis web/src/lib/disambiguation.ts (runtime firewall)
- Related: codebeast#9 (DATA_AUTHORITY), aegis#344 (disambiguation)
adf_commands_loc: 884 / 800 → 796 / 800.

The TYPED_DATA_ACCESS_SCAFFOLD + NAMED_MODULE_SCAFFOLDS + NAMED_MODULE_DEFAULT_TRIGGERS
blew the 800-line ceiling on packages/cli/src/commands/adf.ts when folded
inline. Moved them to a dedicated adf-named-scaffolds.ts alongside the
other adf-*.ts module files. adf.ts imports the maps for use by
buildModuleScaffold and adfCreate, and re-exports them for backward
compat with programmatic consumers + tests.

This also sets up a clean pattern for adding more named scaffolds in
future sessions (Session 2+ can add scaffolds for governance policies,
compliance modules, etc. to adf-named-scaffolds.ts without touching
adf.ts again).
@stackbilt-admin stackbilt-admin merged commit f7a0b2b into main Apr 9, 2026
3 checks passed
@stackbilt-admin stackbilt-admin deleted the feat/typed-data-access-adf-69 branch April 9, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant