terp-cli 0.43.0__tar.gz → 0.45.0__tar.gz

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 (104) hide show
  1. {terp_cli-0.43.0 → terp_cli-0.45.0}/PKG-INFO +9 -9
  2. {terp_cli-0.43.0 → terp_cli-0.45.0}/pyproject.toml +9 -9
  3. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/__init__.py +10 -75
  4. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/audit_findings.py +15 -1
  5. terp_cli-0.45.0/src/terp/cli/dependency_risk.py +348 -0
  6. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/dependency_scan.py +6 -1
  7. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/deployment_adopt.py +2 -1
  8. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/envschema.py +3 -0
  9. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/guide_deployment.py +7 -3
  10. terp_cli-0.45.0/src/terp/cli/guide_security.py +77 -0
  11. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_plan.py +86 -5
  12. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_render.py +2 -0
  13. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/manifest.py +44 -1
  14. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/promote.py +2 -1
  15. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/sign.py +27 -2
  16. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/risk_authority.py +4 -1
  17. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/verify.py +12 -12
  18. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/version.py +1 -1
  19. terp_cli-0.43.0/src/terp/cli/dependency_risk.py +0 -167
  20. {terp_cli-0.43.0 → terp_cli-0.45.0}/.gitignore +0 -0
  21. {terp_cli-0.43.0 → terp_cli-0.45.0}/signer/Dockerfile +0 -0
  22. {terp_cli-0.43.0 → terp_cli-0.45.0}/signer/terp-arch-releases.json +0 -0
  23. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/_appref.py +0 -0
  24. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/_cors_view.py +0 -0
  25. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/_engine.py +0 -0
  26. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/_output.py +0 -0
  27. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/_subjects.py +0 -0
  28. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/access.py +0 -0
  29. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/api_contract.py +0 -0
  30. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/api_contract_bounds.py +0 -0
  31. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/api_contract_check.py +0 -0
  32. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/api_contract_schemas.py +0 -0
  33. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/api_contract_shapes.py +0 -0
  34. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/apidocs.py +0 -0
  35. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/authz_surface.py +0 -0
  36. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/capabilities.py +0 -0
  37. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/dependency_audit.py +0 -0
  38. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/deploy_safety.py +0 -0
  39. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/deployment_app.py +0 -0
  40. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/deployment_check.py +0 -0
  41. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/deployment_declare.py +0 -0
  42. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/deployment_render.py +0 -0
  43. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/dev.py +0 -0
  44. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/docker.py +0 -0
  45. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/docker_masks.py +0 -0
  46. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/envfile.py +0 -0
  47. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/envrequired.py +0 -0
  48. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/envseams.py +0 -0
  49. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/fmt.py +0 -0
  50. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/grants.py +0 -0
  51. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/guide_capability.py +0 -0
  52. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/guide_files.py +0 -0
  53. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/guide_maintenance.py +0 -0
  54. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/guide_migrations.py +0 -0
  55. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/guide_passwords.py +0 -0
  56. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/heartbeat.py +0 -0
  57. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/jobs.py +0 -0
  58. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/leases.py +0 -0
  59. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/locks.py +0 -0
  60. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/maintenance/__init__.py +0 -0
  61. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/maintenance/_images.py +0 -0
  62. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/maintenance/_packages.py +0 -0
  63. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/maintenance/_platform.py +0 -0
  64. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/maintenance/_report.py +0 -0
  65. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/maintenance/_vulnerabilities.py +0 -0
  66. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/module_roles.py +0 -0
  67. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/npm_tree.py +0 -0
  68. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/openapi.py +0 -0
  69. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/outbox.py +0 -0
  70. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/ports.py +0 -0
  71. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/profiles.py +0 -0
  72. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/py.typed +0 -0
  73. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/python_audit.py +0 -0
  74. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/__init__.py +0 -0
  75. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_archives.py +0 -0
  76. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_common.py +0 -0
  77. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_compare.py +0 -0
  78. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_dockerfile.py +0 -0
  79. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_git.py +0 -0
  80. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_history.py +0 -0
  81. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_image.py +0 -0
  82. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_locks.py +0 -0
  83. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_migrations.py +0 -0
  84. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_npm_lock.py +0 -0
  85. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_osv.py +0 -0
  86. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_registry.py +0 -0
  87. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/_sandbox.py +0 -0
  88. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/build.py +0 -0
  89. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/cli.py +0 -0
  90. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/dsse.py +0 -0
  91. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/release/gate.py +0 -0
  92. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/reseal.py +0 -0
  93. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/reseal_report.py +0 -0
  94. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/routes.py +0 -0
  95. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/scaffold.py +0 -0
  96. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/scaffold_frontend.py +0 -0
  97. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/schema.py +0 -0
  98. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/seed.py +0 -0
  99. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/service_accounts.py +0 -0
  100. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/smoke.py +0 -0
  101. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/upgrade_recipes.py +0 -0
  102. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/users.py +0 -0
  103. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/workbench.py +0 -0
  104. {terp_cli-0.43.0 → terp_cli-0.45.0}/src/terp/cli/workbench_adopt.py +0 -0
@@ -1,23 +1,23 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: terp-cli
3
- Version: 0.43.0
3
+ Version: 0.45.0
4
4
  Summary: Terp command-line tool — inspect, scaffolding, migrations, checks, api-docs.
5
5
  Project-URL: Repository, https://github.com/AITT-NL/terp-framework
6
6
  Project-URL: Changelog, https://github.com/AITT-NL/terp-framework/blob/main/CHANGELOG.md
7
7
  License-Expression: Apache-2.0
8
8
  Requires-Python: >=3.13
9
9
  Requires-Dist: pyyaml>=6.0
10
- Requires-Dist: terp-arch==0.43.0
11
- Requires-Dist: terp-core==0.43.0
12
- Requires-Dist: terp-migrations==0.43.0
10
+ Requires-Dist: terp-arch==0.45.0
11
+ Requires-Dist: terp-core==0.45.0
12
+ Requires-Dist: terp-migrations==0.45.0
13
13
  Provides-Extra: jobs
14
- Requires-Dist: terp-cap-outbox==0.43.0; extra == 'jobs'
15
- Requires-Dist: terp-cap-scheduler-apscheduler==0.43.0; extra == 'jobs'
14
+ Requires-Dist: terp-cap-outbox==0.45.0; extra == 'jobs'
15
+ Requires-Dist: terp-cap-scheduler-apscheduler==0.45.0; extra == 'jobs'
16
16
  Provides-Extra: release
17
17
  Requires-Dist: cryptography>=46; extra == 'release'
18
18
  Requires-Dist: packaging>=24; extra == 'release'
19
- Requires-Dist: terp-cap-egress==0.43.0; extra == 'release'
19
+ Requires-Dist: terp-cap-egress==0.45.0; extra == 'release'
20
20
  Provides-Extra: scheduler
21
- Requires-Dist: terp-cap-scheduler-apscheduler==0.43.0; extra == 'scheduler'
21
+ Requires-Dist: terp-cap-scheduler-apscheduler==0.45.0; extra == 'scheduler'
22
22
  Provides-Extra: worker
23
- Requires-Dist: terp-cap-outbox==0.43.0; extra == 'worker'
23
+ Requires-Dist: terp-cap-outbox==0.45.0; extra == 'worker'
@@ -4,18 +4,18 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "terp-cli"
7
- version = "0.43.0"
7
+ version = "0.45.0"
8
8
  description = "Terp command-line tool — inspect, scaffolding, migrations, checks, api-docs."
9
9
  requires-python = ">=3.13"
10
10
  license = "Apache-2.0"
11
11
  dependencies = [
12
- "terp-core==0.43.0",
12
+ "terp-core==0.45.0",
13
13
  # `terp migrate` delegates to terp-migrations (lazily imported), keeping Alembic
14
14
  # off the path for `terp inspect` / `terp guide` while making migrations work.
15
- "terp-migrations==0.43.0",
15
+ "terp-migrations==0.45.0",
16
16
  # `terp guide rules` projects the live rule registry; terp-arch is imported lazily
17
17
  # (only when that topic is rendered), so it stays off the common `terp guide` path.
18
- "terp-arch==0.43.0",
18
+ "terp-arch==0.45.0",
19
19
  # `terp verify --only env-seams` and `terp smoke` read the compose profiles as data
20
20
  # (anchors and `<<:` merge keys resolved), so both answer without a Docker daemon or
21
21
  # even the `docker` binary. Declared explicitly rather than leant on: every app
@@ -29,11 +29,11 @@ dependencies = [
29
29
  # or a scheduler engine into apps that only use inspect/check/migrate. Deployments can select
30
30
  # one process role, while `jobs` is the convenient complete jobs-process bundle.
31
31
  [project.optional-dependencies]
32
- worker = ["terp-cap-outbox==0.43.0"]
33
- scheduler = ["terp-cap-scheduler-apscheduler==0.43.0"]
32
+ worker = ["terp-cap-outbox==0.45.0"]
33
+ scheduler = ["terp-cap-scheduler-apscheduler==0.45.0"]
34
34
  jobs = [
35
- "terp-cap-outbox==0.43.0",
36
- "terp-cap-scheduler-apscheduler==0.43.0",
35
+ "terp-cap-outbox==0.45.0",
36
+ "terp-cap-scheduler-apscheduler==0.45.0",
37
37
  ]
38
38
  # `terp release` and `terp promote` (ADR 0187): the DSSE signature (cryptography), the lock's
39
39
  # markers (packaging), and the one declared way to a registry, an index and the vulnerability
@@ -42,7 +42,7 @@ jobs = [
42
42
  release = [
43
43
  "cryptography>=46",
44
44
  "packaging>=24",
45
- "terp-cap-egress==0.43.0",
45
+ "terp-cap-egress==0.45.0",
46
46
  ]
47
47
 
48
48
  [project.scripts]
@@ -65,6 +65,7 @@ from terp.cli import (
65
65
  guide_maintenance,
66
66
  guide_migrations,
67
67
  guide_passwords,
68
+ guide_security,
68
69
  )
69
70
  from terp.cli.grants import (
70
71
  grant_add_command,
@@ -1174,72 +1175,7 @@ Multi-tenant rows (tenancy capability)
1174
1175
  Sign the tenant into the token at login with
1175
1176
  build_login_module(authenticate, tenant_resolver=...).
1176
1177
  """,
1177
- "security": """\
1178
- The security declaration (SecurityConfig, refused at production boot)
1179
-
1180
- - ONE declaration, wired on the control plane, read by create_app:
1181
- from terp.core import ControlPlane, CorsPolicy, RateLimit, SecurityConfig
1182
- control_plane = ControlPlane(security=SecurityConfig(
1183
- cors=CorsPolicy.allow(["https://app.example.com"]),
1184
- trusted_proxy_hops=1,
1185
- ))
1186
- - FOUR of its states refuse a production boot (SecurityConfig.production_problems();
1187
- create_app raises BootError "insecure production security config"). Each has exactly
1188
- one declaration that answers it:
1189
- 1. CORS unset -> CorsPolicy.from_environment(), .allow([...]) or .disabled(reason=...)
1190
- 2. CORS allowing '*' -> name the origins; a wildcard with credentials is no origin check
1191
- 3. rate_limit disabled -> RateLimit(requests=..., window_seconds=...)
1192
- 4. an override disabled -> an override may LOWER or RAISE a limit, never remove it
1193
- Declining is a full answer and must be said out loud: CorsPolicy.disabled(reason=...)
1194
- is the same-origin deployment's answer, and the reason is the point of it.
1195
- Which browser origins may call the API is a fact of an environment, not of the source:
1196
- CorsPolicy.from_environment() takes the allowlist from BACKEND_CORS_ORIGINS when the app
1197
- is composed (ADR 0210). An environment that names none serves no cross-origin access; an
1198
- entry that is not an origin (a path, a trailing slash, '*') refuses the boot. Without
1199
- that declaration the variable opens nothing, and a boot that finds it set says so.
1200
- `terp verify --only production-readiness` asks these before you ship, so the refusal
1201
- arrives in the gate rather than at the deploy.
1202
- - rate_limit_overrides is a PER-PREFIX BUCKET, not a shared counter (ADR 0115):
1203
- SecurityConfig(rate_limit_overrides={"/api/v1/auth": RateLimit.for_credentials()})
1204
- Longest prefix wins; everything unmatched keeps rate_limit. Separate buckets on
1205
- purpose - a credential endpoint and an asset read share a process, not a counter, so
1206
- exhausting one family must not 429 the other. The shape mirrors the per-mount
1207
- max_request_bytes map: one way to scope a limit to a path, not two.
1208
- - trusted_proxy_hops: NAME THE PROXY YOU ACTUALLY RUN BEHIND. It defaults to 0, meaning
1209
- the direct TCP peer identifies the caller and X-Forwarded-For is ignored as
1210
- attacker-supplied. Behind one reverse proxy (the shipped nginx profile) set 1, or every
1211
- caller collapses onto the proxy's address and your per-caller controls - the rate limit,
1212
- the OIDC callback throttle - stop being per-caller. The symptom is intermittent 429s
1213
- that look like a traffic spike. Nothing refuses this at boot, because 0 is correct for a
1214
- directly-exposed app: it is a deployment fact only you know.
1215
- - expose_api_docs is a deliberate opt-in, OFF in production: /docs, /redoc and
1216
- /openapi.json are hidden there because a production API's full schema is not public
1217
- information. Development always serves them, and `terp openapi` exports the document
1218
- either way - so turning this on is a choice to publish, not a way to get the file.
1219
- Commit that file instead: `openapi.json` is the app's API contract, the one a mobile
1220
- app or a site in another repository pins, and `terp verify --only api-contract` holds
1221
- it to the API the app serves, naming every change to its shape, the ones that break a
1222
- client first (ADR 0194). Who may call a route is not in it: authz-surface pins that.
1223
- - headers ships a safe SecurityHeaders set; max_request_bytes (1 MiB) is the body cap and
1224
- is per-mount overridable (ADR 0067); request_id_header names the correlation header
1225
- ("X-Request-ID") echoed on every response.
1226
- - A NATIVE MOBILE CLIENT stays signed in through its own routes, opt-in with a reason
1227
- (ADR 0195): build_login_module(..., native_clients=NativeClients(reason="...")) mounts
1228
- POST /api/v1/auth/native/login, /native/refresh and /native/logout. The first two answer
1229
- the refresh token in the JSON body and run the same rotation, reuse detection and
1230
- revocation as the cookie, its rotation grace window included; /native/logout takes the
1231
- token and revokes its whole family without minting a successor. The client keeps that
1232
- token in the OS keychain or keystore and nowhere else, and treats a 401 from
1233
- /native/refresh as signed out. All three refuse any request with browser provenance
1234
- (Origin, any Sec-Fetch-* header, the refresh cookie) with 403 native_client_only before
1235
- the body is validated, so a browser stays on /login, /refresh and /logout. A HYBRID app
1236
- (a page inside a native shell) calls them from its native layer and hands its page only
1237
- access tokens: a page that holds the refresh token has given up what the cookie
1238
- protects. No route that mints a credential (/login, /token, /refresh, /native/login,
1239
- /native/refresh) accepts an Idempotency-Key; retry without one.
1240
- - No terp.arch check applies - there is no module code shape to police. Enforcement is
1241
- the create_app production fail-fast plus the production-readiness verify lane.
1242
- """,
1178
+ "security": guide_security.TOPIC,
1243
1179
  "logging": """\
1244
1180
  Logging (one JSON record per line, the terp-log/1 schema, ADR 0188)
1245
1181
 
@@ -1950,14 +1886,14 @@ Frontend module screens (@terpjs/react-core)
1950
1886
  raw <form> -> Stack as="form" (terp guide forms)
1951
1887
  raw fetch / XMLHttpRequest -> useTerpClient() + unwrap (typed client)
1952
1888
  WebSocket / EventSource / sendBeacon -> the generated client (one egress path)
1953
- style={} / className / any stylesheet -> layout via Stack/DetailList; design tokens
1889
+ inline style / global classes -> primitives or a sibling CSS Module
1954
1890
  <a href="/..."> -> the router's Link (role-aware, no reload)
1955
1891
  deep imports (@terpjs/*/src, @terpjs/*/dist) -> import from the package root only
1956
1892
  data-terp / data-terp-* anywhere in src -> compose the component that renders it
1957
1893
  The data-terp markers are react-core's own: its stylesheet and the runtime layout check
1958
1894
  trust them. A framework screen you replace (renderTerpApp({ login })) is yours, so its
1959
1895
  tests find it by role and accessible name, not by the framework screen's markers.
1960
- The bootstrap (src/main.tsx) is the one file that imports stylesheets, and only the token
1896
+ The bootstrap (src/main.tsx) is the one file that imports global stylesheets, and only the token
1961
1897
  pipeline's three: @terpjs/contract/tokens.css, ./house-style.css and ./theme.css. A
1962
1898
  library's stylesheet is refused there too: it would paint outside the palettes. A
1963
1899
  stylesheet loaded through import() or import.meta.glob is refused the same way.
@@ -2045,7 +1981,7 @@ Forms (react-core primitives)
2045
1981
  <Button type="submit" variant="primary">Save</Button>
2046
1982
  </Stack>
2047
1983
  - Field wraps label + control + hint/error for one field; Stack (vertical by default)
2048
- is the layout — never style={} / className / a stylesheet.
1984
+ lays out fields. A custom layout can use a sibling CSS Module.
2049
1985
  - Submit through the typed client: const client = useTerpClient();
2050
1986
  await unwrap(client.POST("/api/v1/invoices/", { body })); a failure throws ApiError
2051
1987
  ({code, status, requestId, fields}) — map codes to copy with useErrorMessage, show
@@ -2108,10 +2044,9 @@ Forms (react-core primitives)
2108
2044
  "theming": """\
2109
2045
  Theming and branding (design tokens, palettes, the brand mark)
2110
2046
 
2111
- - EVERY style is a design token. The react-core primitives paint from CSS custom
2112
- properties shipped by @terpjs/contract (tokens.css), which is why the boundary lint
2113
- refuses `style={}`, `className` and stylesheets in every src/ file: code that painted
2114
- itself would not follow the palette. Modules never need theme-specific code.
2047
+ - Use the shared tokens for palette, typography and spacing. For a custom screen, use a
2048
+ plain Page and import styles from "./Board.module.css". Apply className={styles.board}
2049
+ and define .board in that file. Global stylesheets belong to the bootstrap token pipeline.
2115
2050
  - THE SHIPPED PALETTES, plus "system":
2116
2051
  midday twilight evening night contrast
2117
2052
  Named for the time of day they suit: midday is the light set, twilight a dimmed dark,
@@ -2506,8 +2441,8 @@ committed, .app.env is not.
2506
2441
 
2507
2442
  Never write a secret value into the manifest, .env.example, .app.env.example, source,
2508
2443
  tests, prompts or logs. Platform-owned names (SECRET_KEY, POSTGRES_PASSWORD, TERP_RUNTIME_DB_PASSWORD, TERP_MIGRATION_DATABASE_URL, DATABASE_URL,
2509
- ENVIRONMENT, WEB_PORT, BACKEND_CORS_ORIGINS) are refused in the manifest: they already
2510
- have an owner.
2444
+ ENVIRONMENT, WEB_PORT, BACKEND_CORS_ORIGINS, TERP_RELEASE_TAG, TERP_EDGE_HOPS) are refused
2445
+ in the manifest: they already have an owner.
2511
2446
 
2512
2447
  SCOPING A VARIABLE TO ONE SERVICE (not available yet)
2513
2448
 
@@ -11,6 +11,11 @@ import json
11
11
  import re
12
12
  from typing import Any
13
13
 
14
+ #: The longest string and the longest list terp-spec's ``dependency-audit`` contract holds. A
15
+ #: finding past either is never written, so every document a scan writes is the contract's.
16
+ MAX_TEXT = 4096
17
+ MAX_ITEMS = 10_000
18
+
14
19
 
15
20
  class AuditUnreadable(ValueError):
16
21
  """The scanner or lock did not provide complete evidence."""
@@ -44,8 +49,17 @@ def finding(*, advisory: str, aliases: list[str], ecosystem: str, package: str,
44
49
  }
45
50
  if not all(isinstance(v, str) and v for v in (advisory, package, version, lockfile)):
46
51
  raise AuditUnreadable("a dependency finding has no identity")
52
+ fixed_versions = sorted(set(fixed))
53
+ lists = (identity["advisories"], identity["dependency_paths"], fixed_versions)
54
+ if any(len(values) > MAX_ITEMS for values in lists) or any(
55
+ len(text) > MAX_TEXT for text in (package, version, lockfile, *(text for values in lists for text in values))
56
+ ):
57
+ raise AuditUnreadable(
58
+ f"a dependency finding is longer than the dependency-audit contract holds: {MAX_TEXT} "
59
+ f"characters to a string and {MAX_ITEMS} entries to a list"
60
+ )
47
61
  return {**identity, "fingerprint": digest(identity), "severity": severity,
48
- "fixed_versions": sorted(set(fixed)), "dependency_scope": scope}
62
+ "fixed_versions": fixed_versions, "dependency_scope": scope}
49
63
 
50
64
 
51
65
  def npm_findings(report: object, lock: object, lockfile: str) -> list[dict]:
@@ -0,0 +1,348 @@
1
+ """Release permission over complete audits and authenticated, current acceptances.
2
+
3
+ This evaluator does not authenticate records. Its caller must verify the issuer and
4
+ obtain current revocation state outside the agent's execution boundary. Raw checks
5
+ and assurance are never modified. No other failed check can be accepted here.
6
+
7
+ A check's evidence and every acceptance an authority returns are documents of the Terp
8
+ Standard, terp-spec's ``dependency-audit`` and ``dependency-risk-acceptance``, and both
9
+ are read closed, as their schemas are: a field neither defines, a string the contract
10
+ counts as blank or holds longer than it allows, and a digest, commit or time with
11
+ anything around it are refused, never read past. A superseded acceptance is held to the
12
+ contract too; only its lifetime, its revocation and the release it names are left to
13
+ the decision that replaces it. The patterns and limits below are the schemas' own, and
14
+ ``tests/architecture/test_dependency_risk.py`` holds this reader to the pinned release:
15
+ it runs the release's fixtures, and breaks the schemas' rules one at a time at every
16
+ field, requiring a refusal for each document the pinned schema refuses.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import json
22
+ import re
23
+ from datetime import UTC, datetime, timedelta
24
+
25
+ from terp.cli.audit_findings import MAX_ITEMS, MAX_TEXT, blocking, digest
26
+
27
+ AUDITS = {"dependency-audit-npm": "npm", "dependency-audit-python": "pypi"}
28
+ MAX_LIFETIME = timedelta(days=30)
29
+ MAX_SCAN_AGE = timedelta(hours=24)
30
+ IDENTITY = ("advisories", "ecosystem", "package", "version", "lockfile", "dependency_paths")
31
+
32
+ #: The longest ``revoked_at`` an acceptance may hold. The decision a release is read against
33
+ #: holds none (""); a superseded one may say when it was revoked.
34
+ MAX_REVOCATION = 40
35
+
36
+ #: The fields each contract defines: every one is required, and no other is allowed.
37
+ AUDIT_FIELDS = frozenset({"version", "complete", "scanned_at", "locks", "findings"})
38
+ FINDING_FIELDS = frozenset({*IDENTITY, "fingerprint", "severity", "fixed_versions", "dependency_scope"})
39
+ ACCEPTANCE_FIELDS = frozenset({
40
+ "version", "id", "project_id", "commit", "environments", "finding", "locks", "reason", "evidence",
41
+ "approved_by", "approved_at", "expires_at", "revoked_at",
42
+ })
43
+
44
+ #: The contracts' patterns as their schemas write them, applied as JSON Schema applies a
45
+ #: pattern: by a search. ``CONTENT`` finds one character the acceptance contract does not count
46
+ #: as blank, which each field saying who decided, for what, why and on what evidence must hold.
47
+ CONTENT = re.compile(r"[^\u0000-\u0020\u007F-\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]")
48
+ DIGEST = re.compile(r"^sha256:[0-9a-f]{64}(?![\s\S])")
49
+ COMMIT = re.compile(r"^([0-9a-f]{40}|[0-9a-f]{64})(?![\s\S])")
50
+ INSTANT = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,6})?(Z|\+00:00)$")
51
+
52
+ #: What ``INSTANT`` means read as JSON Schema reads it, which Python's matcher does not: ASCII
53
+ #: digits and nothing after the zone. The hour stops at 23 because Python 3.14 reads 24:00:00 as
54
+ #: the next midnight where 3.13 refuses it, and a verdict must not depend on the interpreter.
55
+ _UTC_TIME = re.compile(r"[0-9]{4}-[0-9]{2}-[0-9]{2}T(?:[01][0-9]|2[0-3]):[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,6})?(?:Z|\+00:00)")
56
+
57
+
58
+ class RiskRefused(ValueError):
59
+ """Incomplete evidence or invalid acceptance; permission stays closed."""
60
+
61
+
62
+ def time_value(value: object, what: str) -> datetime:
63
+ """A UTC time in any ISO 8601 form Python reads, as a risk authority's own answer may write one.
64
+
65
+ *what* names the time in a refusal: the field, and the record it is in.
66
+ """
67
+ if value is None:
68
+ raise RiskRefused(f"{what} is missing")
69
+ if not isinstance(value, str):
70
+ raise RiskRefused(f"{what} is not a string")
71
+ try:
72
+ result = datetime.fromisoformat(value.replace("Z", "+00:00"))
73
+ except ValueError as exc:
74
+ raise RiskRefused(f"{what} is not a date and time") from exc
75
+ if result.utcoffset() != timedelta(0):
76
+ raise RiskRefused(f"{what} must be UTC")
77
+ return result
78
+
79
+
80
+ def instant(value: object, what: str) -> datetime:
81
+ """A time as both contracts write one, ``2026-11-18T12:00:00Z``, or a refusal naming *what*."""
82
+ if not isinstance(value, str) or not INSTANT.search(value) or not _UTC_TIME.fullmatch(value):
83
+ raise RiskRefused(f"{what} must be UTC, written YYYY-MM-DDThh:mm:ss with at most six decimals, "
84
+ "then Z or +00:00")
85
+ return time_value(value, what)
86
+
87
+
88
+ def _names(fields: list[str]) -> str:
89
+ """Field names as a refusal shows them: escaped, the first five, each cut at 64 characters."""
90
+ shown = ", ".join(json.dumps(name[:64]) for name in fields[:5])
91
+ return shown + (f" and {len(fields) - 5} more" if len(fields) > 5 else "")
92
+
93
+
94
+ def _closed(document: dict, fields: frozenset[str], what: str, contract: str) -> None:
95
+ """Refused unless *document* holds exactly the *fields* its *contract* defines."""
96
+ extra, missing = sorted(str(name) for name in set(document) - fields), sorted(fields - set(document))
97
+ if extra or missing:
98
+ said = [f"holds {_names(extra)}, which the {contract} contract does not define"] if extra else []
99
+ said += [f"lacks {_names(missing)}, which the {contract} contract requires"] if missing else []
100
+ raise RiskRefused(f"{what} {' and '.join(said)}: whatever writes it must write the contract's fields")
101
+
102
+
103
+ def _text_problem(value: object, *, said: bool = False) -> str | None:
104
+ """What keeps *value* from being a string of the contracts, or None.
105
+
106
+ One of 1 to MAX_TEXT characters, and where *said*, one character outside the blank class.
107
+ """
108
+ if not isinstance(value, str):
109
+ return "is not a string"
110
+ if not value:
111
+ return "is empty"
112
+ if len(value) > MAX_TEXT:
113
+ return f"is longer than {MAX_TEXT} characters"
114
+ if said and CONTENT.search(value) is None:
115
+ return "holds only characters the contract counts as blank"
116
+ return None
117
+
118
+
119
+ def _list_problem(value: object, *, said: bool = False, ordered: bool = False, required: bool = True) -> str | None:
120
+ """What keeps *value* from being a list of the contracts, or None.
121
+
122
+ At most MAX_ITEMS distinct strings, each as :func:`_text_problem` reads one: sorted where
123
+ *ordered*, and not empty where *required*.
124
+ """
125
+ if not isinstance(value, list):
126
+ return "is not a list"
127
+ if required and not value:
128
+ return "is empty"
129
+ if len(value) > MAX_ITEMS:
130
+ return f"lists more than {MAX_ITEMS} entries"
131
+ for item in value:
132
+ problem = _text_problem(item, said=said)
133
+ if problem is not None:
134
+ return f"has an entry that {problem}"
135
+ if len(set(value)) != len(value):
136
+ return "lists an entry more than once"
137
+ if ordered and value != sorted(value):
138
+ return "is not sorted"
139
+ return None
140
+
141
+
142
+ def _lock_problem(value: object) -> str | None:
143
+ """What keeps *value* from mapping each lock's path to its whole sha256 digest, or None."""
144
+ if not isinstance(value, dict):
145
+ return "is not an object of lock paths and digests"
146
+ for path, recorded in value.items():
147
+ if not isinstance(path, str) or not path:
148
+ return "names a lock with an empty path"
149
+ if not isinstance(recorded, str) or DIGEST.search(recorded) is None:
150
+ return f"gives {_names([path])} no whole sha256 digest"
151
+ return None
152
+
153
+
154
+ def _one_of(value: object, *choices: str) -> bool:
155
+ """Whether *value* is one of the strings *choices*; a value of any other type is none of them."""
156
+ return isinstance(value, str) and value in choices
157
+
158
+
159
+ def fingerprint(item: object, where: str = "a finding", contract: str = "dependency-audit") -> str:
160
+ """The fingerprint of *item*, a finding of *contract*, or a refusal that names it as *where*."""
161
+ if not isinstance(item, dict):
162
+ raise RiskRefused(f"{where} is not an object")
163
+ _closed(item, FINDING_FIELDS, where, contract)
164
+ for key, problem in (
165
+ *((key, _list_problem(item[key], ordered=True)) for key in ("advisories", "dependency_paths")),
166
+ *((key, _text_problem(item[key])) for key in ("package", "version", "lockfile")),
167
+ ("fixed_versions", _list_problem(item["fixed_versions"], ordered=True, required=False)),
168
+ ):
169
+ if problem is not None:
170
+ raise RiskRefused(f"{where}: {key} {problem}")
171
+ if not _one_of(item["ecosystem"], "npm", "pypi"):
172
+ raise RiskRefused(f"{where}: ecosystem is not npm or pypi")
173
+ if not _one_of(item["severity"], "info", "low", "moderate", "high", "critical", "unknown"):
174
+ raise RiskRefused(f"{where}: severity is not info, low, moderate, high, critical or unknown")
175
+ if item["ecosystem"] == "npm" and item["severity"] == "unknown":
176
+ raise RiskRefused(f"{where}: severity is unknown, and npm classifies every advisory it reports")
177
+ if not _one_of(item["dependency_scope"], "runtime", "development", "unknown"):
178
+ raise RiskRefused(f"{where}: dependency_scope is not runtime, development or unknown")
179
+ result = digest({key: item[key] for key in IDENTITY})
180
+ if result != item["fingerprint"]:
181
+ raise RiskRefused(f"{where}: fingerprint is not the one its identity hashes to")
182
+ return result
183
+
184
+
185
+ def audit_evidence(audit: object, *, now: datetime,
186
+ name: str = "the dependency scan") -> tuple[dict[str, str], dict[str, dict]]:
187
+ """A complete, current ``dependency-audit`` document's locks, and its findings by fingerprint.
188
+
189
+ Refused unless the scan finished at most :data:`MAX_SCAN_AGE` before *now*, and each finding
190
+ is whole, belongs to one of the scan's locks and is listed once. *name* says which scan a
191
+ refusal is about.
192
+ """
193
+ if not isinstance(audit, dict) or type(audit.get("version")) is not int or audit["version"] != 1:
194
+ raise RiskRefused(f"{name} is not version 1 of the dependency-audit contract: audit again with the "
195
+ "toolchain the release pins")
196
+ if audit.get("complete") is not True:
197
+ raise RiskRefused(f"{name} is incomplete")
198
+ _closed(audit, AUDIT_FIELDS, name, "dependency-audit")
199
+ scanned = instant(audit["scanned_at"], f"{name}: scanned_at")
200
+ if not now - MAX_SCAN_AGE <= scanned <= now:
201
+ raise RiskRefused(f"{name} is stale or in the future: audit again")
202
+ locks, items = audit["locks"], audit["findings"]
203
+ problem = _lock_problem(locks)
204
+ if problem is not None:
205
+ raise RiskRefused(f"{name}: locks {problem}")
206
+ if not isinstance(items, list):
207
+ raise RiskRefused(f"{name}: findings is not a list")
208
+ if len(items) > MAX_ITEMS:
209
+ raise RiskRefused(f"{name} lists more than {MAX_ITEMS} findings, more than its contract holds")
210
+ findings: dict[str, dict] = {}
211
+ for index, item in enumerate(items):
212
+ where = f"finding {index} of {name}"
213
+ key = fingerprint(item, where)
214
+ if item["lockfile"] not in locks:
215
+ raise RiskRefused(f"{where}: lockfile {_names([item['lockfile']])} is not one of the scan's locks")
216
+ if key in findings:
217
+ raise RiskRefused(f"{where} repeats an earlier finding of the scan")
218
+ findings[key] = item
219
+ return locks, findings
220
+
221
+
222
+ def acceptance_form(record: object) -> tuple[dict, str, datetime]:
223
+ """*record*, the fingerprint of the finding it accepts and when it was approved, or a refusal.
224
+
225
+ Refused unless *record* is a ``dependency-risk-acceptance`` document: version 1, the fields
226
+ the contract defines, content in each field that says who decided, for what, why and on what
227
+ evidence, an exact commit, at least one lock with its whole digest, and both times in the
228
+ contract's form. Nothing here depends on the release the record is read for, so every record
229
+ an authority returns is held to it, a superseded one included.
230
+ """
231
+ if not isinstance(record, dict):
232
+ raise RiskRefused("an acceptance record is malformed: it is not an object")
233
+ if type(record.get("version")) is not int or record["version"] != 1:
234
+ raise RiskRefused(f"{_label(record)} is not version 1 of the dependency-risk-acceptance contract")
235
+ _closed(record, ACCEPTANCE_FIELDS, _label(record), "dependency-risk-acceptance")
236
+ problem = _text_problem(record["id"], said=True)
237
+ if problem is not None:
238
+ raise RiskRefused(f"an acceptance's id {problem}")
239
+ label = _label(record)
240
+ for key, problem in (
241
+ *((key, _text_problem(record[key], said=True)) for key in ("project_id", "reason", "approved_by")),
242
+ *((key, _list_problem(record[key], said=True)) for key in ("environments", "evidence")),
243
+ ):
244
+ if problem is not None:
245
+ raise RiskRefused(f"{label}: {key} {problem}")
246
+ if not isinstance(record["commit"], str) or not COMMIT.search(record["commit"]):
247
+ raise RiskRefused(f"{label}: commit is not a whole commit id, 40 or 64 lowercase hex characters")
248
+ problem = "names no lock" if record["locks"] == {} else _lock_problem(record["locks"])
249
+ if problem is not None:
250
+ raise RiskRefused(f"{label}: locks {problem}")
251
+ if not isinstance(record["revoked_at"], str) or len(record["revoked_at"]) > MAX_REVOCATION:
252
+ raise RiskRefused(f"{label}: revoked_at is not a string of at most {MAX_REVOCATION} characters")
253
+ approved = instant(record["approved_at"], f"{label}: approved_at")
254
+ instant(record["expires_at"], f"{label}: expires_at")
255
+ return record, fingerprint(record["finding"], f"the finding of {label}", "dependency-risk-acceptance"), approved
256
+
257
+
258
+ def _label(record: dict) -> str:
259
+ """An acceptance as a refusal names it: by its id, where it has one that says something."""
260
+ named = record.get("id")
261
+ return f"acceptance {_names([named])}" if _text_problem(named, said=True) is None else "an acceptance"
262
+
263
+
264
+ def valid_acceptance(record: object, *, project: str, commit: str, environment: str,
265
+ locks: dict, now: datetime) -> str:
266
+ """The fingerprint *record* accepts, if it is the contract's and covers this release *now*."""
267
+ document, key, start = acceptance_form(record)
268
+ label = _label(document)
269
+ if document["project_id"] != project or document["commit"] != commit:
270
+ raise RiskRefused(f"{label} belongs to another project or commit")
271
+ if environment not in document["environments"]:
272
+ raise RiskRefused(f"{label} does not cover this environment")
273
+ if document["locks"] != locks:
274
+ raise RiskRefused(f"{label} covers another dependency lock set")
275
+ if document["revoked_at"] != "":
276
+ raise RiskRefused(f"{label} was revoked")
277
+ end = instant(document["expires_at"], f"{label}: expires_at")
278
+ if not start <= now < end or end - start > MAX_LIFETIME:
279
+ raise RiskRefused(f"{label} is expired, not yet valid, or longer than 30 days")
280
+ return key
281
+
282
+
283
+ def evaluate(checks: list[dict], acceptances: list[dict], *, project: str,
284
+ commit: str, environment: str, now: datetime | None = None) -> dict:
285
+ """Compute permission; inputs are authenticated by the trusted caller, not this function."""
286
+ now = now or datetime.now(UTC)
287
+ if (not project or not environment or not isinstance(commit, str) or not COMMIT.search(commit)
288
+ or now.utcoffset() != timedelta(0)):
289
+ raise RiskRefused("release permission requires an exact project, commit, environment and UTC time")
290
+ if not isinstance(checks, list) or not checks:
291
+ raise RiskRefused("release permission requires every release check")
292
+ ids = [c.get("id") for c in checks if isinstance(c, dict)]
293
+ if len(ids) != len(checks) or any(not isinstance(i, str) or not i for i in ids) or len(ids) != len(set(ids)):
294
+ raise RiskRefused("release checks are malformed or duplicated")
295
+ if not AUDITS.keys() <= set(ids):
296
+ raise RiskRefused("release checks omit a dependency audit")
297
+ locks, findings, failures = {}, {}, []
298
+ for check in checks:
299
+ if type(check.get("ok")) is not bool or type(check.get("applicable")) is not bool:
300
+ raise RiskRefused("a release check has no verdict")
301
+ if check["id"] not in AUDITS:
302
+ if not check["ok"]:
303
+ failures.append(check["id"])
304
+ continue
305
+ name = f"the {check['id']} scan"
306
+ scan_locks, scanned = audit_evidence(check.get("dependency_audit"), now=now, name=name)
307
+ for path, value in scan_locks.items():
308
+ if path in locks and locks[path] != value:
309
+ raise RiskRefused(f"{name} gives {_names([path])} another digest than the other scan does")
310
+ locks[path] = value
311
+ if check["applicable"] != bool(scan_locks) or (not check["applicable"] and scanned):
312
+ raise RiskRefused(f"{name} contradicts its applicability")
313
+ blocked = []
314
+ for key, item in scanned.items():
315
+ # A fingerprint covers the ecosystem, and each audit holds only its own, so the
316
+ # two audits can never list one finding between them: no repeat to refuse here.
317
+ if item["ecosystem"] != AUDITS[check["id"]]:
318
+ raise RiskRefused(f"{name} lists a {item['ecosystem']} finding, and it audits {AUDITS[check['id']]} alone")
319
+ findings[key] = item
320
+ if blocking(item):
321
+ blocked.append(key)
322
+ if check["ok"] != (not blocked):
323
+ raise RiskRefused(f"{name} contradicts its verdict")
324
+ # Every record is the contract's, a superseded one too. Then select the current
325
+ # decision before validating its lifetime or revocation: an expired older record must
326
+ # not defeat a renewal, and withdrawing the renewal must never bring an older approval
327
+ # back into force.
328
+ latest: dict[str, tuple[dict, datetime]] = {}
329
+ for record in acceptances:
330
+ document, key, approved = acceptance_form(record)
331
+ if key in latest:
332
+ previous = latest[key][1]
333
+ if approved == previous:
334
+ raise RiskRefused(f"{_label(document)} and {_label(latest[key][0])} decide one finding at the same time")
335
+ if approved < previous:
336
+ continue
337
+ latest[key] = (document, approved)
338
+ covered = {}
339
+ for record, _approved in latest.values():
340
+ key = valid_acceptance(record, project=project, commit=commit, environment=environment, locks=locks, now=now)
341
+ if key not in findings or record["finding"] != findings[key]:
342
+ raise RiskRefused(f"{_label(record)} is stale or describes another finding")
343
+ covered[key] = record["id"]
344
+ unaccepted = sorted(key for key, item in findings.items() if blocking(item) and key not in covered)
345
+ used = sorted(covered[key] for key, item in findings.items() if blocking(item) and key in covered)
346
+ return {"version": 1, "allowed": not failures and not unaccepted,
347
+ "status": "blocked" if failures or unaccepted else "accepted" if used else "passed",
348
+ "failed_checks": failures, "unaccepted_findings": unaccepted, "acceptance_ids": used}
@@ -7,7 +7,7 @@ import json
7
7
  from datetime import UTC, datetime
8
8
  from pathlib import Path
9
9
 
10
- from terp.cli.audit_findings import AuditUnreadable, blocking, npm_findings, python_findings
10
+ from terp.cli.audit_findings import MAX_ITEMS, AuditUnreadable, blocking, npm_findings, python_findings
11
11
 
12
12
 
13
13
  def dependency_checks(check_type):
@@ -99,6 +99,11 @@ def scan_dependencies(root: Path, ecosystem: str) -> tuple[int, str, dict]:
99
99
  findings = python_findings(report, lock)
100
100
  if (code == 1) != any(blocking(item) for item in findings):
101
101
  raise AuditUnreadable("the scanner exit code contradicts its dependency findings")
102
+ if len(evidence["findings"]) + len(findings) > MAX_ITEMS:
103
+ raise AuditUnreadable(
104
+ f"the audits found more than {MAX_ITEMS} findings, more than the dependency-audit "
105
+ "contract holds: update the dependencies that carry the most of them, and audit again"
106
+ )
102
107
  evidence["locks"][lock] = "sha256:" + hashlib.sha256(before).hexdigest()
103
108
  evidence["findings"].extend(findings)
104
109
  except (OSError, ValueError) as exc:
@@ -48,7 +48,7 @@ from terp.arch.deployment import (
48
48
  read,
49
49
  readable,
50
50
  )
51
- from terp.arch.deployment.generator import FRONTEND_LOCK, SITE_LOCK
51
+ from terp.arch.deployment.generator import FRONTEND_LOCK, SITE_LOCK, SUITE_LOCK
52
52
  from terp.arch.deployment.profile import truth_findings
53
53
  from terp.arch.deployment.render_check import (
54
54
  ANSWER,
@@ -214,6 +214,7 @@ def plan_generated(root: pathlib.Path) -> Plan:
214
214
  tables=published_tables(),
215
215
  frontend_lock=(root / FRONTEND_LOCK).is_file(),
216
216
  site_lock=(root / SITE_LOCK).is_file(),
217
+ conformance_lock=(root / SUITE_LOCK).is_file(),
217
218
  )
218
219
  if refused:
219
220
  raise AdoptionRefused(
@@ -45,6 +45,8 @@ RESOLVED_BY_VALUES = frozenset({"host", "container", "browser"})
45
45
  #: is the per-release tag the production profile's image names read (ADR 0185), spelled once
46
46
  #: in ``terp.arch.deployment.generator.RELEASE_TAG_VARIABLE`` and held equal to this entry by
47
47
  #: ``tests/architecture/test_prod_profile.py``: this module stays off terp-arch's import path.
48
+ #: ``TERP_EDGE_HOPS`` is the hop a deploy tool's edge puts in front of the app, which
49
+ #: ``create_app`` adds to the declared count (ADR 0220): the tool that runs the edge sets it.
48
50
  PLATFORM_OWNED_NAMES = frozenset(
49
51
  {
50
52
  "SECRET_KEY",
@@ -56,6 +58,7 @@ PLATFORM_OWNED_NAMES = frozenset(
56
58
  "WEB_PORT",
57
59
  "BACKEND_CORS_ORIGINS",
58
60
  "TERP_RELEASE_TAG",
61
+ "TERP_EDGE_HOPS",
59
62
  }
60
63
  )
61
64