@xenos1996/usa 2.4.0 → 2.6.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 (45) hide show
  1. package/README.md +2 -2
  2. package/dist/agent/index.d.ts +9 -0
  3. package/dist/agent/index.d.ts.map +1 -0
  4. package/dist/agent/index.js +2 -0
  5. package/dist/agent/index.js.map +1 -0
  6. package/dist/agent/providers.d.ts +56 -0
  7. package/dist/agent/providers.d.ts.map +1 -0
  8. package/dist/agent/providers.js +334 -0
  9. package/dist/agent/providers.js.map +1 -0
  10. package/dist/agent/types.d.ts +103 -0
  11. package/dist/agent/types.d.ts.map +1 -0
  12. package/dist/agent/types.js +19 -0
  13. package/dist/agent/types.js.map +1 -0
  14. package/dist/cli.d.ts +1 -1
  15. package/dist/cli.d.ts.map +1 -1
  16. package/dist/cli.js +115 -2
  17. package/dist/cli.js.map +1 -1
  18. package/dist/engine/categories.d.ts +45 -0
  19. package/dist/engine/categories.d.ts.map +1 -0
  20. package/dist/engine/categories.js +148 -0
  21. package/dist/engine/categories.js.map +1 -0
  22. package/dist/engine/test-evidence.d.ts +84 -0
  23. package/dist/engine/test-evidence.d.ts.map +1 -0
  24. package/dist/engine/test-evidence.js +154 -0
  25. package/dist/engine/test-evidence.js.map +1 -0
  26. package/dist/index.d.ts +7 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +5 -0
  29. package/dist/index.js.map +1 -1
  30. package/dist/live/runner.d.ts +34 -0
  31. package/dist/live/runner.d.ts.map +1 -0
  32. package/dist/live/runner.js +220 -0
  33. package/dist/live/runner.js.map +1 -0
  34. package/dist/live/session.d.ts +25 -0
  35. package/dist/live/session.d.ts.map +1 -0
  36. package/dist/live/session.js +100 -0
  37. package/dist/live/session.js.map +1 -0
  38. package/dist/live/types.d.ts +31 -0
  39. package/dist/live/types.d.ts.map +1 -0
  40. package/dist/live/types.js +9 -0
  41. package/dist/live/types.js.map +1 -0
  42. package/package.json +1 -1
  43. package/rules/categories.yaml +124 -0
  44. package/rules/core/testing-assurance.yaml +240 -0
  45. package/rules/index.yaml +1 -0
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Live conversational audit sessions — shared types.
3
+ *
4
+ * Doctrine: the session is a deterministic state machine. The transcript is
5
+ * the artifact; it carries no timestamps so its rendering is byte-stable and
6
+ * test-assertable (structure asserted, never times).
7
+ */
8
+ import type { ChatRequest, ChatResult } from '../agent/types.js';
9
+ /** Conversational phases, in walking order. */
10
+ export type SessionPhase = 'idle' | 'foundation' | 'audit' | 'triage' | 'report' | 'done';
11
+ /** Who produced a transcript line. */
12
+ export type TranscriptKind = 'user' | 'tool' | 'model' | 'decision';
13
+ /** One deterministic transcript line: no timestamps by design. */
14
+ export interface TranscriptEntry {
15
+ phase: SessionPhase;
16
+ kind: TranscriptKind;
17
+ text: string;
18
+ }
19
+ /** Reducer state: where the session is, what was said, what was learned. */
20
+ export interface SessionState {
21
+ phase: SessionPhase;
22
+ transcript: TranscriptEntry[];
23
+ facts: string[];
24
+ }
25
+ /** LLM call behind an injectable interface. Types come from `src/agent` only. */
26
+ export type ChatFn = (req: ChatRequest) => Promise<ChatResult>;
27
+ /** Synchronous line reader injected by the caller (stdin in the CLI). */
28
+ export type AskFn = (prompt: string) => string | null | Promise<string | null>;
29
+ /** Line printer injected by the caller (console in the CLI). */
30
+ export type PrintFn = (line: string) => void;
31
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/live/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEjE,+CAA+C;AAC/C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE1F,sCAAsC;AACtC,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;AAEpE,kEAAkE;AAClE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,4EAA4E;AAC5E,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,YAAY,CAAC;IACpB,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,iFAAiF;AACjF,MAAM,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAE/D,yEAAyE;AACzE,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE/E,gEAAgE;AAChE,MAAM,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Live conversational audit sessions — shared types.
3
+ *
4
+ * Doctrine: the session is a deterministic state machine. The transcript is
5
+ * the artifact; it carries no timestamps so its rendering is byte-stable and
6
+ * test-assertable (structure asserted, never times).
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/live/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xenos1996/usa",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "Universal Software Auditor — an open-source, self-adapting audit framework for any project, any stack, any stage",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -0,0 +1,124 @@
1
+ # =============================================================================
2
+ # USA assurance categories (schema: usa-categories-v1)
3
+ # -----------------------------------------------------------------------------
4
+ # The future-ready categorization axis: ten stable categories that group the
5
+ # sixteen report sections (S1..S16) and the rule-id prefixes into assurance
6
+ # themes. Categories never replace sections and never change scoring — they
7
+ # are a *derived* view (see src/engine/categories.ts), the same derivation
8
+ # precedent ADR-0021 set for catalogues.
9
+ #
10
+ # Honesty discipline (normative): every description states IMPLEMENTED (real
11
+ # rules mapped below) or PROPOSED (aspirational, no rules mapped yet). An
12
+ # aspirational-but-empty category is a valid, labeled state — never pad
13
+ # `sections` or `rulePrefixes` to fake coverage.
14
+ #
15
+ # Adding a category is not supported: the set is frozen at these ten ids and
16
+ # the loader skips any unknown id with a warning.
17
+ # =============================================================================
18
+
19
+ schema: usa-categories-v1
20
+
21
+ categories:
22
+ - id: foundational
23
+ name: Foundational
24
+ description: 'Status: IMPLEMENTED. Covers repository structure, project hygiene, and
25
+ foundation readiness — the ground an audit stands on. It matters for
26
+ assurance because undetectable projects (no manifest, no VCS, no stated
27
+ intent) cannot be audited deterministically, so every deeper category
28
+ depends on this one holding.'
29
+ sections: [S1, S3]
30
+ rulePrefixes: [REPO-, FND-]
31
+
32
+ - id: security
33
+ name: Security
34
+ description: 'Status: IMPLEMENTED. Covers application security controls, supply-chain
35
+ integrity and provenance, and dependency risk — what keeps malicious
36
+ input, tampered artifacts, and known-vulnerable components out. It
37
+ matters for assurance because a single auth or provenance failure
38
+ outweighs tidy docs or passing linters, which is why these rules carry
39
+ the heaviest scoring weights.'
40
+ sections: [S2, S3, S10]
41
+ rulePrefixes: [SEC-, SUP-, DEP-]
42
+
43
+ - id: networking
44
+ name: Networking
45
+ description: 'Status: PROPOSED — aspirational, no rules mapped yet. Will cover
46
+ transport security, DNS hygiene, ingress/egress policy, and service
47
+ connectivity. It matters for assurance because most breaches cross a
48
+ network boundary, but the current rule tree has no dedicated networking
49
+ checks, so this category is an empty placeholder until such packs land.'
50
+ sections: []
51
+ rulePrefixes: []
52
+
53
+ - id: communication
54
+ name: Communication
55
+ description: 'Status: PROPOSED — aspirational, no rules mapped yet. Will cover
56
+ messaging, eventing, notification, and human coordination surfaces
57
+ (queues, webhooks, changelogs, incident channels). It matters for
58
+ assurance because silent systems fail silently, but the current rule
59
+ tree has no communication packs, so this category stays empty by
60
+ design rather than borrowing unrelated rules.'
61
+ sections: []
62
+ rulePrefixes: []
63
+
64
+ - id: ux
65
+ name: User Experience
66
+ description: 'Status: PROPOSED — aspirational, no rules mapped yet. Will cover
67
+ interaction quality, accessibility behaviour, and user-facing clarity
68
+ beyond static compliance text. It matters for assurance because users
69
+ work around hostile interfaces in unsafe ways, but the current tree
70
+ holds no dedicated UX checks, so nothing is mapped here yet.'
71
+ sections: []
72
+ rulePrefixes: []
73
+
74
+ - id: vision
75
+ name: Vision
76
+ description: 'Status: PROPOSED — aspirational, no rules mapped yet. Will cover the
77
+ live-assurance future: continuous verification, runtime attestation,
78
+ and audit-as-a-service loops that outgrow point-in-time reports. It
79
+ matters for assurance because auditing must become continuous to stay
80
+ relevant, but no vision packs exist yet, so this category is a labeled
81
+ empty axis awaiting them.'
82
+ sections: []
83
+ rulePrefixes: []
84
+
85
+ - id: technical-sota
86
+ name: Technical State of the Art
87
+ description: "Status: IMPLEMENTED. Covers AI/LLM-era risk controls, machine-learning
88
+ stack hygiene, and future-readiness signals — the frontier where new
89
+ failure modes appear first. It matters for assurance because yesterday's
90
+ checklist misses prompt injection, model provenance, and framework
91
+ churn, so the audit must track what the state of the art demands now."
92
+ sections: [S14, S15, S16]
93
+ rulePrefixes: [AI-, ML-, FUT-]
94
+
95
+ - id: architecture
96
+ name: Architecture
97
+ description: 'Status: IMPLEMENTED. Covers system structure, modularity, and design
98
+ intent — the decisions that make a codebase comprehensible or
99
+ accidental. It matters for assurance because architectural drift
100
+ compounds every other risk: monoliths that should be modules fail
101
+ reviews, rollbacks, and onboarding alike.'
102
+ sections: [S4]
103
+ rulePrefixes: [ARCH-]
104
+
105
+ - id: standards
106
+ name: Standards
107
+ description: 'Status: IMPLEMENTED. Covers compliance posture and alignment with
108
+ external frameworks — accessibility, licensing, data-protection, and
109
+ regulatory duties. It matters for assurance because contractual and
110
+ legal obligations are audit findings with counterparties, not opinions,
111
+ so conformance evidence must be checkable independently of taste.'
112
+ sections: [S13]
113
+ rulePrefixes: [COMP-]
114
+
115
+ - id: protocol
116
+ name: Protocol
117
+ description: 'Status: PROPOSED — aspirational, no rules mapped yet. Will cover
118
+ wire-protocol conformance, API contract fidelity, and schema
119
+ compatibility guarantees. It matters for assurance because
120
+ integrations fail at boundaries, but the current tree has no
121
+ protocol-conformance packs, so this category is empty until they
122
+ exist.'
123
+ sections: []
124
+ rulePrefixes: []
@@ -0,0 +1,240 @@
1
+ id: core/testing-assurance
2
+ title: Testing Assurance Markers
3
+ section: S7
4
+ section_title: Testing & Quality Assurance
5
+ description: >
6
+ Deterministic presence-markers for the testing assurance program: unit,
7
+ integration, and system layouts; contract tests; coverage and mutation
8
+ evidence; retry/determinism guards; failure assertions; and test-data
9
+ isolation. Every rule asserts only that a marker exists — never that the
10
+ tests are good, sufficient, or green.
11
+ version: '1.0'
12
+
13
+ rules:
14
+ - id: TAS-001
15
+ title: A unit-test layout exists
16
+ section: S7
17
+ section_title: Testing & Quality Assurance
18
+ severity: MEDIUM
19
+ class: correctness
20
+ check:
21
+ kind: any_file
22
+ patterns:
23
+ - 'tests/unit/**'
24
+ - 'test/unit/**'
25
+ - 'unit/**'
26
+ - '**/*.unit.test.*'
27
+ - '**/*.unit.spec.*'
28
+ why: 'A conventional unit-test location tells contributors and CI exactly where confidence lives.'
29
+ remediation: 'Put unit tests under tests/unit (or mark them *.unit.test.*) and wire the directory into CI.'
30
+ references: ['Testing-Trophy', 'OpenSSF-Scorecard:CI-Tests']
31
+
32
+ - id: TAS-002
33
+ title: An integration-test layout exists
34
+ section: S7
35
+ section_title: Testing & Quality Assurance
36
+ severity: MEDIUM
37
+ class: correctness
38
+ check:
39
+ kind: any_file
40
+ patterns:
41
+ - 'tests/integration/**'
42
+ - 'test/integration/**'
43
+ - 'tests/integ/**'
44
+ - '**/*.integration.test.*'
45
+ - '**/*.integ.test.*'
46
+ - '**/*.int.test.*'
47
+ why: 'Unit tests with everything mocked verify the mock, not the seam; a named integration layout is where seam coverage lives.'
48
+ remediation: 'Add tests/integration with tests that exercise a real database, queue, or HTTP boundary.'
49
+ references: ['Testing-Trophy']
50
+
51
+ - id: TAS-003
52
+ title: A system/end-to-end test layout exists
53
+ section: S7
54
+ section_title: Testing & Quality Assurance
55
+ severity: MEDIUM
56
+ class: correctness
57
+ check:
58
+ kind: any_file
59
+ patterns:
60
+ - 'tests/e2e/**'
61
+ - 'test/e2e/**'
62
+ - 'e2e/**'
63
+ - 'tests/system/**'
64
+ - 'test/system/**'
65
+ - 'system-tests/**'
66
+ - '**/*.e2e.*'
67
+ why: 'Unit tests cannot tell you that checkout is broken because a button moved; a system-level layout is where journey coverage lives.'
68
+ remediation: 'Cover three journeys first: sign up/log in, the core money path, and the path that would lose data if it failed.'
69
+ references: ['Testing-Trophy']
70
+
71
+ - id: TAS-004
72
+ title: Contract tests are present
73
+ section: S7
74
+ section_title: Testing & Quality Assurance
75
+ severity: LOW
76
+ class: correctness
77
+ check:
78
+ kind: any_file
79
+ patterns:
80
+ - 'pacts/**'
81
+ - 'pact/**'
82
+ - '**/*.pact.*'
83
+ - 'tests/contracts/**'
84
+ - 'tests/contract/**'
85
+ - 'test/contracts/**'
86
+ - '**/*.contract.test.*'
87
+ - '**/*.contract.spec.*'
88
+ why: 'An API without checked-in consumer contracts can only be tested by hand; pact files and contract suites are the machine-checkable shadow of that agreement.'
89
+ remediation: 'Record consumer-driven contracts (e.g. Pact) or add a tests/contracts suite asserting request/response shapes.'
90
+ references: ['OpenAPI', 'Testing-Trophy']
91
+
92
+ - id: TAS-005
93
+ title: Coverage configuration or output is present
94
+ section: S7
95
+ section_title: Testing & Quality Assurance
96
+ severity: LOW
97
+ class: correctness
98
+ check:
99
+ kind: any_file
100
+ patterns:
101
+ - '.codecov.yml'
102
+ - 'codecov.yml'
103
+ - 'codecov.yaml'
104
+ - '.coveragerc'
105
+ - '.nycrc'
106
+ - '.nycrc.json'
107
+ - '.c8rc'
108
+ - '.c8rc.json'
109
+ - 'coverage/**'
110
+ - '**/lcov.info'
111
+ why: 'Unmeasured coverage drifts down silently; a coverage config or report artifact proves measurement was set up at least once.'
112
+ remediation: 'Turn on coverage reporting in the test runner and publish the number on every PR.'
113
+ references: ['NIST-SSDF-RV.1.1']
114
+
115
+ - id: TAS-006
116
+ title: A coverage threshold is pinned in the package.json-embedded jest config
117
+ section: S7
118
+ section_title: Testing & Quality Assurance
119
+ severity: LOW
120
+ class: correctness
121
+ check:
122
+ kind: json_path
123
+ file: 'package.json'
124
+ path: 'jest.coverageThreshold'
125
+ why: 'A gate stops the slide — but this check reads only the package.json-embedded jest config, the one JSON location with a stable schema. Thresholds kept in vitest.config, jest.config.js, or .nycrc are invisible to it.'
126
+ remediation: 'Set jest.coverageThreshold in package.json, or keep the threshold wherever the runner reads it and accept this marker as not-applicable.'
127
+ references: ['NIST-SSDF-RV.1.1']
128
+
129
+ - id: TAS-007
130
+ title: Mutation-testing evidence is present
131
+ section: S7
132
+ section_title: Testing & Quality Assurance
133
+ severity: FUTURE
134
+ class: correctness
135
+ check:
136
+ kind: any_file
137
+ patterns:
138
+ - 'reports/**/*mut*'
139
+ - 'reports/mutation/**'
140
+ - 'stryker.conf.*'
141
+ - '.stryker.conf.*'
142
+ - '.mutmut*'
143
+ - 'mutants/**'
144
+ why: 'Coverage tells you which lines ran, not whether the test would have failed if the line were wrong; a mutation config or report proves the question was asked.'
145
+ remediation: 'Run mutation testing on the highest-risk module first and keep the config or report in the repo.'
146
+ references: ['Mutation-Testing']
147
+
148
+ - id: TAS-008
149
+ title: A determinism guard is set in test config or CI
150
+ section: S7
151
+ section_title: Testing & Quality Assurance
152
+ severity: LOW
153
+ class: correctness
154
+ check:
155
+ kind: grep_present
156
+ pattern: '(forbidOnly|forbid-only|forbid_only|failOnConsole|fail-on-console)'
157
+ include:
158
+ [
159
+ 'playwright.config.*',
160
+ 'cypress.config.*',
161
+ 'vitest.config.*',
162
+ 'vitest.workspace.*',
163
+ 'jest.config.*',
164
+ 'package.json',
165
+ '.github/workflows/*.yml',
166
+ '.github/workflows/*.yaml',
167
+ '.gitlab-ci.yml',
168
+ ]
169
+ why: 'Focused-test markers (.only) committed by accident silently skip the rest of the suite; a forbid-only guard string proves the leak was thought about.'
170
+ remediation: 'Set forbidOnly on CI (e.g. Playwright forbidOnly) so a stray .only fails the build instead of shrinking it.'
171
+ references: ['Google-Testing-Blog:Flaky']
172
+
173
+ - id: TAS-009
174
+ title: A test retry budget is declared
175
+ section: S7
176
+ section_title: Testing & Quality Assurance
177
+ severity: LOW
178
+ class: operations
179
+ check:
180
+ kind: grep_present
181
+ pattern: '(retries\s*:\s*[1-9]|"retries"\s*:\s*[1-9]|retries=[1-9]|--retries[ =][1-9]|rerun-failed|flaky-test-retry|retry-on-failure)'
182
+ include:
183
+ [
184
+ 'playwright.config.*',
185
+ 'cypress.config.*',
186
+ 'vitest.config.*',
187
+ 'jest.config.*',
188
+ 'package.json',
189
+ '.github/workflows/*.yml',
190
+ '.github/workflows/*.yaml',
191
+ '.gitlab-ci.yml',
192
+ ]
193
+ why: 'A retries setting proves the project pays for reruns; it proves nothing about whether the tests are flaky or stable — only that the budget exists.'
194
+ remediation: 'Declare an explicit retry budget (e.g. retries: 2 on CI) and track which tests consume it; quarantine chronic consumers.'
195
+ references: ['Google-Testing-Blog:Flaky']
196
+
197
+ - id: TAS-010
198
+ title: Tests assert failure paths
199
+ section: S7
200
+ section_title: Testing & Quality Assurance
201
+ severity: MEDIUM
202
+ class: correctness
203
+ check:
204
+ kind: grep_present
205
+ pattern: '(\.toThrow\(|\.rejects|pytest\.raises|assertRaises|assert\.rejects|ShouldThrow|assert\.throws)'
206
+ include:
207
+ [
208
+ '**/*.test.*',
209
+ '**/*.spec.*',
210
+ '**/test_*.py',
211
+ '**/*_test.*',
212
+ 'tests/**',
213
+ 'test/**',
214
+ '__tests__/**',
215
+ 'spec/**',
216
+ ]
217
+ why: 'A suite that only asserts happy paths never proves the error handling works; failure-assertion strings prove at least one test looks at the sad path.'
218
+ remediation: 'Add negative tests for every permission boundary and every error branch — 401/403 paths, validation rejections, and cross-tenant attempts.'
219
+ references: ['Testing-Patterns']
220
+
221
+ - id: TAS-011
222
+ title: Test-data and environment isolation markers exist
223
+ section: S7
224
+ section_title: Testing & Quality Assurance
225
+ severity: LOW
226
+ class: maintainability
227
+ check:
228
+ kind: any_file
229
+ patterns:
230
+ - 'tests/fixtures/**'
231
+ - 'test/fixtures/**'
232
+ - '**/__fixtures__/**'
233
+ - '**/factories/**'
234
+ - '**/__factories__/**'
235
+ - '.env.test'
236
+ - '.env.testing'
237
+ - 'tests/.env.test'
238
+ why: 'Hand-built object literals in 200 tests make every schema change a 200-file migration, and tests sharing the live environment leak state; fixtures, factories, and a dedicated test env file are the markers of isolation.'
239
+ remediation: 'Add a factory or fixtures directory and a .env.test so tests generate data and never touch the dev or prod environment.'
240
+ references: ['Testing-Patterns', '12-Factor:Config']
package/rules/index.yaml CHANGED
@@ -19,6 +19,7 @@ packs:
19
19
  - core/architecture.yaml
20
20
  - core/code-quality.yaml
21
21
  - core/testing.yaml
22
+ - core/testing-assurance.yaml
22
23
  - core/cicd.yaml
23
24
  - core/release.yaml
24
25
  - core/dependencies.yaml