codeimprint 0.5.0a32__tar.gz → 0.5.0a33__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 (26) hide show
  1. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/CHANGELOG.md +14 -0
  2. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/PKG-INFO +1 -1
  3. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/pyproject.toml +1 -1
  4. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/__init__.py +1 -1
  5. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/cli.py +27 -0
  6. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/.gitignore +0 -0
  7. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/LICENSE +0 -0
  8. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/NOTICE +0 -0
  9. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/README.pypi.md +0 -0
  10. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint/__init__.py +0 -0
  11. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint/__main__.py +0 -0
  12. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/__main__.py +0 -0
  13. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/api.py +0 -0
  14. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/chainseal.py +0 -0
  15. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/config.py +0 -0
  16. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/gitrepo.py +0 -0
  17. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/imprint_file.py +0 -0
  18. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/linecount.py +0 -0
  19. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/ownership.py +0 -0
  20. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/project.py +0 -0
  21. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/receipt.py +0 -0
  22. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/records.py +0 -0
  23. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/timestamp.py +0 -0
  24. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/transparency.py +0 -0
  25. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/trust.py +0 -0
  26. {codeimprint-0.5.0a32 → codeimprint-0.5.0a33}/src/codeimprint_cli/tsa_roots.py +0 -0
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0a33 — Plan refusals are never silent [CIM-BE-53-v1]
4
+
5
+ For engine 0.7.0a40, which can enforce the Hello plan's limits (`CODEIMPRINT_BILLING_ENFORCE`).
6
+ Includes 0.5.0a32 (not tagged on its own).
7
+
8
+ - **New: a seal the plan refuses says so.** The server's `plan_limit_reached` (a new active
9
+ project too many) and `plan_automatic_sealing` (a CI token's seal on the free Hello plan)
10
+ are printed as "not sealed: <the server's message, with the upgrade link> [<code>]".
11
+ - In GitHub Actions: a warning annotation titled "CodeImprint plan", exit code 0 (an
12
+ automated build never fails on it).
13
+ - In a terminal: the same warning, exit code 2.
14
+ - `imprint token create` names the code too.
15
+ - Tests: `tests/test_plan_refusals.py`.
16
+
3
17
  ## 0.5.0a32 — Signed organisation requests [CIM-BE-48-v1]
4
18
 
5
19
  For engine 0.7.0a38, which needs them (audit 42f-01, 42f-03).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: codeimprint
3
- Version: 0.5.0a32
3
+ Version: 0.5.0a33
4
4
  Summary: CodeImprint: seal your code with a CodeImprint server (tamper-evident, logged and timestamped) and verify seals offline.
5
5
  Project-URL: Homepage, https://codeimprint.ai
6
6
  Project-URL: Hub, https://app.codeimprint.ai
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
  # Published on PyPI as `codeimprint`. The import package stays `codeimprint_cli` and the
7
7
  # command `imprint`.
8
8
  name = "codeimprint"
9
- version = "0.5.0a32"
9
+ version = "0.5.0a33"
10
10
  description = "CodeImprint: seal your code with a CodeImprint server (tamper-evident, logged and timestamped) and verify seals offline."
11
11
  readme = "README.pypi.md"
12
12
  license = "Apache-2.0"
@@ -5,4 +5,4 @@ A thin client for a CodeImprint server: it zips a project, asks the server to se
5
5
  it, and verifies Imprint files offline. All analysis happens on the server.
6
6
  """
7
7
 
8
- __version__ = "0.5.0a32"
8
+ __version__ = "0.5.0a33"
@@ -314,8 +314,31 @@ def _client(args, fallback_url: str | None = None) -> Client:
314
314
  return _signed_in(url, settings.token if settings.url else None)
315
315
 
316
316
 
317
+ # The server's plan refusals (engine 0.7.0a40, CIM-BE-53-v1): stable codes whose message
318
+ # names the upgrade page. Never silent: a warning in automated builds, an error elsewhere.
319
+ PLAN_REFUSALS = ("plan_limit_reached", "plan_automatic_sealing")
320
+
321
+
322
+ def _plan_refusal(exc: BaseException) -> ApiError | None:
323
+ """The server's plan refusal behind ``exc`` (an ApiError, or a SealFailed made from one)."""
324
+ for e in (exc, exc.__cause__):
325
+ if isinstance(e, ApiError) and e.code in PLAN_REFUSALS:
326
+ return e
327
+ return None
328
+
329
+
330
+ def _plan_warning(refusal: ApiError) -> None:
331
+ """The plan's refusal, said plainly: in GitHub Actions also an annotation of its own."""
332
+ text = f"not sealed: {refusal.message} [{refusal.code}]"
333
+ if os.environ.get("GITHUB_ACTIONS") == "true":
334
+ print(f"::warning title=CodeImprint plan::{text}")
335
+ print(f"imprint: warning: {text}", file=sys.stderr)
336
+
337
+
317
338
  def _explain(client: Client, exc: Exception, what: str) -> str:
318
339
  """``what: why``, with what to do when the server asks for a sign-in."""
340
+ if isinstance(exc, ApiError) and exc.code in PLAN_REFUSALS:
341
+ return f"{what}: {exc.message} [{exc.code}]"
319
342
  if isinstance(exc, ApiError) and exc.code == "token_scope":
320
343
  return (f"{what}: a CI token only seals and checks its own project. Sign in with "
321
344
  f"`imprint login` for this. The server said: {exc}")
@@ -2163,6 +2186,10 @@ def cmd_seal(args) -> int:
2163
2186
  data = _prepare_upload(args.path, "seal", client, args.yes)
2164
2187
  rc = _seal_zip(args, client, data, cfg.get("project_id"), _folder_lines(args.path))
2165
2188
  except SealFailed as exc:
2189
+ refusal = _plan_refusal(exc)
2190
+ if refusal is not None: # the plan said no: never silent (CIM-BE-53-v1)
2191
+ _plan_warning(refusal)
2192
+ return 0 if _ci() else 2
2166
2193
  if _ci(): # never break a build by surprise
2167
2194
  _warn(f"seal skipped — {exc}")
2168
2195
  return 0
File without changes
File without changes