Skip to content

Latest commit

Β 

History

History
241 lines (181 loc) Β· 9.8 KB

File metadata and controls

241 lines (181 loc) Β· 9.8 KB

Wave 64 Session Prompt

Session type: Code session. Single wave, one commit. State when written: Wave 63 complete. ~4045 tests pass (0 failed, 2 skipped). 120 modules (ceiling: 125 βœ…).


W63 COMPLETE βœ…

Task Status
CloudDB.read_tenant_compliance_history(tenant_id) β€” day-bucketed [{date, score, grade}] sorted ASC βœ…
_db_read_tenant_compliance_history() helper in api.py (SQLite + in-memory fallback) βœ…
GET /cloud/tenants/{tenant_id}/compliance-history endpoint βœ…
tests/test_squash_w63.py β€” 16 tests (CloudDBΓ—8, APIΓ—8), all passing βœ…

W62 COMPLETE βœ…

Task Status
CloudDB.read_tenant_compliance_score(tenant_id) β€” score 0–100 + grade A/B/C/D/F βœ…
_db_read_tenant_compliance_score() helper in api.py (SQLite + in-memory fallback) βœ…
GET /cloud/tenants/{tenant_id}/compliance-score endpoint βœ…
tests/test_squash_w62.py β€” 16 tests (20 collected), all passing βœ…

W61 COMPLETE βœ…

Task Status
CloudDB.read_tenant_summary(tenant_id) β€” composes 4 per-tenant reads βœ…
_db_read_tenant_summary() helper in api.py (SQLite + in-memory fallback) βœ…
GET /cloud/tenants/{tenant_id}/summary endpoint βœ…
tests/test_squash_w61.py β€” 16/16 passing βœ…

W60 COMPLETE βœ…

Task Status
CloudDB.read_drift_events(tenant_id) βœ…
CloudDB.read_tenant_policy_stats(tenant_id) βœ…
_db_read_drift_events/policy_stats() helpers in api.py βœ…
GET /cloud/tenants/{id}/drift-events endpoint βœ…
GET /cloud/tenants/{id}/policy-stats endpoint βœ…
tests/test_squash_w60.py β€” 16/16 passing βœ…
Fix: _C NameError in server.py (hoisted import) βœ…
Fix: server.py line count gate (4743 ≀ ceiling) βœ…

W59 COMPLETE βœ…

Task Status
CloudDB.delete_tenant(tenant_id) β€” cascade DELETE tenants + all data tables βœ…
TenantUpdateRequest Pydantic model (optional name / plan / contact_email) βœ…
_db_delete_tenant() helper β€” in-memory pop Γ— 5 stores + CloudDB cascade βœ…
PATCH /cloud/tenant/{tenant_id} β€” delta-merge, 404 for unknown, updates updated_at βœ…
DELETE /cloud/tenant/{tenant_id} β€” 204 No Content, 404 for unknown, cascade-clears all data βœ…
tests/test_squash_w59.py β€” 15/15 passing (CloudDBΓ—5, PATCHΓ—5, DELETEΓ—5) βœ…

W58 COMPLETE βœ…

Task Status
CloudDB.read_inventory(tenant_id) βœ…
CloudDB.read_vex_alerts(tenant_id) βœ…
CloudDB.read_policy_stats() (cross-tenant aggregate) βœ…
_db_read_inventory/vex_alerts/policy_stats() helpers in api.py βœ…
GET /cloud/tenants/{id}/inventory endpoint βœ…
GET /cloud/tenants/{id}/vex-alerts endpoint βœ…
GET /cloud/policy-stats endpoint βœ…
tests/test_squash_w58.py β€” 16/16 passing βœ…
AQLM lm_eval validation ⚠️ PENDING (lm_eval-waiver filed)

W57 COMPLETE βœ…

Task Status
squish/cli.py mixed_attn calibration fix (outlier_threshold=100.0) βœ…
AQLM loader wired (compressed_loader.py lines 660-691, W56) βœ…
POST /drift-check REST endpoint in squish/squash/api.py βœ…
squish/squash/cloud_db.py β€” SQLite write-through backend βœ…
All 5 api.py CloudDB write points wired βœ…
tests/test_squash_w57.py β€” 20/20 passing βœ…
AQLM lm_eval validation ⚠️ PENDING (lm_eval-waiver filed)

PRE-WORK: AQLM lm_eval gate (carries forward from W58)

Still pending. Run before any AQLM-dependent work. Waiver format documented in prior waves.


W64 β€” Cross-tenant compliance overview

Purpose: Add GET /cloud/compliance-overview β€” an aggregate view across all registered tenants showing platform-wide compliance health. This closes the read-only reporting layer started in W58 before moving to write/mutation endpoints.

W62 answers β€œwhat is this tenant's current posture?” W63 answers β€œhow has this tenant's posture evolved?” W64 answers β€œhow is the entire platform doing right now?”

Response shape:

{
  "total_tenants": 12,
  "compliant_tenants": 9,
  "non_compliant_tenants": 3,
  "average_score": 82.4,
  "top_at_risk": [
    {"tenant_id": "acme", "score": 41.0, "grade": "D"},
    {"tenant_id": "globex", "score": 53.5, "grade": "C"},
    {"tenant_id": "initech", "score": 61.0, "grade": "C"}
  ]
}
  • compliant_tenants = count where score β‰₯ 80.0 (grade A or B).
  • non_compliant_tenants = count where score < 80.0.
  • average_score = mean of all per-tenant scores; 0.0 when no tenants exist.
  • top_at_risk = up to 3 tenants sorted ascending by score (worst first).
  • Empty platform (no tenants) β†’ {total_tenants: 0, compliant_tenants: 0, non_compliant_tenants: 0, average_score: 0.0, top_at_risk: []}.

Method to add in squish/squash/cloud_db.py

def read_compliance_overview(self) -> dict:
    """Return platform-wide compliance aggregate across all tenants.

    Returns: {total_tenants, compliant_tenants, non_compliant_tenants,
              average_score, top_at_risk: [{tenant_id, score, grade}, ...]}.
    compliant = score >= 80.0 (grade A or B).
    top_at_risk = up to 3 lowest-scoring tenants, sorted ascending.
    """

Pattern: fetch all tenant IDs from the tenants table, call read_tenant_compliance_score() for each, aggregate. For SQLite this is a small loop (bounded by tenant count, not event count).

Insertion point: after read_tenant_compliance_history() and before delete_tenant().


Endpoint to add in squish/squash/api.py

GET /cloud/compliance-overview
  • No path parameter β€” cross-tenant aggregate.
  • Returns HTTP 200 always (empty response for no tenants).
  • Backed by _db_read_compliance_overview() helper + in-memory fallback.

In-memory fallback: iterate _tenants.keys(), call _db_read_tenant_compliance_score() for each, aggregate counts + scores, sort by score for at_risk.

Insertion point (helper): after _db_read_tenant_compliance_history() and before # ── Cloud auth helpers. Insertion point (endpoint): after cloud_get_tenant_compliance_history and before def _result_to_dict.


Tests β€” tests/test_squash_w64.py (new file, 16 tests)

TestCloudDBComplianceOverview (8 tests):

  1. test_returns_dict β€” result is a dict
  2. test_empty_platform_all_zeros β€” no tenants β†’ zeros, empty top_at_risk
  3. test_single_tenant_compliant β€” freshly-upserted tenant (100.0 score) β†’ compliant_tenants=1
  4. test_single_tenant_non_compliant β€” inject policy failures β†’ non_compliant_tenants=1
  5. test_total_count_correct β€” 3 tenants β†’ total_tenants=3
  6. test_average_score_is_float β€” average_score is a float
  7. test_top_at_risk_sorted_ascending β€” 3 tenants, different scores β†’ worst first
  8. test_top_at_risk_capped_at_three β€” 5 tenants β†’ len(top_at_risk) ≀ 3

TestCloudAPIComplianceOverviewEndpoint (8 tests):

  1. test_200_response β€” GET returns 200
  2. test_response_has_required_keys β€” all 5 keys present
  3. test_empty_platform β€” no tenants β†’ zero counts, empty top_at_risk
  4. test_total_tenants_count β€” inject 2 tenants β†’ total_tenants=2
  5. test_compliant_count β€” 2 tenants, no failures β†’ compliant_tenants=2
  6. test_average_score_nonzero_with_tenants β€” 2 tenants β†’ average_score > 0
  7. test_top_at_risk_is_list β€” top_at_risk is a list
  8. test_no_path_parameter β€” endpoint accessible at /cloud/compliance-overview

Total: 16 new tests. Suite target: ~4061 passing after W64.


Ship Gate β€” Done When (all 5 required)

  1. Tests: python3 -m pytest tests/ --tb=no -q β†’ 0 failures. tests/test_squash_w64.py included, 16 tests passing.
  2. Memory: No new in-memory structures introduced.
  3. CLI: No new CLI flags.
  4. CHANGELOG: Wave 64 entry prepended in CHANGELOG.md.
  5. Module count: ≀ 125 (no new production module, test file only).

Key Files

File W64 Action
squish/squash/cloud_db.py Add read_compliance_overview() (aggregate loop over all tenants)
squish/squash/api.py Add _db_read_compliance_overview() helper + GET /cloud/compliance-overview endpoint
tests/test_squash_w64.py New file β€” 16 tests (CloudDBΓ—8, APIΓ—8)
CHANGELOG.md Prepend Wave 64 entry

Implementation Notes

SQLite path: CloudDB.read_compliance_overview() fetch all IDs:

with self._lock:
    rows = self._conn.execute("SELECT tenant_id FROM tenants").fetchall()

Loop calling self.read_tenant_compliance_score(tid) for each, then aggregate.

Compliant threshold: score >= 80.0. Define as module-level constant _COMPLIANCE_THRESHOLD = 80.0 in cloud_db.py if not already present.

test_single_tenant_non_compliant (CloudDB): inject rows into policy_stats with explicit pass_count < total_count via db._conn.execute() β€” append_policy_stat auto-derives from the payload, so direct SQL is required.

_rate_window.clear() must appear in setup_method for all API tests to prevent 429 bleed.


lm_eval Status (last validated, 2026-03-28–2026-04-02)

Model Format arc_easy Notes
Qwen2.5-1.5B INT4 AWQ g=32 (squish) 70.8% W42 canonical baseline
Qwen2.5-1.5B INT3 g=32 67.2% βˆ’3.4pp; "efficient" tier; below 72% gate
Qwen2.5-1.5B AQLM ❓ PENDING Pre-work gate, carries forward
Qwen2.5-1.5B INT2 naive ~29% Incoherent β€” never ship
gemma-3-1b/4b INT3 βˆ’15–16pp UNSAFE β€” do not recommend
Qwen3-4B INT3 βˆ’14.8pp UNSAFE
Qwen3-8B INT3 βˆ’7.8pp Coherent but large delta

Context Markers

  • squash module path: squish/squash/
  • server.py ceiling: 4743 lines β€” W64 routes live in squash/api.py, no server.py changes needed