cassis-cli 4.0.0__tar.gz → 4.0.1__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 (24) hide show
  1. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/PKG-INFO +17 -5
  2. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/README.md +16 -4
  3. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/api.py +12 -0
  4. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/auth.py +17 -2
  5. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/eval.py +13 -4
  6. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/issues.py +14 -9
  7. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/pyproject.toml +1 -1
  8. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/LICENSE +0 -0
  9. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/NOTICE +0 -0
  10. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/__init__.py +0 -0
  11. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/chats.py +0 -0
  12. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/common.py +0 -0
  13. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/credentials.py +0 -0
  14. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/dbt.py +0 -0
  15. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/guide.py +0 -0
  16. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/main.py +0 -0
  17. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/ontology.py +0 -0
  18. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/ontology_design_guide.md +0 -0
  19. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/projects.py +0 -0
  20. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/schema.py +0 -0
  21. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/schema_plan.py +0 -0
  22. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/status.py +0 -0
  23. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/tables.py +0 -0
  24. {cassis_cli-4.0.0 → cassis_cli-4.0.1}/cassis_cli/verify.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cassis-cli
3
- Version: 4.0.0
3
+ Version: 4.0.1
4
4
  Summary: Validate, test and evaluate your Cassis context from your terminal, then publish it
5
5
  License: Apache-2.0
6
6
  License-File: LICENSE
@@ -107,8 +107,19 @@ copied credentials could remain usable until expiry.
107
107
 
108
108
  Credential precedence is **`--api-key` → `CASSIS_API_KEY` → saved login**. An
109
109
  explicit key that is rejected never falls back to a saved account. Logout does
110
- not unset `CASSIS_API_KEY`. Keep API keys in CI secret variables as before;
111
- delegated gateway keys are not CLI credentials.
110
+ not unset `CASSIS_API_KEY`. Keep API keys in CI secret variables as before.
111
+
112
+ A **gateway key** (an admin-created delegation key) lets a company agent run the
113
+ CLI for many people with one key. The key can act as anyone in the organization,
114
+ so it never reaches the agent's sandbox: a proxy outside it holds the key and, on
115
+ each request, sets the `Authorization` header and the `X-Cassis-User-Email`
116
+ header naming the person the agent acts for (replacing any the sandbox sent).
117
+ Inside the sandbox, `CASSIS_API_URL` points at the proxy and `CASSIS_API_KEY`
118
+ holds a placeholder. Each command runs as the named person, with their role, and
119
+ `cassis auth status` shows that person's account. Changes made through a gateway
120
+ go through a pull request: `cassis context upload` and `cassis schema push` are
121
+ refused to a gateway key (`cassis schema apply`, which only writes your checkout,
122
+ still works).
112
123
 
113
124
  Server selection is **`--api-url` → `CASSIS_API_URL` →
114
125
  `https://app.getcassis.com`**. Pass the server flag to each command, or set the
@@ -271,8 +282,9 @@ cassis tables dismiss CORE.PAYMENTS RAW.SESSION
271
282
  # Read what the agent saw for readable occurrences (ids from `issues show`; several at once):
272
283
  cassis issues evidence 019f0000-0000-7000-8000-0000000000e1 019f0000-0000-7000-8000-0000000000c1
273
284
 
274
- # Close the loop once the fix is published (or reopen). When the fix ships in a pull
275
- # request, put `Resolves <id>` in its description instead and the merge closes the issue:
285
+ # Close the loop once the fix is published (or reopen). On a project synced with its git
286
+ # repository, put `Resolves <id>` in the pull request's description instead and the merge
287
+ # closes the issue; a project published by `cassis context upload` needs this command:
276
288
  cassis issues resolve 019f0000-0000-7000-8000-0000000000e1 --published
277
289
  cassis issues dismiss 019f0000-0000-7000-8000-0000000000e1 019f0000-0000-7000-8000-0000000000e2 --reason duplicate
278
290
  cassis issues reopen 019f0000-0000-7000-8000-0000000000e1
@@ -82,8 +82,19 @@ copied credentials could remain usable until expiry.
82
82
 
83
83
  Credential precedence is **`--api-key` → `CASSIS_API_KEY` → saved login**. An
84
84
  explicit key that is rejected never falls back to a saved account. Logout does
85
- not unset `CASSIS_API_KEY`. Keep API keys in CI secret variables as before;
86
- delegated gateway keys are not CLI credentials.
85
+ not unset `CASSIS_API_KEY`. Keep API keys in CI secret variables as before.
86
+
87
+ A **gateway key** (an admin-created delegation key) lets a company agent run the
88
+ CLI for many people with one key. The key can act as anyone in the organization,
89
+ so it never reaches the agent's sandbox: a proxy outside it holds the key and, on
90
+ each request, sets the `Authorization` header and the `X-Cassis-User-Email`
91
+ header naming the person the agent acts for (replacing any the sandbox sent).
92
+ Inside the sandbox, `CASSIS_API_URL` points at the proxy and `CASSIS_API_KEY`
93
+ holds a placeholder. Each command runs as the named person, with their role, and
94
+ `cassis auth status` shows that person's account. Changes made through a gateway
95
+ go through a pull request: `cassis context upload` and `cassis schema push` are
96
+ refused to a gateway key (`cassis schema apply`, which only writes your checkout,
97
+ still works).
87
98
 
88
99
  Server selection is **`--api-url` → `CASSIS_API_URL` →
89
100
  `https://app.getcassis.com`**. Pass the server flag to each command, or set the
@@ -246,8 +257,9 @@ cassis tables dismiss CORE.PAYMENTS RAW.SESSION
246
257
  # Read what the agent saw for readable occurrences (ids from `issues show`; several at once):
247
258
  cassis issues evidence 019f0000-0000-7000-8000-0000000000e1 019f0000-0000-7000-8000-0000000000c1
248
259
 
249
- # Close the loop once the fix is published (or reopen). When the fix ships in a pull
250
- # request, put `Resolves <id>` in its description instead and the merge closes the issue:
260
+ # Close the loop once the fix is published (or reopen). On a project synced with its git
261
+ # repository, put `Resolves <id>` in the pull request's description instead and the merge
262
+ # closes the issue; a project published by `cassis context upload` needs this command:
251
263
  cassis issues resolve 019f0000-0000-7000-8000-0000000000e1 --published
252
264
  cassis issues dismiss 019f0000-0000-7000-8000-0000000000e1 019f0000-0000-7000-8000-0000000000e2 --reason duplicate
253
265
  cassis issues reopen 019f0000-0000-7000-8000-0000000000e1
@@ -32,6 +32,10 @@ USER_AGENT = f"cassis-cli/{__version__}"
32
32
  # Response header the CI endpoints set to the newest cassis-cli on PyPI.
33
33
  LATEST_VERSION_HEADER = "x-cassis-cli-latest"
34
34
 
35
+ # Set by the server on a 403 whose message is the whole explanation (an identity a gateway named,
36
+ # a write a delegation key may not make, a role that does not allow the action); valued with a code.
37
+ REFUSAL_HEADER = "X-Cassis-Refusal"
38
+
35
39
  _upgrade_notice_shown = False
36
40
 
37
41
 
@@ -157,6 +161,10 @@ def _project_scope_error(response: httpx.Response) -> ApiError:
157
161
  except ValueError:
158
162
  detail = None
159
163
  prefix = f"{detail} " if isinstance(detail, str) and detail else ""
164
+ if prefix and response.headers.get(REFUSAL_HEADER):
165
+ # The server says who may do this and how to fix it (a refused gateway identity, a write
166
+ # closed to delegation keys, an Explorer's role): a --project hint would send the agent astray.
167
+ return ApiError(f"{prefix}(HTTP {response.status_code}).")
160
168
  return ApiError(
161
169
  f"{prefix}(HTTP {response.status_code}). Check --project and that "
162
170
  "the acting account belongs to the project's organization and has permission."
@@ -325,6 +333,8 @@ def get_projects(
325
333
 
326
334
  if response.status_code == 401:
327
335
  raise AuthError(_REJECTED_CREDENTIAL)
336
+ if response.status_code == 403 and response.headers.get(REFUSAL_HEADER):
337
+ raise _project_scope_error(response)
328
338
  if response.status_code >= 400:
329
339
  raise ApiError(f"Cassis API returned HTTP {response.status_code}: {response.text[:500]}")
330
340
  result = _parse_json_response(response, url)
@@ -1557,6 +1567,8 @@ def get_chats(
1557
1567
  raise AuthError(_REJECTED_CREDENTIAL)
1558
1568
  if response.status_code == 404 and chat_id and _detail_or_text(response) == "Chat not found":
1559
1569
  raise ChatNotFoundError("Conversation not found or not accessible to this API key.")
1570
+ if response.status_code == 403 and response.headers.get(REFUSAL_HEADER):
1571
+ raise _project_scope_error(response)
1560
1572
  if response.status_code in (403, 404):
1561
1573
  raise ApiError(
1562
1574
  f"Conversation access denied (HTTP {response.status_code}). Check --project and the API key’s read access and project scope."
@@ -39,10 +39,25 @@ def account_info(server: str, credential: str) -> dict:
39
39
  "Credential expired, revoked, or invalid for this server. Run cassis logout then cassis login, or check your API key."
40
40
  )
41
41
  if response.status_code == 403:
42
- raise CredentialError("Access denied for this account.")
42
+ # A refused delegated identity explains itself (header missing or misplaced, user suspended, ...).
43
+ detail = _detail(response)
44
+ raise CredentialError(detail or "Access denied for this account.")
43
45
  if response.status_code != 200:
44
46
  raise CredentialError(f"Cannot inspect this account (HTTP {response.status_code}). Check the server version.")
45
- return response.json()
47
+ try:
48
+ return response.json()
49
+ except ValueError as exc:
50
+ raise CredentialError(
51
+ f"Cassis at {server} returned a non-JSON response: check --api-url and any proxy in between."
52
+ ) from exc
53
+
54
+
55
+ def _detail(response: httpx.Response) -> Optional[str]:
56
+ try:
57
+ detail = response.json().get("detail")
58
+ except ValueError:
59
+ return None
60
+ return detail if isinstance(detail, str) and detail else None
46
61
 
47
62
 
48
63
  def login(
@@ -2524,18 +2524,27 @@ def _wait_for_run(
2524
2524
  def on_auth_error(exc: AuthError) -> None:
2525
2525
  typer.secho(f"{exc} The run keeps going server-side.", fg=typer.colors.RED, err=True)
2526
2526
 
2527
+ # The run outlives the wait: name the commands that pick it up again, an agent cannot open the webapp.
2528
+ # They carry the project and a non-default server, so they work from any directory as printed.
2529
+ target = f" --project {project_id}"
2530
+ if api_url.rstrip("/") != DEFAULT_API_URL:
2531
+ target += f" --api-url {api_url}"
2532
+ pick_up = (
2533
+ f"`cassis eval runs watch {run_id}{target}` waits for it again, `cassis eval runs show {run_id}{target}` "
2534
+ "prints it (or says it is still in progress)."
2535
+ )
2536
+
2527
2537
  def on_give_up(exc: ApiError, failures: int) -> None:
2528
2538
  typer.secho(
2529
- f"Polling failed {failures} times in a row ({exc}). "
2530
- "Giving up — the run keeps going server-side; see the webapp's Evals page.",
2539
+ f"Polling failed {failures} times in a row ({exc}). Giving up — the run keeps going server-side: "
2540
+ f"{pick_up}",
2531
2541
  fg=typer.colors.RED,
2532
2542
  err=True,
2533
2543
  )
2534
2544
 
2535
2545
  def on_timeout(_snapshot: "tuple[dict[str, Any], list[dict[str, Any]]]") -> None:
2536
2546
  typer.secho(
2537
- f"Timed out after {timeout:g}s waiting for run {run_id}. "
2538
- "The run keeps going server-side — see the webapp's Evals page.",
2547
+ f"Timed out after {timeout:g}s waiting for run {run_id}. The run keeps going server-side: {pick_up}",
2539
2548
  fg=typer.colors.YELLOW,
2540
2549
  err=True,
2541
2550
  )
@@ -226,8 +226,10 @@ def show(
226
226
  ) -> None:
227
227
  """Show issues: each one's diagnosis, fix proposal, the questions to guard, and its evidence.
228
228
 
229
- `Next step` says how the issue closes: a pull request whose description
230
- contains `Resolves <id>`, which Cassis resolves when it merges. On an open
229
+ `Next step` says how the issue closes: on a project synced with its git
230
+ repository, a pull request whose description contains `Resolves <id>`,
231
+ which Cassis resolves when it merges; on a project published by `cassis
232
+ context upload`, `cassis issues resolve` once the fix is published. On an open
231
233
  issue, `Guard questions` are the failing questions to turn into eval cases
232
234
  before that pull request (`cassis context test -q ... --save-case --issue
233
235
  <id>`). Each occurrence's id feeds `cassis issues evidence`, which prints
@@ -525,10 +527,12 @@ def resolve(
525
527
  ) -> None:
526
528
  """Mark issues resolved: the context change that fixes them is published.
527
529
 
528
- For a fix that ships through a pull request, prefer writing `Resolves <id>`
529
- in the PR description: Cassis resolves the issue itself when the PR
530
- merges, and records the PR on it. Use this command for outcomes that never
531
- go through a PR. Exits 0 on success, 1 when an issue does not exist in
530
+ On a project synced with its git repository (`cassis status` says so),
531
+ prefer writing `Resolves <id>` in the description of the pull request that
532
+ ships the fix: Cassis resolves the issue itself when the PR merges, and
533
+ records the PR on it. Use this command for outcomes that never go through
534
+ a PR, and on a project published by `cassis context upload`, where the
535
+ mention is not read. Exits 0 on success, 1 when an issue does not exist in
532
536
  the project (the others are still resolved), 2 on usage errors, 3 on
533
537
  transport/API errors.
534
538
  """
@@ -544,12 +548,13 @@ def resolve(
544
548
  mentions = ", ".join(f"`Resolves {issue_id}`" for issue_id in ids)
545
549
  resolves = "resolves the issue when it merges" if len(ids) == 1 else "resolves each issue when it merges"
546
550
  typer.echo(
547
- "Nothing sent. Ship the fix first: a pull request whose description contains "
548
- f"{mentions} {resolves}, with no command to run.",
551
+ "Nothing sent. Ship the fix first: on a project synced with its git repository, a pull "
552
+ f"request whose description contains {mentions} {resolves}, with no command to run.",
549
553
  err=True,
550
554
  )
551
555
  typer.echo(
552
- f"For a fix published another way, run `cassis issues resolve {shown} --published` once it is.",
556
+ "For a fix published another way, `cassis context upload` included, run "
557
+ f"`cassis issues resolve {shown} --published` once it is.",
553
558
  err=True,
554
559
  )
555
560
  raise typer.Exit(EXIT_USAGE)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cassis-cli"
3
- version = "4.0.0"
3
+ version = "4.0.1"
4
4
  description = "Validate, test and evaluate your Cassis context from your terminal, then publish it"
5
5
  readme = "README.md"
6
6
  license = { text = "Apache-2.0" }
File without changes
File without changes
File without changes