Audit Type Ownership
Use this skill for non-mutating type ownership audits in the compartment repo.
Source of truth
AGENTS.mddocs/layers/README.mddocs/specs/type-placement.md- the relevant layer docs, starting with
docs/layers/api.mdwhen the user does not narrow the audit
Workflow
- Run
node .codex/skills/audit-type-ownership/scripts/audit_type_ownership.mjsfrom the repo root. - Narrow with
--package <api|contracts|sdk|cli|edge|worker|docker|kube-runtime|utils|test-support>when the request is scoped. Use--format jsononly when a structured artifact is more useful than Markdown. - Read the script output before making claims. It is a heuristic inventory, not proof.
- Treat declared workspace dependencies as package context, not automatic findings. A non-
contractsimport matters only when it is undeclared in the owning package or it conflicts with the relevant layer doc. - Treat duplicate names as move candidates only when they imply a shared serialized or cross-package owner. Package-local families such as
*Input,*Context,*Plan,*Result,*Options,*State,*Config, and*Appcan legitimately exist in multiple packages. - Classify findings with this matrix:
contracts: serialized DTOs, public*Request,*Response,*Summary, shared status/value aliases- query layer:
*Row,*Selection,*Transaction,*Executor, persistence mutation inputs - service layer:
*Input,*Context,*Plan,*Result - app/adapter layer:
*Options,*State,*Config,*App
- Treat cross-process or cross-package payloads as contract-owned, even when the current consumer is internal.
- Treat query/service boundary leakage and placement violations from
docs/specs/type-placement.mdas ownership bugs, including genericsrc/types/,routes/shared/, and route DTO mappers outside*.presenter.ts. - If the audit turns into implementation, run the narrowest relevant package checks first and then add any required special checks for the diff.
Default scope
- Start with
api. - Then sweep
contracts,sdk,cli,edge,worker,docker,kube-runtime,utils, andtest-support. - Keep the audit non-mutating unless the user explicitly asks for implementation after the audit.
Output
PolicyConcrete findingsMove listPhased refactor plan
Script
scripts/audit_type_ownership.mjsinventories namedinterfaceandtypedeclarations by package and file.- It highlights duplicate type names, suspicious
@compartment/*imports, query/service leaks, root export risks, package dependency context, and placement violations. - Final ownership decisions still come from
AGENTS.md, the architecture docs, and the relevant checks.