@xenos1996/usat 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.
Files changed (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +335 -0
  3. package/USAT.md +596 -0
  4. package/dist/cli.d.ts +3 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +438 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/config.d.ts +7 -0
  9. package/dist/config.d.ts.map +1 -0
  10. package/dist/config.js +72 -0
  11. package/dist/config.js.map +1 -0
  12. package/dist/detect/index.d.ts +58 -0
  13. package/dist/detect/index.d.ts.map +1 -0
  14. package/dist/detect/index.js +329 -0
  15. package/dist/detect/index.js.map +1 -0
  16. package/dist/engine/audit.d.ts +21 -0
  17. package/dist/engine/audit.d.ts.map +1 -0
  18. package/dist/engine/audit.js +295 -0
  19. package/dist/engine/audit.js.map +1 -0
  20. package/dist/engine/diff.d.ts +24 -0
  21. package/dist/engine/diff.d.ts.map +1 -0
  22. package/dist/engine/diff.js +136 -0
  23. package/dist/engine/diff.js.map +1 -0
  24. package/dist/engine/evaluate.d.ts +19 -0
  25. package/dist/engine/evaluate.d.ts.map +1 -0
  26. package/dist/engine/evaluate.js +377 -0
  27. package/dist/engine/evaluate.js.map +1 -0
  28. package/dist/engine/gate.d.ts +19 -0
  29. package/dist/engine/gate.d.ts.map +1 -0
  30. package/dist/engine/gate.js +47 -0
  31. package/dist/engine/gate.js.map +1 -0
  32. package/dist/engine/loader.d.ts +22 -0
  33. package/dist/engine/loader.d.ts.map +1 -0
  34. package/dist/engine/loader.js +360 -0
  35. package/dist/engine/loader.js.map +1 -0
  36. package/dist/engine/maturity.d.ts +20 -0
  37. package/dist/engine/maturity.d.ts.map +1 -0
  38. package/dist/engine/maturity.js +157 -0
  39. package/dist/engine/maturity.js.map +1 -0
  40. package/dist/engine/score.d.ts +19 -0
  41. package/dist/engine/score.d.ts.map +1 -0
  42. package/dist/engine/score.js +141 -0
  43. package/dist/engine/score.js.map +1 -0
  44. package/dist/engine/sections.d.ts +14 -0
  45. package/dist/engine/sections.d.ts.map +1 -0
  46. package/dist/engine/sections.js +50 -0
  47. package/dist/engine/sections.js.map +1 -0
  48. package/dist/index.d.ts +23 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +17 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/report/markdown.d.ts +16 -0
  53. package/dist/report/markdown.d.ts.map +1 -0
  54. package/dist/report/markdown.js +488 -0
  55. package/dist/report/markdown.js.map +1 -0
  56. package/dist/types.d.ts +282 -0
  57. package/dist/types.d.ts.map +1 -0
  58. package/dist/types.js +16 -0
  59. package/dist/types.js.map +1 -0
  60. package/dist/util/glob.d.ts +11 -0
  61. package/dist/util/glob.d.ts.map +1 -0
  62. package/dist/util/glob.js +86 -0
  63. package/dist/util/glob.js.map +1 -0
  64. package/dist/util/project.d.ts +72 -0
  65. package/dist/util/project.d.ts.map +1 -0
  66. package/dist/util/project.js +586 -0
  67. package/dist/util/project.js.map +1 -0
  68. package/dist/util/yaml.d.ts +28 -0
  69. package/dist/util/yaml.d.ts.map +1 -0
  70. package/dist/util/yaml.js +48 -0
  71. package/dist/util/yaml.js.map +1 -0
  72. package/docs/ARCHITECTURE.md +119 -0
  73. package/docs/README.md +27 -0
  74. package/docs/adr/0001-record-architecture-decisions.md +35 -0
  75. package/docs/adr/0002-typescript-engine-over-python.md +49 -0
  76. package/docs/adr/0003-rules-are-data-not-code.md +50 -0
  77. package/docs/adr/0004-markdown-only-output.md +41 -0
  78. package/docs/adr/0005-maturity-dampens-severity.md +56 -0
  79. package/docs/adr/0006-severity-status-two-axes.md +48 -0
  80. package/docs/adr/0007-suppressions-are-visible-and-expiring.md +46 -0
  81. package/docs/adr/0008-report-trailer-and-diff.md +48 -0
  82. package/docs/adr/0009-fail-closed-on-malformed-input.md +56 -0
  83. package/docs/adr/0010-detector-design.md +54 -0
  84. package/docs/adr/0011-coexist-with-deep-scanners.md +52 -0
  85. package/docs/adr/README.md +32 -0
  86. package/docs/agent-integration.md +129 -0
  87. package/docs/ci-integration.md +163 -0
  88. package/docs/concepts.md +196 -0
  89. package/docs/configuration.md +105 -0
  90. package/docs/detectors.md +186 -0
  91. package/docs/getting-started.md +99 -0
  92. package/docs/maturity-profiles.md +156 -0
  93. package/docs/reference/api.md +193 -0
  94. package/docs/reference/cli.md +412 -0
  95. package/docs/rule-packs.md +278 -0
  96. package/docs/standards-mapping.md +171 -0
  97. package/package.json +96 -0
  98. package/rules/core/architecture.yaml +190 -0
  99. package/rules/core/cicd.yaml +212 -0
  100. package/rules/core/code-quality.yaml +261 -0
  101. package/rules/core/dependencies.yaml +132 -0
  102. package/rules/core/documentation.yaml +119 -0
  103. package/rules/core/future-readiness.yaml +91 -0
  104. package/rules/core/release.yaml +131 -0
  105. package/rules/core/repo.yaml +303 -0
  106. package/rules/core/security.yaml +494 -0
  107. package/rules/core/supply-chain.yaml +357 -0
  108. package/rules/core/testing.yaml +260 -0
  109. package/rules/detectors.yaml +2255 -0
  110. package/rules/index.yaml +41 -0
  111. package/rules/profiles/maturity.yaml +135 -0
  112. package/rules/stacks/ai-era.yaml +193 -0
  113. package/rules/stacks/api-backend.yaml +121 -0
  114. package/rules/stacks/cli.yaml +105 -0
  115. package/rules/stacks/compliance.yaml +157 -0
  116. package/rules/stacks/containers.yaml +124 -0
  117. package/rules/stacks/data.yaml +165 -0
  118. package/rules/stacks/go.yaml +134 -0
  119. package/rules/stacks/iac.yaml +128 -0
  120. package/rules/stacks/jvm.yaml +150 -0
  121. package/rules/stacks/ml-ai.yaml +140 -0
  122. package/rules/stacks/mobile.yaml +121 -0
  123. package/rules/stacks/node-typescript.yaml +166 -0
  124. package/rules/stacks/python.yaml +175 -0
  125. package/rules/stacks/rust.yaml +129 -0
  126. package/rules/stacks/solidity.yaml +139 -0
  127. package/rules/stacks/web-frontend.yaml +159 -0
  128. package/templates/AGENTS.audit.md +135 -0
  129. package/templates/AUDIT_REPORT.md +155 -0
@@ -0,0 +1,193 @@
1
+ # API reference
2
+
3
+ Everything the CLI does is available as a library. Types are exported from the
4
+ package root.
5
+
6
+ ```ts
7
+ import { runAudit, detect, Project, renderMarkdown, diffReports } from 'usat';
8
+ ```
9
+
10
+ ## `runAudit(options): AuditOutcome`
11
+
12
+ Runs a full audit. Only `target` is required — every other option falls back to
13
+ the same default the CLI uses.
14
+
15
+ ```ts
16
+ import { runAudit } from 'usat';
17
+
18
+ const { report, profile, warnings } = runAudit({
19
+ // synchronous — no await needed
20
+ target: '/path/to/project',
21
+ depth: 'standard', // 'quick' | 'standard' | 'deep'
22
+ profile: 'auto', // 'auto' | 'prototype' | 'mvp' | 'beta' | 'production' | 'legacy'
23
+ config: { version: 1, ignore: ['vendor/**'] }, // or omit to read .usat.yaml
24
+ allowCommands: false, // let `command` checks execute
25
+ includePacks: ['stacks/node-typescript'],
26
+ excludePacks: ['stacks/solidity'],
27
+ });
28
+
29
+ console.log(report.score.overall); // 88.7
30
+ console.log(warnings); // malformed packs — never throws
31
+ ```
32
+
33
+ | Option | Type | Default |
34
+ | ------------------------------- | -------------------- | ------------------------------------- |
35
+ | `target` | `string` | — (required) |
36
+ | `rulesDir` | `string` | `rules/` inside the installed package |
37
+ | `depth` | `Depth` | `'standard'` |
38
+ | `profile` | `Maturity \| 'auto'` | `'auto'` |
39
+ | `config` | `UsatConfig` | parsed from `<target>/.usat.yaml` |
40
+ | `allowCommands` | `boolean` | `false` |
41
+ | `usatVersion` | `string` | version from `package.json` |
42
+ | `includePacks` / `excludePacks` | `string[]` | `undefined` |
43
+
44
+ Returns `{ report: AuditReport, profile: MaturityProfile, warnings: string[] }`.
45
+
46
+ ## `detect(project, detectors, git, extraFacts?): DetectionResult`
47
+
48
+ Turns a tree into a fact set.
49
+
50
+ ```ts
51
+ import { Project, detect, loadDetectorFile } from 'usat';
52
+
53
+ const project = new Project('/path/to/project', ['vendor/**']);
54
+ const detection = detect(
55
+ project,
56
+ loadDetectorFile('node_modules/usat/rules/detectors.yaml'),
57
+ project.gitInfo(),
58
+ ['monorepo'], // facts asserted by the caller
59
+ );
60
+
61
+ detection.facts.flags; // Set { 'lang:typescript', 'pm:npm', 'has:ci', … }
62
+ detection.maturity; // 'mvp'
63
+ detection.maturitySignals; // ['+1 tests present', '+0 release tags (absent)', …]
64
+ ```
65
+
66
+ ## `Project`
67
+
68
+ The tree index. Cached, read-only, built once.
69
+
70
+ ```ts
71
+ const p = new Project(root, extraIgnores);
72
+
73
+ p.files; // string[] — every indexed path, relative, sorted
74
+ p.glob('**/*.ts'); // string[]
75
+ p.has('package.json'); // boolean
76
+ p.dirExists('src'); // boolean
77
+ p.anyFile(['**/*.tf', 'pulumi/**']); // boolean
78
+ p.count('**/*.test.ts'); // number
79
+ p.read('package.json'); // string | null
80
+ p.readJson('package.json'); // unknown | null (tolerates comments + trailing commas)
81
+ p.grep('TODO|FIXME', ['**/*.ts'], ['**/generated/**']); // GrepHit[]
82
+ p.gitInfo(); // { commits, contributors, tags, branches, daysSinceLastCommit, isRepo }
83
+ p.trackedFiles(); // string[] — paths git knows about (respects .gitignore semantics)
84
+ ```
85
+
86
+ **`grep` never touches lockfiles, minified bundles, source maps, or generated
87
+ files**, so a 40 MB `package-lock.json` cannot dominate the runtime. Those files
88
+ are still _indexed_, so the presence of a lockfile is checkable.
89
+
90
+ ## `loadRulePacks(rulesDir): { packs, warnings }`
91
+
92
+ Parses and validates every pack reachable from `rules/index.yaml`. A malformed
93
+ pack produces a warning and is skipped — the audit continues rather than
94
+ failing, because one broken pack should not cost you the other twenty-six.
95
+
96
+ ```ts
97
+ import { loadRulePacks, applyRuleOverrides } from 'usat';
98
+
99
+ const { packs, warnings } = loadRulePacks('rules');
100
+ applyRuleOverrides(packs, { 'SEC-042': { severity: 'LOW' } });
101
+ ```
102
+
103
+ ## `evaluateRule(rule, ctx): Finding`
104
+
105
+ Evaluates a single rule. Useful for testing a pack without running an audit.
106
+
107
+ ```ts
108
+ import { evaluateRule, ruleApplies, packApplies } from 'usat';
109
+
110
+ if (ruleApplies(rule, facts, depth)) {
111
+ const finding = evaluateRule(rule, ctx);
112
+ finding.status; // 'PASS' | 'FAIL' | 'MISSING' | 'UNKNOWN' | …
113
+ }
114
+ ```
115
+
116
+ ## `score(evaluated, sections, profile): ScoreCard`
117
+
118
+ ```ts
119
+ import { score } from 'usat';
120
+
121
+ const card = score(evaluated, sections, profile);
122
+ card.overall; // 88.7 — 0 when nothing resolved (never null; see below)
123
+ card.automationCoverage; // 70.8 — share of applicable rules verified without a human
124
+ card.sections; // [{ id, title, score: number | null, confidence, … }]
125
+ card.counts; // per-status totals, suppressed findings excluded
126
+ card.severityCounts; // per-severity open findings, suppressed excluded
127
+ card.expectedBand; // e.g. [60, 85] for the detected maturity stage
128
+ ```
129
+
130
+ A section whose rules all resolved to `UNKNOWN` scores **`null`**, not 10. It is
131
+ excluded from the numerator _and_ the denominator, and rendered as
132
+ `— not verified`. The **overall** score, however, is a number: `0` when
133
+ nothing resolved. A bare `0` cannot tell "everything failed" from "nothing
134
+ was verifiable" — read it together with `automationCoverage`, which is
135
+ exactly the confusion `docs/concepts.md` warns is the most misleading thing
136
+ an audit tool can produce.
137
+
138
+ ## `renderMarkdown(report, profile): string`
139
+
140
+ Deterministic Markdown, including the machine-readable trailer. Rule IDs in
141
+ the trailer are YAML-quoted, so pack-author-controlled IDs cannot corrupt
142
+ the machine-parsed channel.
143
+
144
+ ```ts
145
+ import { renderMarkdown, parseTrailer, trailer } from 'usat';
146
+
147
+ const md = renderMarkdown(report, profile);
148
+ const yaml = trailer(report); // the YAML string embedded in the trailer fences
149
+ const parsed = parseTrailer(md); // read a trailer back out (latest wins on concatenation)
150
+ ```
151
+
152
+ ## `diffReports(beforeRaw, afterRaw): string`
153
+
154
+ Takes two trailer YAML strings (or full reports — `parseTrailer` extracts),
155
+ returns Markdown. Reports fixed, regressed, changed-still-open, and newly
156
+ applicable rules with net point movement. Judgement-queue transitions are
157
+ first-class: `UNKNOWN → PASS` lists as fixed _(resolved by review)_ and
158
+ `PASS → UNKNOWN` as regressed _(needs review)_.
159
+
160
+ ```ts
161
+ import { diffReports, parseTrailer } from 'usat';
162
+
163
+ const md = diffReports(parseTrailer(beforeMd)!, parseTrailer(afterMd)!);
164
+ console.log(md); // # 🔁 USAT Audit Diff …
165
+ ```
166
+
167
+ ## `validatePredicate(p, where, warnings): void`
168
+
169
+ Validates an `applies_when` predicate the way the loader does: unknown keys
170
+ and operators, non-list `all`/`any`, and uncompilable `matches` regexes each
171
+ push a named warning. Use it when authoring packs programmatically —
172
+ evaluation fails closed (rule skipped) on anything this flags.
173
+
174
+ ```ts
175
+ import { validatePredicate } from 'usat';
176
+
177
+ const warnings: string[] = [];
178
+ validatePredicate({ fact: 'has:ci', op: 'bogus' }, 'my-pack MY-001', warnings);
179
+ // warnings: ['my-pack MY-001: unknown predicate op "bogus" — rule will never apply']
180
+ ```
181
+
182
+ ## `loadConfig(target, explicitPath?): UsatConfig`
183
+
184
+ Reads `.usat.yaml`. A missing file is not an error — it returns an empty config.
185
+ A malformed one throws, loudly, because silent config loss produces an audit
186
+ that quietly disagrees with the user's intent.
187
+
188
+ ## Types
189
+
190
+ `Severity` · `Status` · `RuleClass` · `Depth` · `Maturity` · `Location` ·
191
+ `Finding` · `Predicate` · `FactOp` · `Check` · `Rule` · `RulePack` ·
192
+ `AuditReport` · `UsatConfig` · `SectionDef` · `MaturityProfile` ·
193
+ `ScoredRule` · `EvalContext`
@@ -0,0 +1,412 @@
1
+ <!-- GENERATED by scripts/gen-cli-docs.mjs — do not hand-edit. -->
2
+
3
+ # CLI reference (generated)
4
+
5
+ Regenerated from the built CLI. If this file disagrees with `--help`, the file is stale — run `node scripts/gen-cli-docs.mjs` and commit.
6
+
7
+ ## `usat --help`
8
+
9
+ ```
10
+ usat — Universal Software Audit Template
11
+
12
+ usat audit [path] Audit a project and write a Markdown report
13
+ usat detect [path] Print the auto-detected facts and maturity
14
+ usat rules [--section S2] List all loaded rule packs and rules
15
+ usat explain <RULE-ID> Show everything about one rule
16
+ usat diff <before> <after> Compare two previously generated reports
17
+ usat init [path] Scaffold .usat.yaml + a GitHub Actions workflow
18
+
19
+ audit options
20
+ --out <file> Report path (default AUDIT.md)
21
+ --depth <level> quick | standard | deep (default standard)
22
+ --profile <stage> auto | prototype | mvp | beta | production | legacy
23
+ --rules-dir <dir> Rule pack directory (default bundled rules/)
24
+ --config <file> Explicit .usat.yaml location
25
+ --include <packs> Force these packs on (comma separated)
26
+ --exclude <packs> Force these packs off
27
+ --fact <ns:value> Assert a fact detection missed, e.g. --fact has:database
28
+ --allow-commands Run `command:` checks (shells out; off by default)
29
+ --fail-on <sev> Exit 1 on findings >= sev: critical|high|medium|low|none
30
+ --quiet Only errors
31
+
32
+ examples
33
+ usat audit . --depth deep
34
+ usat audit ../api --profile production --fail-on high
35
+ usat audit . --out reports/audit-$(date +%F).md
36
+ ```
37
+
38
+ ## `usat rules`
39
+
40
+ ```
41
+
42
+ ## core/repo — Repository & Project Structure (18 rules)
43
+ Root hygiene, the essential-files baseline, and version-control quality. Cheap to fix, expensive to ignore — this is where most leaked credentials and most onboarding pain originate.
44
+
45
+ REPO-001 CRITICAL security .gitignore is present
46
+ REPO-002 CRITICAL security No environment/secret files committed
47
+ REPO-003 CRITICAL security No secrets in git history
48
+ REPO-004 HIGH documentation README present
49
+ REPO-005 HIGH compliance LICENSE present
50
+ REPO-006 HIGH maintainability .env.example documents required configuration
51
+ REPO-007 HIGH maintainability Build artifacts and dependencies are not committed
52
+ REPO-008 MEDIUM maintainability Large binaries are not committed directly
53
+ REPO-009 HIGH security SECURITY.md published
54
+ REPO-010 MEDIUM documentation CHANGELOG maintained
55
+ REPO-011 LOW documentation CONTRIBUTING guide present
56
+ REPO-012 LOW compliance Code of conduct present
57
+ REPO-013 LOW style .editorconfig present
58
+ REPO-014 MEDIUM operations CODEOWNERS assigns review responsibility
59
+ REPO-015 LOW maintainability Commit history is meaningful
60
+ REPO-016 LOW maintainability Branch strategy is defined and stale branches pruned
61
+ REPO-017 MEDIUM maintainability Concern separation at the root
62
+ REPO-018 LOW documentation Agent instruction file present (AGENTS.md / CLAUDE.md)
63
+
64
+ ## core/security — Security (25 rules)
65
+ Universal security baseline. Severity is never dampened here below CRITICAL, and security-class rules carry the heaviest multiplier in the score. USAT is not a penetration test — it finds the doors that were left open.
66
+
67
+ SEC-001 CRITICAL security No hardcoded credentials in source
68
+ SEC-002 HIGH security Sensitive data is not written to logs
69
+ SEC-003 HIGH security No plaintext HTTP endpoints in configuration
70
+ SEC-004 HIGH security TLS verification is not disabled
71
+ SEC-005 CRITICAL security SQL is not built by string concatenation
72
+ SEC-006 HIGH security No unsafe dynamic code execution
73
+ SEC-007 CRITICAL security Shell commands are not built from user input
74
+ SEC-008 HIGH security User input is validated at a trust boundary
75
+ SEC-009 HIGH security Output is encoded rather than interpolated as HTML
76
+ SEC-010 HIGH security Path traversal is prevented on filesystem access
77
+ SEC-011 CRITICAL security Passwords use a modern adaptive hash
78
+ SEC-012 MEDIUM security Tokens and sessions expire
79
+ SEC-013 HIGH security JWTs are not accepted with alg:none or unverified
80
+ SEC-014 HIGH security Failed authentication is rate limited
81
+ SEC-015 HIGH security Authorization is enforced per request, not per route
82
+ SEC-016 HIGH security Secrets come from a manager in production
83
+ SEC-017 HIGH security CORS is not a wildcard
84
+ SEC-018 MEDIUM security Security headers are set
85
+ SEC-019 MEDIUM security CSRF protection for cookie-based sessions
86
+ SEC-020 MEDIUM security Errors do not leak internals to clients
87
+ SEC-021 MEDIUM security Cryptographic randomness for tokens and IDs
88
+ SEC-022 HIGH security Uploads are validated for type, size, and content
89
+ SEC-023 HIGH compliance PII is identified and protected at rest
90
+ SEC-024 MEDIUM compliance Secrets and PII are redacted in logs and telemetry
91
+ SEC-025 HIGH security Adaptive password hashing is present where auth exists
92
+
93
+ ## core/supply-chain — Supply Chain & Build Provenance (17 rules)
94
+ Promoted to its own section in USAT. You can write perfect code and still ship someone else's backdoor: these controls cover the path from a contributor's editor to the artifact your users run. Aligned with SLSA v1.2, NIST SSDF (SP 800-218), and the OpenSSF Scorecard.
95
+
96
+ SUP-001 HIGH supply-chain A lockfile is committed
97
+ SUP-002 MEDIUM supply-chain CI installs with a frozen lockfile
98
+ SUP-003 MEDIUM supply-chain Dependency versions are pinned, not floating
99
+ SUP-004 MEDIUM supply-chain Automated dependency updates are configured
100
+ SUP-005 HIGH supply-chain Dependency vulnerability scanning runs in CI
101
+ SUP-006 MEDIUM supply-chain SAST runs in CI
102
+ SUP-007 MEDIUM supply-chain Secret scanning runs in CI
103
+ SUP-008 HIGH supply-chain CI workflows avoid script-injection patterns
104
+ SUP-009 MEDIUM supply-chain Workflows declare least-privilege token permissions
105
+ SUP-010 MEDIUM supply-chain Third-party actions are pinned to a version or SHA
106
+ SUP-011 CRITICAL supply-chain No secrets in CI configuration
107
+ SUP-012 HIGH supply-chain Default branch is protected
108
+ SUP-013 LOW supply-chain Commits are signed or attested
109
+ SUP-014 LOW supply-chain An SBOM is generated for releases
110
+ SUP-015 FUTURE supply-chain Release artifacts carry provenance attestation
111
+ SUP-016 MEDIUM supply-chain Container images are scanned before publish
112
+ SUP-017 FUTURE supply-chain Build pipeline is reproducible from source
113
+
114
+ ## core/architecture — Architecture & Design (10 rules)
115
+ Structure, boundaries, and the decisions behind them. Mostly judgement — USAT automates the parts that show up as files and flags the rest for review rather than pretending a regex can measure coupling.
116
+
117
+ ARCH-001 MEDIUM documentation Architecture is documented
118
+ ARCH-002 LOW documentation Architecture decisions are recorded (ADRs)
119
+ ARCH-003 MEDIUM maintainability No god files
120
+ ARCH-004 MEDIUM maintainability Layers are separated (transport / domain / data)
121
+ ARCH-005 HIGH maintainability No circular dependencies between modules
122
+ ARCH-006 LOW maintainability Module boundaries are enforced by tooling
123
+ ARCH-007 MEDIUM operations Configuration is externalised
124
+ ARCH-008 LOW maintainability Side effects are isolated and testable
125
+ ARCH-009 MEDIUM operations Single points of failure are identified
126
+ ARCH-010 LOW performance Async work is offloaded to a queue
127
+
128
+ ## core/code-quality — Code Quality (13 rules)
129
+ Linting, typing, error handling, and logging hygiene. These are the rules an agent should be able to settle without asking a human — most of them are answered by looking for a config file.
130
+
131
+ CQ-001 MEDIUM maintainability A linter is configured
132
+ CQ-002 LOW style A formatter is configured
133
+ CQ-003 MEDIUM correctness Type checking is enabled and strict
134
+ CQ-004 LOW maintainability Type escapes are not used as a default
135
+ CQ-005 HIGH correctness Errors are handled, not swallowed
136
+ CQ-006 MEDIUM correctness There is a central error handler
137
+ CQ-007 LOW operations Logging is structured and levelled
138
+ CQ-008 LOW operations Requests carry a correlation/trace ID
139
+ CQ-009 LOW style Debug statements are not left in production paths
140
+ CQ-010 LOW maintainability TODO/FIXME debt is tracked, not just annotated
141
+ CQ-011 LOW maintainability Functions do one thing
142
+ CQ-012 MEDIUM maintainability Duplicated logic has been consolidated
143
+ CQ-013 FUTURE maintainability Complexity is measured
144
+
145
+ ## core/testing — Testing & Quality Assurance (12 rules)
146
+ Coverage is a weak proxy for confidence; USAT separates "tests exist", "tests run in CI", and "tests actually cover the paths that matter".
147
+
148
+ TEST-001 HIGH correctness A test suite exists
149
+ TEST-002 HIGH operations Tests run in CI on every pull request
150
+ TEST-003 MEDIUM correctness There is a meaningful number of tests
151
+ TEST-004 MEDIUM correctness Coverage is measured
152
+ TEST-005 LOW correctness Coverage thresholds are enforced
153
+ TEST-006 MEDIUM correctness Integration tests cover the seams
154
+ TEST-007 MEDIUM correctness End-to-end tests cover critical user journeys
155
+ TEST-008 MEDIUM security Security-relevant behaviour is tested
156
+ TEST-009 MEDIUM correctness Tests are independent and deterministic
157
+ TEST-010 FUTURE performance Performance/load tests exist for critical paths
158
+ TEST-011 FUTURE correctness Mutation testing or equivalent
159
+ TEST-012 LOW maintainability Test data comes from fixtures or factories
160
+
161
+ ## core/cicd — CI/CD, Infrastructure & Observability (12 rules)
162
+ How code becomes running software, and how you find out when it breaks. Heavily informed by the OpenSSF Scorecard and DORA's delivery metrics.
163
+
164
+ CICD-001 HIGH operations A CI pipeline exists
165
+ CICD-002 MEDIUM operations CI runs lint, test, and build
166
+ CICD-003 HIGH operations Deployment is automated
167
+ CICD-004 HIGH operations A rollback path exists and has been exercised
168
+ CICD-005 MEDIUM operations Separate environments exist
169
+ CICD-006 MEDIUM operations Infrastructure is defined as code
170
+ CICD-007 MEDIUM operations Health check endpoints exist
171
+ CICD-008 MEDIUM operations Error tracking / APM is configured
172
+ CICD-009 MEDIUM operations Alerting is configured for critical failures
173
+ CICD-010 HIGH operations Backups exist AND restores have been tested
174
+ CICD-011 MEDIUM operations A disaster recovery plan exists
175
+ CICD-012 LOW operations Observability covers the golden signals
176
+
177
+ ## core/release — Release & Change Management (7 rules)
178
+ How a merged commit becomes a version someone else depends on. This section is what separates "we deploy" from "we ship".
179
+
180
+ REL-001 MEDIUM maintainability Versioning is semantic and consistent
181
+ REL-002 MEDIUM operations Releases are tagged in version control
182
+ REL-003 LOW documentation Release notes are published
183
+ REL-004 LOW operations Risky changes sit behind a feature flag
184
+ REL-005 HIGH correctness Database migrations run forward and are reversible
185
+ REL-006 MEDIUM correctness Migrations are separated from application deploys
186
+ REL-007 MEDIUM operations There is a documented incident/runbook path
187
+
188
+ ## core/dependencies — Dependencies & Third-Party (8 rules)
189
+ Every dependency is a bet on someone else's maintenance discipline. USAT scores the observable parts and hands the rest to review.
190
+
191
+ DEP-001 MEDIUM supply-chain Dependencies are declared in a manifest
192
+ DEP-002 HIGH supply-chain No known-HIGH/CRITICAL vulnerabilities in dependencies
193
+ DEP-003 MEDIUM supply-chain Dependencies are actively maintained
194
+ DEP-004 LOW maintainability No obviously redundant dependencies
195
+ DEP-005 LOW maintainability Unused dependencies are pruned
196
+ DEP-006 MEDIUM compliance Licenses are compatible with the project license
197
+ DEP-007 MEDIUM operations External services have documented failure modes
198
+ DEP-008 HIGH security Webhook payloads are signature-verified
199
+
200
+ ## core/documentation — Documentation & Knowledge (7 rules)
201
+ Documentation is the only part of the system that ships to every future maintainer. USAT checks the artefacts exist and then asks whether they are true.
202
+
203
+ DOC-001 MEDIUM documentation README covers what / install / run / contribute
204
+ DOC-002 MEDIUM documentation Setup instructions have been verified recently
205
+ DOC-003 MEDIUM documentation Public APIs are documented
206
+ DOC-004 LOW documentation Complex logic is explained at the point of use
207
+ DOC-005 LOW documentation Docs live in the repo with the code
208
+ DOC-006 LOW documentation An onboarding path exists
209
+ DOC-007 FUTURE documentation Documentation examples are tested
210
+
211
+ ## core/future-readiness — Future Readiness (6 rules)
212
+ Not needed today, expensive to bolt on later. These are plans, not defects — every rule here is FUTURE severity and never blocks a release.
213
+
214
+ FUT-001 FUTURE maintainability A path off the current architecture exists
215
+ FUT-002 FUTURE maintainability No core technology is at or near end of life
216
+ FUT-003 FUTURE operations Data archiving strategy exists
217
+ FUT-004 FUTURE operations Multi-region or failover is at least designed
218
+ FUT-005 FUTURE maintainability A tech radar or equivalent exists
219
+ FUT-006 FUTURE operations Cost/usage is monitored
220
+
221
+ ## stacks/node-typescript — Node.js / TypeScript (9 rules)
222
+ Activated when JavaScript or TypeScript is detected.
223
+ NODE-001 MEDIUM operations Node runtime version is pinned
224
+ NODE-002 MEDIUM correctness TypeScript strict mode is on
225
+ NODE-003 MEDIUM correctness Unhandled promise rejections are handled
226
+ NODE-004 CRITICAL security No private registry credentials committed
227
+ NODE-005 MEDIUM maintainability No deprecated Node APIs in use
228
+ NODE-006 MEDIUM correctness Environment variables are validated at startup
229
+ NODE-007 LOW performance Libraries declare sideEffects / exports for tree-shaking
230
+ NODE-008 LOW maintainability Module system is consistent
231
+ NODE-009 LOW operations A fast, isolated runtime is used for tests
232
+
233
+ ## stacks/python — Python (10 rules)
234
+ Activated when Python is detected.
235
+ PY-001 MEDIUM supply-chain Dependencies are declared in a modern manifest
236
+ PY-002 MEDIUM operations Python version is pinned
237
+ PY-003 MEDIUM supply-chain Dependencies are pinned to exact versions
238
+ PY-004 MEDIUM correctness No bare except clauses
239
+ PY-005 MEDIUM correctness No mutable default arguments
240
+ PY-006 CRITICAL security No unsafe deserialisation
241
+ PY-007 HIGH security Subprocess calls do not use shell=True
242
+ PY-008 CRITICAL security Debug mode is not enabled outside local development
243
+ PY-009 LOW maintainability Type hints are used on public functions
244
+ PY-010 MEDIUM maintainability A linter/formatter is configured for Python
245
+
246
+ ## stacks/go — Go (8 rules)
247
+ Activated when Go is detected.
248
+ GO-001 MEDIUM operations go.mod declares the Go version
249
+ GO-002 HIGH correctness Errors are checked, not discarded
250
+ GO-003 MEDIUM correctness Contexts are propagated
251
+ GO-004 MEDIUM correctness No panics in request paths
252
+ GO-005 MEDIUM maintainability go vet / staticcheck / golangci-lint runs in CI
253
+ GO-006 MEDIUM correctness Goroutine lifecycle is bounded
254
+ GO-007 CRITICAL security SQL is parameterised
255
+ GO-008 MEDIUM performance HTTP servers set timeouts
256
+
257
+ ## stacks/rust — Rust (7 rules)
258
+ Activated when Rust is detected.
259
+ RS-001 MEDIUM maintainability Cargo.toml declares edition and metadata
260
+ RS-002 MEDIUM correctness No unwrap/expect in non-test code
261
+ RS-003 HIGH security unsafe blocks are justified and minimal
262
+ RS-004 MEDIUM maintainability Clippy runs in CI
263
+ RS-005 MEDIUM correctness No todo!/unimplemented! in shipped paths
264
+ RS-006 MEDIUM supply-chain Dependency audit runs in CI (cargo-audit / deny)
265
+ RS-007 LOW performance Release builds are optimised and stripped
266
+
267
+ ## stacks/jvm — Java / Kotlin / JVM (8 rules)
268
+ Activated when Java, Kotlin, or Scala is detected.
269
+ JVM-001 MEDIUM supply-chain Dependency versions are managed centrally
270
+ JVM-002 CRITICAL security No hardcoded credentials in configuration
271
+ JVM-003 MEDIUM correctness Exception handling does not swallow stack traces
272
+ JVM-004 CRITICAL security Parameterised SQL / JPA criteria instead of concatenation
273
+ JVM-005 LOW correctness Nullability is explicit
274
+ JVM-006 MEDIUM supply-chain Static analysis runs in CI
275
+ JVM-007 HIGH security Insecure deserialisation is avoided
276
+ JVM-008 LOW performance JVM/container memory limits are respected
277
+
278
+ ## stacks/web-frontend — Web Frontend (9 rules)
279
+ Activated for browser-facing applications. Covers Core Web Vitals, a11y, and bundle discipline.
280
+ WEB-001 MEDIUM performance Core Web Vitals are measured
281
+ WEB-002 MEDIUM performance Code splitting / lazy loading is used
282
+ WEB-003 MEDIUM performance Images are optimised
283
+ WEB-004 MEDIUM compliance Accessibility basics are in place
284
+ WEB-005 LOW performance Bundle size is monitored
285
+ WEB-006 MEDIUM correctness Error boundaries exist around risky UI
286
+ WEB-007 CRITICAL security No secrets in client-side bundles
287
+ WEB-008 MEDIUM compliance Forms validate and expose errors accessibly
288
+ WEB-009 FUTURE performance An offline/PWA story exists
289
+
290
+ ## stacks/mobile — Mobile (iOS / Android / Cross-platform) (8 rules)
291
+ Activated when iOS, Android, React Native, Expo, or Flutter is detected.
292
+ MOB-001 HIGH operations Crash reporting is integrated
293
+ MOB-002 CRITICAL security No hardcoded API secrets in app bundles
294
+ MOB-003 HIGH security Sensitive data is not stored insecurely on device
295
+ MOB-004 MEDIUM security Network security configuration is explicit
296
+ MOB-005 MEDIUM compliance Permissions are requested minimally and with rationale
297
+ MOB-006 MEDIUM correctness Offline behaviour is handled
298
+ MOB-007 HIGH compliance Privacy manifests / data collection disclosure are present
299
+ MOB-008 MEDIUM correctness Tested on multiple screen sizes and OS versions
300
+
301
+ ## stacks/containers — Containers & Runtime (8 rules)
302
+ Activated when Docker, compose, or Kubernetes manifests are detected.
303
+ CTNR-001 HIGH security Container does not run as root
304
+ CTNR-002 MEDIUM performance Multi-stage builds are used
305
+ CTNR-003 MEDIUM supply-chain Base image is minimal and pinned
306
+ CTNR-004 MEDIUM supply-chain A .dockerignore exists
307
+ CTNR-005 CRITICAL security No secrets baked into the image
308
+ CTNR-006 MEDIUM operations HEALTHCHECK is defined
309
+ CTNR-007 MEDIUM performance Kubernetes workloads declare resource limits
310
+ CTNR-008 MEDIUM supply-chain Images are scanned and signed
311
+
312
+ ## stacks/iac — Infrastructure as Code & Cloud (7 rules)
313
+ Activated when Terraform/OpenTofu, Pulumi, Ansible, or Kubernetes manifests are detected.
314
+ IAC-001 CRITICAL security No public exposure of storage buckets or databases
315
+ IAC-002 HIGH security Encryption at rest is enabled
316
+ IAC-003 MEDIUM supply-chain IaC is validated and scanned before apply
317
+ IAC-004 HIGH operations State is stored remotely and locked
318
+ IAC-005 HIGH security IAM follows least privilege
319
+ IAC-006 LOW operations Cloud spend is tagged and budgeted
320
+ IAC-007 HIGH security Kubernetes manifests avoid privileged containers
321
+
322
+ ## stacks/solidity — Blockchain / Smart Contracts (10 rules)
323
+ Activated when Solidity, Foundry, or Hardhat is detected. USAT is not a substitute for a third-party audit.
324
+ SOLID-001 CRITICAL security Contracts are protected against reentrancy
325
+ SOLID-002 HIGH security Compiler version is 0.8+ (or SafeMath is used)
326
+ SOLID-003 CRITICAL security Access control is explicit on privileged functions
327
+ SOLID-004 CRITICAL security tx.origin is not used for authorisation
328
+ SOLID-005 HIGH security External calls are checked and treated as untrusted
329
+ SOLID-006 MEDIUM security No block.timestamp dependence for critical logic
330
+ SOLID-007 MEDIUM maintainability Events are emitted for state changes
331
+ SOLID-008 MEDIUM operations An emergency pause mechanism exists
332
+ SOLID-009 HIGH correctness A test suite with fuzzing/invariants exists
333
+ SOLID-010 HIGH security Third-party security audit has been performed
334
+
335
+ ## stacks/ml-ai — ML / AI Systems (9 rules)
336
+ Activated when PyTorch/TensorFlow/JAX, notebooks, or model artefacts are detected.
337
+ ML-001 MEDIUM maintainability Training data is versioned
338
+ ML-002 MEDIUM operations Model artefacts are versioned and registered
339
+ ML-003 MEDIUM correctness Training is reproducible (seeded and pinned)
340
+ ML-004 MEDIUM operations Model/data drift is monitored in production
341
+ ML-005 MEDIUM compliance Predictions are logged for audit
342
+ ML-006 MEDIUM compliance Bias/fairness has been evaluated
343
+ ML-007 MEDIUM maintainability Notebooks are not the deployment path
344
+ ML-008 LOW performance Inference cost and latency are tracked
345
+ ML-009 MEDIUM maintainability Model files are not committed to git
346
+
347
+ ## stacks/cli — CLI Tools (7 rules)
348
+ Activated when the project exposes a binary or console script entry point.
349
+ CLI-001 MEDIUM documentation --help is implemented and useful
350
+ CLI-002 MEDIUM correctness Exit codes are meaningful
351
+ CLI-003 HIGH correctness Destructive operations support --dry-run
352
+ CLI-004 MEDIUM security Input from arguments and stdin is validated
353
+ CLI-005 MEDIUM correctness Operations are idempotent where expected
354
+ CLI-006 LOW correctness Errors go to stderr, output to stdout
355
+ CLI-007 LOW maintainability Machine-readable output mode exists
356
+
357
+ ## stacks/data — Data & Database (10 rules)
358
+ Activated when a database, ORM, or migrations directory is detected.
359
+ DATA-001 HIGH correctness A migration system is in place
360
+ DATA-002 MEDIUM correctness Foreign keys / relations are defined
361
+ DATA-003 MEDIUM performance Indexes exist on queried columns
362
+ DATA-004 HIGH performance No N+1 query patterns
363
+ DATA-005 HIGH performance List queries are paginated
364
+ DATA-006 MEDIUM performance Connection pooling is configured
365
+ DATA-007 HIGH correctness Multi-step writes are transactional
366
+ DATA-008 LOW performance No SELECT * in hot paths
367
+ DATA-009 LOW compliance Delete strategy is defined
368
+ DATA-010 HIGH security Row-level access is enforced in the data layer
369
+
370
+ ## stacks/api-backend — Backend / API (8 rules)
371
+ Activated for server-side applications and API services.
372
+ API-001 MEDIUM maintainability The API is versioned
373
+ API-002 HIGH performance Request timeouts are configured
374
+ API-003 MEDIUM performance Retries are bounded with jitter
375
+ API-004 MEDIUM correctness Write operations are idempotent
376
+ API-005 LOW maintainability Response format is consistent
377
+ API-006 MEDIUM documentation An OpenAPI/contract spec exists and is current
378
+ API-007 HIGH security GraphQL depth/complexity limits are enforced
379
+ API-008 LOW operations Health and readiness endpoints are unauthenticated but minimal
380
+
381
+ ## stacks/compliance — Accessibility, i18n & Compliance (10 rules)
382
+ Accessibility, internationalisation, and regulatory obligations. Most of these are judgement calls — USAT records what it can and asks for evidence on the rest.
383
+
384
+ COMP-001 MEDIUM compliance Interactive elements are keyboard accessible
385
+ COMP-002 MEDIUM compliance Form inputs have associated labels
386
+ COMP-003 MEDIUM compliance Colour contrast meets WCAG AA
387
+ COMP-004 MEDIUM compliance Content is not hardcoded to one locale
388
+ COMP-005 LOW compliance Dates, numbers, and currencies are locale-aware
389
+ COMP-006 MEDIUM compliance A privacy policy and terms exist and match reality
390
+ COMP-007 HIGH compliance Data subject rights are implemented
391
+ COMP-008 HIGH compliance Card data is kept out of scope
392
+ COMP-009 MEDIUM compliance Cookie / consent notice is compliant
393
+ COMP-010 LOW compliance Source files carry an SPDX license identifier
394
+
395
+ ## stacks/ai-era — AI / LLM-Era Risks (12 rules)
396
+ New in USAT. Your application may be deterministic while depending on a component that is not. Mapped to the OWASP Top 10 for LLM Applications (2026) and the OWASP Top 10 for Agentic AI (ASI, 2026).
397
+
398
+ AI-001 CRITICAL security Untrusted content cannot override instructions
399
+ AI-002 CRITICAL security Model output is validated before it is executed
400
+ AI-003 HIGH security Agents and tools run with least privilege
401
+ AI-004 HIGH security Secrets and PII do not reach model providers unchecked
402
+ AI-005 MEDIUM performance Inference spend and token usage are bounded
403
+ AI-006 MEDIUM security System prompts and tool schemas are not exposed
404
+ AI-007 HIGH security RAG retrieval is access-controlled per tenant
405
+ AI-008 MEDIUM supply-chain Model and prompt supply chain is pinned
406
+ AI-009 MEDIUM correctness An eval suite exists for model behaviour
407
+ AI-010 HIGH security Consequential actions require human confirmation
408
+ AI-011 MEDIUM security Agent instruction files are scoped and safe
409
+ AI-012 LOW compliance Model inputs and outputs are logged for audit
410
+
411
+ 275 rule(s) across 27 pack(s).
412
+ ```