cassis-cli 3.7.0__tar.gz → 3.9.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 (23) hide show
  1. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/PKG-INFO +10 -9
  2. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/README.md +9 -8
  3. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/api.py +69 -100
  4. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/eval.py +1 -1
  5. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/issues.py +135 -183
  6. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/pyproject.toml +1 -1
  7. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/LICENSE +0 -0
  8. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/NOTICE +0 -0
  9. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/__init__.py +0 -0
  10. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/auth.py +0 -0
  11. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/chats.py +0 -0
  12. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/common.py +0 -0
  13. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/credentials.py +0 -0
  14. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/dbt.py +0 -0
  15. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/guide.py +0 -0
  16. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/main.py +0 -0
  17. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/ontology.py +0 -0
  18. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/ontology_design_guide.md +0 -0
  19. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/projects.py +0 -0
  20. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/schema.py +0 -0
  21. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/schema_plan.py +0 -0
  22. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/status.py +0 -0
  23. {cassis_cli-3.7.0 → cassis_cli-3.9.0}/cassis_cli/verify.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cassis-cli
3
- Version: 3.7.0
3
+ Version: 3.9.0
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
@@ -46,7 +46,7 @@ Validate, test and evaluate your context from your terminal, then publish it. Th
46
46
  - DDL imports describe one schema snapshot/export file, including ordinary and materialized views; they do not replay incremental migrations. Extraction diagnostics include object names and statement locations. If extraction is incomplete, `schema plan` and `--dry-run` show the extracted inventory and exit 1; `apply`, `push`, and `--write-checkout` cannot save that result. Unknown column types are warnings when all output names are known. Plans also show object-kind, view-definition, comment, and constraint changes. `--json` preserves structured diagnostics and the server-capped inventory.
47
47
 
48
48
  - `cassis status` shows the project's published version (number, label, git commit), whether unpublished changes await publication, the git-sync binding, a schema plan waiting to be applied, and how your local git HEAD relates to the published commit (in sync / N commits ahead / diverged). `cassis status --watch` polls until the published commit matches your local HEAD (e.g. right after merging a PR whose CI publishes the context) instead of watching the GitHub Actions tab.
49
- - `cassis issues` triages the issues Cassis raised on the project (what it found wrong while answering questions: a context gap, missing data) without leaving the checkout: `issues list` (filterable by status, impact, cause and context domain, and showing each issue's domain so you can work through one domain at a time; and each issue's reach, the chat answers that used its context tables in the last 30 days), `issues show <id>` for the diagnosis, suggested action, the occurrences behind it, its reach and evidence (removed from dbt, an AI review suggestion, user feedback, a failed eval, or the chat analysis), `issues evidence <id> <occurrence-id>` for what the agent actually saw, and `issues resolve` / `dismiss` / `reopen` once you've acted on it. When the fix ships through a pull request, write the `PR mention:` line `issues show` prints (`Resolves <id>`) in the PR description instead: Cassis resolves the issue when the PR merges, and `issues show` then reports how it was closed and through which PR.
49
+ - `cassis issues` triages the issues Cassis raised on the project (what it found wrong while answering questions: a context gap, missing data) without leaving the checkout: `issues list` (filterable by status, impact, cause and context domain, and showing each issue's domain so you can work through one domain at a time; and each issue's reach, the chat answers that used its context tables in the last 30 days), `issues show <id>` for the diagnosis, suggested action, the occurrences behind it, its reach and evidence (removed from dbt, an AI review suggestion, user feedback, a failed eval, or the chat analysis), `issues evidence <id> <occurrence-id>` for what the agent actually saw, and `issues resolve` / `dismiss` / `reopen` once you've acted on it. When the fix ships through a pull request, write the `PR mention:` line `issues show` prints (`Resolves <id>`) in the PR description instead: Cassis resolves the issue when the PR merges, and `issues show` then reports how it was closed and through which PR. `issues tables` lists the warehouse tables users asked for that the context does not describe: one line per table, the most asked first, with a suggested domain. These requests are not issues, so `issues list` does not print them. `issues tables set-aside <TABLE>` records a table the team will not add; a table you add leaves the list on its own once published.
50
50
  - `cassis dbt push` sends your dbt project's artifacts (`target/manifest.json`, and `catalog.json` when present) to Cassis from the dbt project's CI, with the commit they were built from. Cassis checks the files, matches each dbt model, seed, snapshot and source to a table of the project's data source, and keeps the upload as the project's dbt baseline unless a newer one is already there. The command prints how many relations matched and how many tests they declare. Cassis compares the upload with the previous baseline and saves findings about the context the merged change puts in doubt for grouping and issue curation. The command distinguishes findings awaiting curation from published issues, printing the source observation for pending findings and links for published issues. Nothing the agent answers with changes.
51
51
  - `cassis dbt check` runs the same comparison on a pull request, before the change merges: it uploads the PR's artifacts (after `dbt compile` on the production target), compares them with the baseline, and prints the context tables, columns, joins and metrics the change puts in doubt, with why it matters and the context change to make. Each finding also says its **reach**, how many chat answers used its context tables in the last 30 days, and within each section the most-reached objects print first, the order the Review page will show them in. Findings are advisory: nothing is filed, the baseline doesn't move, and the check exits 0 with or without findings.
52
52
  - `cassis verify` runs the full local gate in one verb (`context fmt --check`, `context check`, `eval run`), stopping at the first failure. One command in a checkout ("is this change safe to merge?"), one job in CI. `--no-eval` skips the eval suite.
@@ -248,11 +248,6 @@ cassis schema plan future.sql --dry-run --write-checkout # plan a not-yet-deplo
248
248
  # List the projects the acting account can reach (id, name, published version, dialect):
249
249
  cassis projects list
250
250
 
251
- # Refresh the issues from the conversations nobody has analyzed yet (the same pass as the
252
- # webapp's "Analyze conversations" button; waits for the result, --no-wait returns at once,
253
- # and Ctrl-C cancels the run server-side and exits 130):
254
- cassis issues analyze
255
-
256
251
  # Triage the issues Cassis raised (filter by --status/--impact/--cause; --json for raw output):
257
252
  cassis issues list # open issues by default
258
253
  cassis issues list --status all # include resolved and dismissed issues
@@ -260,6 +255,12 @@ cassis issues show 019f0000-0000-7000-8000-0000000000e1
260
255
 
261
256
  # Work one context domain at a time (nested domains included):
262
257
  cassis issues list --domain sales
258
+ # The warehouse tables users asked for that the context does not describe, the most asked first:
259
+ cassis issues tables
260
+ cassis issues tables --layer modeled
261
+ cassis issues tables --domain finance --offset 50
262
+ # A table the team will not add (--undo takes it back):
263
+ cassis issues tables set-aside CORE.PAYMENTS
263
264
 
264
265
  # Issues are shared with the project; source evidence respects conversation access.
265
266
  # Read what the agent saw for one readable occurrence (ids from `issues show`):
@@ -345,9 +346,9 @@ A domain without `owners` inherits its nearest parent's, and the root domain's (
345
346
  | Code | Meaning |
346
347
  | ---- | ------------------------------------------------------------------------------ |
347
348
  | 0 | Context is valid (check) / pulled (pull) / uploaded (upload) / eval run completed with no regression: every case passed, already failed on the base run, or is pending the change it guards (eval run) / every probe completed (test, whatever its outcome; probes are informational, don't gate CI on them) / dbt upload accepted, or kept behind a newer one (dbt push) / dbt upload checked, with or without findings (dbt check) |
348
- | 1 | Validation failed (check: findings printed; upload: nothing imported; eval run: invalid tree or a regression, a case whose answer fails now and passed on the base run; test: invalid tree or a probe failed; add-case: duplicate question or gold SQL that does not run; delete-case, history: no such case in the project; show: no such run in the project; issues: no such issue or occurrence in the project; issues analyze: failed or cancelled analysis run; schema plan/apply: extraction is incomplete, the plan failed (unparseable or truncated DDL), is stale or expired, the apply failed, or the project won't accept it (a plan is being applied, a DDL was given for a warehouse-connected project, or --warehouse for a DDL-only one); dbt push: the upload was refused or rejected (a file is invalid, too large or from an unsupported dbt version, or no relation matches the project's data source); dbt check: the upload was refused or rejected (an invalid file, or no baseline yet: run `cassis dbt push` first)) |
349
+ | 1 | Validation failed (check: findings printed; upload: nothing imported; eval run: invalid tree or a regression, a case whose answer fails now and passed on the base run; test: invalid tree or a probe failed; add-case: duplicate question or gold SQL that does not run; delete-case, history: no such case in the project; show: no such run in the project; issues: no such issue or occurrence in the project; schema plan/apply: extraction is incomplete, the plan failed (unparseable or truncated DDL), is stale or expired, the apply failed, or the project won't accept it (a plan is being applied, a DDL was given for a warehouse-connected project, or --warehouse for a DDL-only one); dbt push: the upload was refused or rejected (a file is invalid, too large or from an unsupported dbt version, or no relation matches the project's data source); dbt check: the upload was refused or rejected (an invalid file, or no baseline yet: run `cassis dbt push` first)) |
349
350
  | 2 | Usage error (missing credentials or project, no context directory, unreadable file, tree over the size limits, `eval run --branch` naming a context branch the project does not have, `eval run --base` naming a published version the project does not have or given without `--changed`, `eval run --dry-run --case` naming no current case, `upload` or `schema push` outside a git checkout or with uncommitted context files, `dbt push` or `dbt check` without a manifest.json, outside a git checkout without `--commit`, or with an artifact over the size limits) |
350
- | 3 | Transport/API error (unreachable API, invalid key, inaccessible project, unexpected response, a server too old for the command or option), another eval run or issue analysis already active, out of credits, `--timeout` reached, or Cassis failed on its side while processing a dbt upload (`dbt push` / `dbt check`: nothing to fix in the upload, push again) |
351
+ | 3 | Transport/API error (unreachable API, invalid key, inaccessible project, unexpected response, a server too old for the command or option), another eval run already active, out of credits, `--timeout` reached, or Cassis failed on its side while processing a dbt upload (`dbt push` / `dbt check`: nothing to fix in the upload, push again) |
351
352
  | 4 | `eval run` reached no verdict: the run failed or was cancelled on Cassis's side, or the cases that did not pass errored instead of failing (agent, judge or warehouse errors, a broken gold SQL). Nothing says the context regressed: rerun, or read the errors |
352
353
 
353
354
  Commands that send the local tree (`check`, `fmt`, `upload`, `eval run`, `test`) accept up to
@@ -21,7 +21,7 @@ Validate, test and evaluate your context from your terminal, then publish it. Th
21
21
  - DDL imports describe one schema snapshot/export file, including ordinary and materialized views; they do not replay incremental migrations. Extraction diagnostics include object names and statement locations. If extraction is incomplete, `schema plan` and `--dry-run` show the extracted inventory and exit 1; `apply`, `push`, and `--write-checkout` cannot save that result. Unknown column types are warnings when all output names are known. Plans also show object-kind, view-definition, comment, and constraint changes. `--json` preserves structured diagnostics and the server-capped inventory.
22
22
 
23
23
  - `cassis status` shows the project's published version (number, label, git commit), whether unpublished changes await publication, the git-sync binding, a schema plan waiting to be applied, and how your local git HEAD relates to the published commit (in sync / N commits ahead / diverged). `cassis status --watch` polls until the published commit matches your local HEAD (e.g. right after merging a PR whose CI publishes the context) instead of watching the GitHub Actions tab.
24
- - `cassis issues` triages the issues Cassis raised on the project (what it found wrong while answering questions: a context gap, missing data) without leaving the checkout: `issues list` (filterable by status, impact, cause and context domain, and showing each issue's domain so you can work through one domain at a time; and each issue's reach, the chat answers that used its context tables in the last 30 days), `issues show <id>` for the diagnosis, suggested action, the occurrences behind it, its reach and evidence (removed from dbt, an AI review suggestion, user feedback, a failed eval, or the chat analysis), `issues evidence <id> <occurrence-id>` for what the agent actually saw, and `issues resolve` / `dismiss` / `reopen` once you've acted on it. When the fix ships through a pull request, write the `PR mention:` line `issues show` prints (`Resolves <id>`) in the PR description instead: Cassis resolves the issue when the PR merges, and `issues show` then reports how it was closed and through which PR.
24
+ - `cassis issues` triages the issues Cassis raised on the project (what it found wrong while answering questions: a context gap, missing data) without leaving the checkout: `issues list` (filterable by status, impact, cause and context domain, and showing each issue's domain so you can work through one domain at a time; and each issue's reach, the chat answers that used its context tables in the last 30 days), `issues show <id>` for the diagnosis, suggested action, the occurrences behind it, its reach and evidence (removed from dbt, an AI review suggestion, user feedback, a failed eval, or the chat analysis), `issues evidence <id> <occurrence-id>` for what the agent actually saw, and `issues resolve` / `dismiss` / `reopen` once you've acted on it. When the fix ships through a pull request, write the `PR mention:` line `issues show` prints (`Resolves <id>`) in the PR description instead: Cassis resolves the issue when the PR merges, and `issues show` then reports how it was closed and through which PR. `issues tables` lists the warehouse tables users asked for that the context does not describe: one line per table, the most asked first, with a suggested domain. These requests are not issues, so `issues list` does not print them. `issues tables set-aside <TABLE>` records a table the team will not add; a table you add leaves the list on its own once published.
25
25
  - `cassis dbt push` sends your dbt project's artifacts (`target/manifest.json`, and `catalog.json` when present) to Cassis from the dbt project's CI, with the commit they were built from. Cassis checks the files, matches each dbt model, seed, snapshot and source to a table of the project's data source, and keeps the upload as the project's dbt baseline unless a newer one is already there. The command prints how many relations matched and how many tests they declare. Cassis compares the upload with the previous baseline and saves findings about the context the merged change puts in doubt for grouping and issue curation. The command distinguishes findings awaiting curation from published issues, printing the source observation for pending findings and links for published issues. Nothing the agent answers with changes.
26
26
  - `cassis dbt check` runs the same comparison on a pull request, before the change merges: it uploads the PR's artifacts (after `dbt compile` on the production target), compares them with the baseline, and prints the context tables, columns, joins and metrics the change puts in doubt, with why it matters and the context change to make. Each finding also says its **reach**, how many chat answers used its context tables in the last 30 days, and within each section the most-reached objects print first, the order the Review page will show them in. Findings are advisory: nothing is filed, the baseline doesn't move, and the check exits 0 with or without findings.
27
27
  - `cassis verify` runs the full local gate in one verb (`context fmt --check`, `context check`, `eval run`), stopping at the first failure. One command in a checkout ("is this change safe to merge?"), one job in CI. `--no-eval` skips the eval suite.
@@ -223,11 +223,6 @@ cassis schema plan future.sql --dry-run --write-checkout # plan a not-yet-deplo
223
223
  # List the projects the acting account can reach (id, name, published version, dialect):
224
224
  cassis projects list
225
225
 
226
- # Refresh the issues from the conversations nobody has analyzed yet (the same pass as the
227
- # webapp's "Analyze conversations" button; waits for the result, --no-wait returns at once,
228
- # and Ctrl-C cancels the run server-side and exits 130):
229
- cassis issues analyze
230
-
231
226
  # Triage the issues Cassis raised (filter by --status/--impact/--cause; --json for raw output):
232
227
  cassis issues list # open issues by default
233
228
  cassis issues list --status all # include resolved and dismissed issues
@@ -235,6 +230,12 @@ cassis issues show 019f0000-0000-7000-8000-0000000000e1
235
230
 
236
231
  # Work one context domain at a time (nested domains included):
237
232
  cassis issues list --domain sales
233
+ # The warehouse tables users asked for that the context does not describe, the most asked first:
234
+ cassis issues tables
235
+ cassis issues tables --layer modeled
236
+ cassis issues tables --domain finance --offset 50
237
+ # A table the team will not add (--undo takes it back):
238
+ cassis issues tables set-aside CORE.PAYMENTS
238
239
 
239
240
  # Issues are shared with the project; source evidence respects conversation access.
240
241
  # Read what the agent saw for one readable occurrence (ids from `issues show`):
@@ -320,9 +321,9 @@ A domain without `owners` inherits its nearest parent's, and the root domain's (
320
321
  | Code | Meaning |
321
322
  | ---- | ------------------------------------------------------------------------------ |
322
323
  | 0 | Context is valid (check) / pulled (pull) / uploaded (upload) / eval run completed with no regression: every case passed, already failed on the base run, or is pending the change it guards (eval run) / every probe completed (test, whatever its outcome; probes are informational, don't gate CI on them) / dbt upload accepted, or kept behind a newer one (dbt push) / dbt upload checked, with or without findings (dbt check) |
323
- | 1 | Validation failed (check: findings printed; upload: nothing imported; eval run: invalid tree or a regression, a case whose answer fails now and passed on the base run; test: invalid tree or a probe failed; add-case: duplicate question or gold SQL that does not run; delete-case, history: no such case in the project; show: no such run in the project; issues: no such issue or occurrence in the project; issues analyze: failed or cancelled analysis run; schema plan/apply: extraction is incomplete, the plan failed (unparseable or truncated DDL), is stale or expired, the apply failed, or the project won't accept it (a plan is being applied, a DDL was given for a warehouse-connected project, or --warehouse for a DDL-only one); dbt push: the upload was refused or rejected (a file is invalid, too large or from an unsupported dbt version, or no relation matches the project's data source); dbt check: the upload was refused or rejected (an invalid file, or no baseline yet: run `cassis dbt push` first)) |
324
+ | 1 | Validation failed (check: findings printed; upload: nothing imported; eval run: invalid tree or a regression, a case whose answer fails now and passed on the base run; test: invalid tree or a probe failed; add-case: duplicate question or gold SQL that does not run; delete-case, history: no such case in the project; show: no such run in the project; issues: no such issue or occurrence in the project; schema plan/apply: extraction is incomplete, the plan failed (unparseable or truncated DDL), is stale or expired, the apply failed, or the project won't accept it (a plan is being applied, a DDL was given for a warehouse-connected project, or --warehouse for a DDL-only one); dbt push: the upload was refused or rejected (a file is invalid, too large or from an unsupported dbt version, or no relation matches the project's data source); dbt check: the upload was refused or rejected (an invalid file, or no baseline yet: run `cassis dbt push` first)) |
324
325
  | 2 | Usage error (missing credentials or project, no context directory, unreadable file, tree over the size limits, `eval run --branch` naming a context branch the project does not have, `eval run --base` naming a published version the project does not have or given without `--changed`, `eval run --dry-run --case` naming no current case, `upload` or `schema push` outside a git checkout or with uncommitted context files, `dbt push` or `dbt check` without a manifest.json, outside a git checkout without `--commit`, or with an artifact over the size limits) |
325
- | 3 | Transport/API error (unreachable API, invalid key, inaccessible project, unexpected response, a server too old for the command or option), another eval run or issue analysis already active, out of credits, `--timeout` reached, or Cassis failed on its side while processing a dbt upload (`dbt push` / `dbt check`: nothing to fix in the upload, push again) |
326
+ | 3 | Transport/API error (unreachable API, invalid key, inaccessible project, unexpected response, a server too old for the command or option), another eval run already active, out of credits, `--timeout` reached, or Cassis failed on its side while processing a dbt upload (`dbt push` / `dbt check`: nothing to fix in the upload, push again) |
326
327
  | 4 | `eval run` reached no verdict: the run failed or was cancelled on Cassis's side, or the cases that did not pass errored instead of failing (agent, judge or warehouse errors, a broken gold SQL). Nothing says the context regressed: rerun, or read the errors |
327
328
 
328
329
  Commands that send the local tree (`check`, `fmt`, `upload`, `eval run`, `test`) accept up to
@@ -1162,7 +1162,7 @@ def post_eval_run_cancel(
1162
1162
 
1163
1163
 
1164
1164
  class IssueNotFoundError(ApiError):
1165
- """The project has no issue, occurrence or issue-analysis run with this id.
1165
+ """The project has no issue or occurrence with this id.
1166
1166
 
1167
1167
  Raised off the server's exact 404 detail, so it separates "this id doesn't
1168
1168
  exist" from "this project isn't in scope for your key", which 404s too.
@@ -1232,6 +1232,74 @@ def get_issues(
1232
1232
  return result
1233
1233
 
1234
1234
 
1235
+ def get_requested_tables(
1236
+ *,
1237
+ api_url: str,
1238
+ api_key: str,
1239
+ project_id: str,
1240
+ layer: Optional[str] = None,
1241
+ search: Optional[str] = None,
1242
+ domain: Optional[str] = None,
1243
+ offset: int = 0,
1244
+ limit: int = 50,
1245
+ transport: Optional[httpx.BaseTransport] = None,
1246
+ ) -> dict[str, Any]:
1247
+ """GET /api/ci/projects/{project_id}/requested-tables and return the page of tables to add."""
1248
+ url = api_url.rstrip("/") + f"/api/ci/projects/{project_id}/requested-tables"
1249
+ params = {"limit": str(limit)}
1250
+ if offset:
1251
+ params["offset"] = str(offset)
1252
+ if layer:
1253
+ params["layer"] = layer
1254
+ if search:
1255
+ params["search"] = search
1256
+ if domain:
1257
+ params["domain"] = domain
1258
+ result = _get_issue_json(url, api_key, transport, params=params)
1259
+ if not isinstance(result, dict) or not isinstance(result.get("items"), list):
1260
+ raise ApiError(f"Unexpected response shape from the Cassis API at {url}.")
1261
+ return result
1262
+
1263
+
1264
+ class TableDecisionRefusedError(ApiError):
1265
+ """The server refused a decision about a requested table (HTTP 422), for example a table that is not in the list."""
1266
+
1267
+
1268
+ def post_requested_table_decision(
1269
+ *,
1270
+ api_url: str,
1271
+ api_key: str,
1272
+ project_id: str,
1273
+ table: str,
1274
+ set_aside: bool,
1275
+ transport: Optional[httpx.BaseTransport] = None,
1276
+ ) -> None:
1277
+ """POST /api/ci/projects/{project_id}/requested-tables/decision: set a requested table aside or take it back.
1278
+
1279
+ Raise `TableDecisionRefusedError` with the server's reason when it refuses
1280
+ the table (HTTP 422: it is not in the list of tables to add).
1281
+ """
1282
+ url = api_url.rstrip("/") + f"/api/ci/projects/{project_id}/requested-tables/decision"
1283
+ try:
1284
+ with _client(transport=transport) as client:
1285
+ response = client.post(
1286
+ url,
1287
+ json={"table": table, "set_aside": set_aside},
1288
+ headers={"Authorization": authorization(api_url, api_key)},
1289
+ )
1290
+ except httpx.HTTPError as exc:
1291
+ raise ApiError(f"Could not reach the Cassis API at {url}: {exc}") from exc
1292
+
1293
+ if response.status_code == 401:
1294
+ raise AuthError(_REJECTED_CREDENTIAL)
1295
+ if response.status_code == 422:
1296
+ raise TableDecisionRefusedError(_detail_or_text(response))
1297
+ if response.status_code in (403, 404):
1298
+ raise _project_scope_error(response)
1299
+ if response.status_code >= 400:
1300
+ raise ApiError(f"Cassis API returned HTTP {response.status_code}: {response.text[:500]}")
1301
+
1302
+
1235
1303
  def get_issue(
1236
1304
  *,
1237
1305
  api_url: str,
@@ -1406,105 +1474,6 @@ def post_ontology_test(
1406
1474
  return result
1407
1475
 
1408
1476
 
1409
- class IssueAnalysisActiveError(ApiError):
1410
- """An issue-analysis run is already in flight for the project (HTTP 409)."""
1411
-
1412
-
1413
- class NothingToAnalyzeError(ApiError):
1414
- """Every conversation on the project has already been analyzed (HTTP 422)."""
1415
-
1416
-
1417
- _ANALYSIS_RUN_KEYS = ("id", "status", "total_chats", "chats_analyzed", "occurrences_created", "issues_touched")
1418
-
1419
-
1420
- def _check_analysis_run_shape(result: Any, url: str) -> dict[str, Any]:
1421
- if not isinstance(result, dict) or not all(key in result for key in _ANALYSIS_RUN_KEYS):
1422
- raise ApiError(f"Unexpected response shape from the Cassis API at {url}.")
1423
- return result
1424
-
1425
-
1426
- def post_issue_analysis_start(
1427
- *,
1428
- api_url: str,
1429
- api_key: str,
1430
- project_id: str,
1431
- transport: Optional[httpx.BaseTransport] = None,
1432
- ) -> dict[str, Any]:
1433
- """POST /api/ci/projects/{project_id}/issue-analysis/runs and return the run record."""
1434
- url = api_url.rstrip("/") + f"/api/ci/projects/{project_id}/issue-analysis/runs"
1435
- try:
1436
- with _client(transport=transport) as client:
1437
- response = client.post(url, headers={"Authorization": authorization(api_url, api_key)})
1438
- except httpx.HTTPError as exc:
1439
- raise ApiError(f"Could not reach the Cassis API at {url}: {exc}") from exc
1440
-
1441
- if response.status_code == 401:
1442
- raise AuthError(_REJECTED_CREDENTIAL)
1443
- if response.status_code == 409:
1444
- raise IssueAnalysisActiveError(
1445
- "An issue analysis is already running for this project — wait for it to finish, "
1446
- "or cancel it from the webapp's Issues page."
1447
- )
1448
- if response.status_code == 422 and "analyz" in response.text.lower():
1449
- # The route takes no body, so its 422 is the server's "nothing to
1450
- # analyze" answer; any other 422 falls through to the generic error.
1451
- raise NothingToAnalyzeError("Nothing to analyze: every conversation on this project has already been analyzed.")
1452
- if response.status_code in (403, 404):
1453
- raise _project_scope_error(response)
1454
- if response.status_code >= 400:
1455
- raise ApiError(f"Cassis API returned HTTP {response.status_code}: {response.text[:500]}")
1456
- return _check_analysis_run_shape(_parse_json_response(response, url), url)
1457
-
1458
-
1459
- def get_issue_analysis_run(
1460
- *,
1461
- api_url: str,
1462
- api_key: str,
1463
- project_id: str,
1464
- run_id: str,
1465
- transport: Optional[httpx.BaseTransport] = None,
1466
- ) -> dict[str, Any]:
1467
- """GET /api/ci/projects/{project_id}/issue-analysis/runs/{run_id} and return the run record."""
1468
- url = api_url.rstrip("/") + f"/api/ci/projects/{project_id}/issue-analysis/runs/{run_id}"
1469
- return _check_analysis_run_shape(
1470
- _get_issue_json(
1471
- url,
1472
- api_key,
1473
- transport,
1474
- not_found_message=f"No issue-analysis run {run_id} in this project.",
1475
- not_found_detail="Issue-analysis run not found",
1476
- ),
1477
- url,
1478
- )
1479
-
1480
-
1481
- def post_issue_analysis_cancel(
1482
- *,
1483
- api_url: str,
1484
- api_key: str,
1485
- project_id: str,
1486
- run_id: str,
1487
- transport: Optional[httpx.BaseTransport] = None,
1488
- ) -> None:
1489
- """POST /api/ci/projects/{project_id}/issue-analysis/runs/{run_id}/cancel."""
1490
- url = api_url.rstrip("/") + f"/api/ci/projects/{project_id}/issue-analysis/runs/{run_id}/cancel"
1491
- try:
1492
- with _client(transport=transport) as client:
1493
- response = client.post(url, headers={"Authorization": authorization(api_url, api_key)})
1494
- except httpx.HTTPError as exc:
1495
- raise ApiError(f"Could not reach the Cassis API at {url}: {exc}") from exc
1496
- if response.status_code == 401:
1497
- raise AuthError(_REJECTED_CREDENTIAL)
1498
- # Same exact-match contract as `get_issue_analysis_run`: a missing run is
1499
- # not a project-scope problem.
1500
- if response.status_code == 404 and _detail_or_text(response) == "Issue-analysis run not found":
1501
- raise IssueNotFoundError(f"No issue-analysis run {run_id} in this project.")
1502
- if response.status_code in (403, 404):
1503
- raise _project_scope_error(response)
1504
- if response.status_code >= 400:
1505
- raise ApiError(f"Cassis API returned HTTP {response.status_code}: {response.text[:500]}")
1506
-
1507
-
1508
1477
  class DbtUploadRejectedError(ApiError):
1509
1478
  """The server refused the dbt upload request itself (400, 413, 422).
1510
1479
 
@@ -2053,7 +2053,7 @@ def run(
2053
2053
  json_output=json_output,
2054
2054
  )
2055
2055
  except KeyboardInterrupt:
2056
- # To stderr under --json, for the same reason as `issues analyze`.
2056
+ # To stderr under --json, so stdout stays the JSON document.
2057
2057
  typer.echo("", err=json_output)
2058
2058
  typer.echo("Interrupted — cancelling the run...", err=json_output)
2059
2059
  try:
@@ -3,8 +3,7 @@
3
3
  Issues are what the product found wrong while answering questions (a context
4
4
  gap, missing data). Listing, reading the evidence behind an occurrence, and
5
5
  resolving or dismissing them from a checkout keeps the fix loop next to the
6
- context files instead of in the webapp; `analyze` refreshes them from the
7
- conversations that arrived since the last pass, without waiting for the nightly one.
6
+ context files instead of in the webapp.
8
7
  """
9
8
 
10
9
  from __future__ import annotations
@@ -20,36 +19,34 @@ from cassis_cli.api import (
20
19
  ApiError,
21
20
  AuthError,
22
21
  IssueNotFoundError,
23
- NothingToAnalyzeError,
22
+ TableDecisionRefusedError,
24
23
  get_issue,
25
- get_issue_analysis_run,
26
24
  get_issue_evidence,
27
25
  get_issues,
28
- post_issue_analysis_cancel,
29
- post_issue_analysis_start,
26
+ get_requested_tables,
30
27
  post_issue_status,
28
+ post_requested_table_decision,
31
29
  )
32
30
  from cassis_cli.common import (
33
31
  DEFAULT_BASE_PATH,
34
- EXIT_INTERRUPTED,
35
32
  EXIT_OK,
36
- EXIT_TRANSPORT,
37
33
  EXIT_USAGE,
38
34
  EXIT_VALIDATION_FAILED,
39
35
  api_failure,
40
- echo_poll_retry,
41
36
  one_line,
42
- poll_until,
43
37
  require_api_key,
44
38
  resolve_project_id,
45
39
  )
46
40
 
47
41
  app = typer.Typer(no_args_is_help=True, help="Triage the project's issues.")
42
+ # The tables users asked for are a list of their own, not issues: `issues list` points to it.
43
+ _TABLES_HINT = "Tables users asked for are not issues: see `cassis issues tables`."
48
44
 
49
45
  STATUSES = ("open", "resolved", "dismissed", "all")
50
46
  DISMISS_REASONS = ("invalid", "irrelevant", "duplicate", "declined")
51
47
  IMPACTS = ("wrong_answer", "at_risk", "unreliable_answer", "no_answer", "inefficient")
52
48
  CAUSES = ("ontology_gap", "missing_data")
49
+ LAYERS = ("modeled", "raw")
53
50
 
54
51
  # The five options every command in this subapp takes. Shared instances: typer
55
52
  # reads the option metadata at decoration time, so one constant per flag keeps
@@ -93,7 +90,7 @@ def _validate_choice(value: Optional[str], allowed: "tuple[str, ...]", flag: str
93
90
  raise typer.Exit(EXIT_USAGE)
94
91
 
95
92
 
96
- def _not_found_failure(exc: IssueNotFoundError) -> "typer.Exit":
93
+ def _not_found_failure(exc: IssueNotFoundError | TableDecisionRefusedError) -> "typer.Exit":
97
94
  typer.secho(str(exc), fg=typer.colors.YELLOW, err=True)
98
95
  return typer.Exit(EXIT_VALIDATION_FAILED)
99
96
 
@@ -167,6 +164,7 @@ def list_issues(
167
164
 
168
165
  if not issues:
169
166
  typer.echo("No issues match." if (status or impact or cause or domain) else "No issues on this project.")
167
+ typer.echo(_TABLES_HINT)
170
168
  raise typer.Exit(EXIT_OK)
171
169
 
172
170
  rows = []
@@ -194,6 +192,132 @@ def list_issues(
194
192
  widths = [max(len(row[column]) for row in rows) for column in range(len(rows[0]) - 1)]
195
193
  for row in rows:
196
194
  typer.echo(" ".join([*(cell.ljust(width) for cell, width in zip(row, widths)), row[-1]]))
195
+ typer.echo(_TABLES_HINT)
196
+ raise typer.Exit(EXIT_OK)
197
+
198
+
199
+ tables_app = typer.Typer(help="The warehouse tables users asked for that the context does not describe.")
200
+ app.add_typer(tables_app, name="tables")
201
+
202
+
203
+ @tables_app.callback(invoke_without_command=True)
204
+ def tables(
205
+ ctx: typer.Context,
206
+ layer: Optional[str] = typer.Option(
207
+ None, "--layer", help=f"Only the modeled tables or only the raw ones ({', '.join(LAYERS)})."
208
+ ),
209
+ search: Optional[str] = typer.Option(None, "--search", help="Only the tables whose name contains this text."),
210
+ domain: Optional[str] = typer.Option(
211
+ None, "--domain", help="Only the tables suggested for this domain path or a domain under it."
212
+ ),
213
+ offset: int = typer.Option(0, "--offset", min=0, help="How many tables to skip, to page through the list."),
214
+ limit: int = typer.Option(50, "--limit", min=1, max=200, help="How many tables to print, the most asked first."),
215
+ path: Path = _PATH_OPTION,
216
+ project_id: Optional[str] = _PROJECT_OPTION,
217
+ api_key: Optional[str] = _API_KEY_OPTION,
218
+ api_url: str = _API_URL_OPTION,
219
+ base_path: str = _BASE_PATH_OPTION,
220
+ json_output: bool = typer.Option(False, "--json", help="Print the tables as raw JSON."),
221
+ ) -> None:
222
+ """List the warehouse tables users asked for that the context does not describe, the most asked first.
223
+
224
+ These requests are not issues, so `cassis issues list` does not print
225
+ them: they are one list for the project, one line per table. Prints each
226
+ table's conversations (`x3`), users, layer (`modeled` or `raw`; `-` when
227
+ the project does not draw that line), suggested domain and name. The
228
+ domain is a suggestion: it ends with `?` when it rests on one conversation,
229
+ and reads `-` when the conversations disagree (`--json` carries every
230
+ candidate with its count, and the owners each table goes to). A table
231
+ leaves the list when it is published in the context or when the team sets
232
+ it aside (`cassis issues tables set-aside <TABLE>`).
233
+ Exits 0 on success, 2 on usage errors, 3 on transport/API errors.
234
+ """
235
+ if ctx.invoked_subcommand is not None:
236
+ return
237
+ layer = _validate_choice(layer, LAYERS, "--layer")
238
+ api_key = require_api_key(api_key, api_url)
239
+ project_id = resolve_project_id(project_id, path / Path(base_path), quiet=json_output)
240
+
241
+ try:
242
+ page = get_requested_tables(
243
+ api_url=api_url,
244
+ api_key=api_key,
245
+ project_id=project_id,
246
+ layer=layer,
247
+ search=search,
248
+ domain=domain,
249
+ offset=offset,
250
+ limit=limit,
251
+ )
252
+ except (AuthError, ApiError) as exc:
253
+ raise api_failure(exc) from exc
254
+
255
+ if json_output:
256
+ typer.echo(json.dumps(page, indent=2))
257
+ raise typer.Exit(EXIT_OK)
258
+
259
+ items = page["items"]
260
+ if not items:
261
+ typer.echo("No table to add.")
262
+ raise typer.Exit(EXIT_OK)
263
+
264
+ rows = []
265
+ for table in items:
266
+ domain = table.get("suggested_domain")
267
+ candidates = table.get("candidate_domains") or []
268
+ # A suggestion that one conversation carries is weak: say so on the line.
269
+ weak = (
270
+ bool(domain) and not table.get("filed_by_team") and candidates and candidates[0].get("conversations") == 1
271
+ )
272
+ rows.append(
273
+ [
274
+ f"x{table.get('conversations') or 0}",
275
+ f"users {table.get('users') or 0}",
276
+ str(table.get("layer") or "-"),
277
+ f"{domain}?" if weak else str(domain or "-"),
278
+ str(table.get("name")),
279
+ ]
280
+ )
281
+ widths = [max(len(row[column]) for row in rows) for column in range(len(rows[0]) - 1)]
282
+ for row in rows:
283
+ typer.echo(" ".join([*(cell.ljust(width) for cell, width in zip(row, widths)), row[-1]]))
284
+ more = int(page.get("total") or 0) - offset - len(items)
285
+ if more > 0:
286
+ typer.echo(f"{more} more (--offset {offset + len(items)}).")
287
+ raise typer.Exit(EXIT_OK)
288
+
289
+
290
+ @tables_app.command("set-aside")
291
+ def set_aside_table(
292
+ table: str = typer.Argument(..., help="SCHEMA.TABLE, as `cassis issues tables` prints it."),
293
+ undo: bool = typer.Option(False, "--undo", help="Take the table back into the list."),
294
+ path: Path = _PATH_OPTION,
295
+ project_id: Optional[str] = _PROJECT_OPTION,
296
+ api_key: Optional[str] = _API_KEY_OPTION,
297
+ api_url: str = _API_URL_OPTION,
298
+ base_path: str = _BASE_PATH_OPTION,
299
+ ) -> None:
300
+ """Record that the team will not add a requested table to the context, or take that back with `--undo`.
301
+
302
+ The table leaves `cassis issues tables` for everyone on the project. A
303
+ table you add needs no command: once the pull request that describes it
304
+ is merged and published, it leaves the list on its own. Requires the
305
+ editor or admin role. Exits 0 on success, 1 when the table is not in the
306
+ list, 2 on usage errors, 3 on transport/API errors.
307
+ """
308
+ api_key = require_api_key(api_key, api_url)
309
+ project_id = resolve_project_id(project_id, path / Path(base_path))
310
+ try:
311
+ post_requested_table_decision(
312
+ api_url=api_url, api_key=api_key, project_id=project_id, table=table, set_aside=not undo
313
+ )
314
+ except TableDecisionRefusedError as exc:
315
+ raise _not_found_failure(exc) from exc
316
+ except (AuthError, ApiError) as exc:
317
+ raise api_failure(exc) from exc
318
+ name = table.strip().upper()
319
+ message = f"{name} is back in the list of tables to add." if undo else f"{name} is set aside."
320
+ typer.secho(f"✓ {message}", fg=typer.colors.GREEN)
197
321
  raise typer.Exit(EXIT_OK)
198
322
 
199
323
 
@@ -493,175 +617,3 @@ def reopen(
493
617
  api_url=api_url,
494
618
  base_path=base_path,
495
619
  )
496
-
497
-
498
- _TERMINAL_ANALYSIS_STATUSES = frozenset({"completed", "failed", "cancelled"})
499
-
500
-
501
- @app.command()
502
- def analyze(
503
- path: Path = _PATH_OPTION,
504
- project_id: Optional[str] = _PROJECT_OPTION,
505
- api_key: Optional[str] = _API_KEY_OPTION,
506
- api_url: str = _API_URL_OPTION,
507
- base_path: str = _BASE_PATH_OPTION,
508
- wait: bool = typer.Option(
509
- True,
510
- "--wait/--no-wait",
511
- help="Wait for the analysis to finish and print its summary (default), or just print the run id.",
512
- ),
513
- poll_interval: float = typer.Option(5.0, "--poll-interval", help="Seconds between status polls."),
514
- timeout: float = typer.Option(1800.0, "--timeout", help="Give up waiting after this many seconds."),
515
- json_output: bool = typer.Option(False, "--json", help="Print the final run record as raw JSON."),
516
- ) -> None:
517
- """Analyze the conversations nobody has analyzed yet, turning what went wrong into issues.
518
-
519
- The same pass as the webapp's "Analyze conversations" button — it runs on
520
- Cassis's workers, so a Ctrl-C or a lost connection never kills it — started
521
- on demand instead of waiting for the nightly one. When every conversation is
522
- already analyzed the command is a no-op and exits 0, so a job re-running it
523
- on a quiet project stays green. Exits 0 when the run completes, 1 when it
524
- fails or is cancelled, 2 on usage errors, 3 on transport errors, when a run
525
- is already in flight, or on --timeout (the run keeps going server-side).
526
- Ctrl-C cancels the run and exits 130.
527
- """
528
- api_key = require_api_key(api_key, api_url)
529
- project_id = resolve_project_id(project_id, path / Path(base_path), quiet=json_output)
530
-
531
- try:
532
- run = post_issue_analysis_start(api_url=api_url, api_key=api_key, project_id=project_id)
533
- except NothingToAnalyzeError as exc:
534
- if json_output:
535
- typer.echo(json.dumps({"run": None, "message": str(exc)}, indent=2))
536
- else:
537
- typer.echo(str(exc))
538
- raise typer.Exit(EXIT_OK) from exc
539
- except (AuthError, ApiError) as exc: # covers IssueAnalysisActiveError too
540
- raise api_failure(exc) from exc
541
-
542
- run_id = str(run["id"])
543
- total = int(run.get("total_chats") or 0)
544
-
545
- if not wait:
546
- if json_output:
547
- typer.echo(json.dumps({"run": run}, indent=2))
548
- else:
549
- typer.echo(f"Analysis run {run_id} started: {total} conversation(s) to analyze.")
550
- typer.echo("It keeps going server-side; the results land on the webapp's Issues page.")
551
- raise typer.Exit(EXIT_OK)
552
-
553
- if not json_output:
554
- typer.echo(f"Analysis run {run_id} started: {total} conversation(s) to analyze.")
555
-
556
- try:
557
- final_run = _wait_for_analysis(
558
- api_url=api_url,
559
- api_key=api_key,
560
- project_id=project_id,
561
- run_id=run_id,
562
- poll_interval=poll_interval,
563
- timeout=timeout,
564
- quiet=json_output,
565
- )
566
- except KeyboardInterrupt:
567
- # To stderr under --json: stdout is the machine's, and these lines would
568
- # land in front of the JSON document a caller is parsing.
569
- typer.echo("", err=json_output)
570
- typer.echo("Interrupted — cancelling the analysis...", err=json_output)
571
- try:
572
- post_issue_analysis_cancel(api_url=api_url, api_key=api_key, project_id=project_id, run_id=run_id)
573
- typer.echo("Analysis cancelled. Conversations analyzed so far keep their occurrences.", err=json_output)
574
- except ApiError as exc:
575
- typer.secho(f"Could not cancel the analysis: {exc}", fg=typer.colors.RED, err=True)
576
- raise typer.Exit(EXIT_INTERRUPTED)
577
-
578
- if json_output:
579
- typer.echo(json.dumps({"run": final_run}, indent=2))
580
- else:
581
- _print_analysis_outcome(final_run)
582
-
583
- if final_run.get("status") == "completed":
584
- raise typer.Exit(EXIT_OK)
585
- raise typer.Exit(EXIT_VALIDATION_FAILED)
586
-
587
-
588
- def _wait_for_analysis(
589
- *,
590
- api_url: str,
591
- api_key: str,
592
- project_id: str,
593
- run_id: str,
594
- poll_interval: float,
595
- timeout: float,
596
- quiet: bool,
597
- ) -> dict[str, Any]:
598
- """Poll the run until terminal and return its final record.
599
-
600
- Exits 3 directly on timeout, on an auth failure (fail fast — retrying a
601
- revoked key can't succeed), or after several consecutive poll failures.
602
- The server-side run keeps going in all three cases.
603
- """
604
- last_line = {"text": ""}
605
-
606
- def fetch() -> "dict[str, Any]":
607
- try:
608
- return get_issue_analysis_run(api_url=api_url, api_key=api_key, project_id=project_id, run_id=run_id)
609
- except IssueNotFoundError as exc:
610
- # The run is gone (purged): nothing to keep polling for.
611
- raise _not_found_failure(exc) from exc
612
-
613
- def on_progress(run: "dict[str, Any]") -> None:
614
- line = (
615
- f"{run.get('chats_analyzed', 0)}/{run.get('total_chats', 0)} conversations analyzed — "
616
- f"{run.get('occurrences_created', 0)} occurrence(s) found"
617
- )
618
- if not quiet and line != last_line["text"]:
619
- typer.echo(line)
620
- last_line["text"] = line
621
-
622
- def on_auth_error(exc: AuthError) -> None:
623
- typer.secho(f"{exc} The analysis keeps going server-side.", fg=typer.colors.RED, err=True)
624
-
625
- def on_give_up(exc: ApiError, failures: int) -> None:
626
- typer.secho(
627
- f"Polling failed {failures} times in a row ({exc}). "
628
- "Giving up — the analysis keeps going server-side; see the webapp's Issues page.",
629
- fg=typer.colors.RED,
630
- err=True,
631
- )
632
-
633
- def on_timeout(_run: "dict[str, Any]") -> None:
634
- typer.secho(
635
- f"Timed out after {timeout:g}s waiting for analysis run {run_id}. "
636
- "The analysis keeps going server-side — see the webapp's Issues page.",
637
- fg=typer.colors.YELLOW,
638
- err=True,
639
- )
640
-
641
- return poll_until(
642
- fetch,
643
- lambda run: run.get("status") in _TERMINAL_ANALYSIS_STATUSES,
644
- poll_interval=poll_interval,
645
- timeout=timeout,
646
- on_timeout=on_timeout,
647
- on_progress=on_progress,
648
- on_auth_error=on_auth_error,
649
- on_retry=echo_poll_retry,
650
- on_give_up=on_give_up,
651
- )
652
-
653
-
654
- def _print_analysis_outcome(run: dict[str, Any]) -> None:
655
- status = run.get("status")
656
- if status == "completed":
657
- typer.echo("")
658
- typer.echo(
659
- f"Analysis complete: {run.get('chats_analyzed', 0)} conversation(s) analyzed, "
660
- f"{run.get('occurrences_created', 0)} occurrence(s) found, "
661
- f"{run.get('issues_touched', 0)} issue(s) created or updated."
662
- )
663
- typer.echo("Review them with `cassis issues list`.")
664
- elif status == "cancelled":
665
- typer.secho("Analysis cancelled before it finished.", fg=typer.colors.YELLOW, err=True)
666
- else:
667
- typer.secho(f"Analysis failed: {run.get('error') or 'unknown error'}", fg=typer.colors.RED, err=True)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cassis-cli"
3
- version = "3.7.0"
3
+ version = "3.9.0"
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