Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions .squad/agents/bunk/history.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ RoutingPolicyEndpoints.ValidateDeployments skips validation when Foundry is empt

<!-- Active learnings from ongoing work below -->

### 2026-05-21 — Non-AI API Limits Test Plan Draft

- Non-AI API limits should extend the existing endpoint-pattern tests in `src/AIPolicyEngine.Tests/EndpointTests.cs`, especially the current `CreatePlan_*`, `UpdatePlan_*`, `Precheck_*`, and `Precheck_RpmLimitExceeded_Returns429OnSecondRequest` cases.
- Cache/persistence and regression coverage should mirror `src/AIPolicyEngine.Tests/Integration/CosmosPersistenceResilienceTests.cs` and `src/AIPolicyEngine.Tests/Integration/PrecheckRoutingIntegrationTests.cs`; a dedicated `PrecheckRest` integration class will likely be cleaner than overloading the current AI routing tests.
- Reuse `src/AIPolicyEngine.Tests/ChargebackApiFactory.cs` and `src/AIPolicyEngine.Tests/FakeRedis.cs`, but add helpers for non-AI RPM key seeding, `NonAiCurrentPeriodRequests` state, and preferably a controllable clock seam for minute and billing-period rollover tests.
- Key open questions raised while drafting: final endpoint contract (`/api/precheck-rest` + `/api/log-rest` in McNulty's proposal), whether `0` means unlimited, whether monthly rejection is `429` or `403`, how rejected requests mutate counters, and what fallback behavior applies when plan reads fail.

**What:** Wrote 36 unit tests across 3 test files for the Phase 0 storage migration architecture:
- `src/Chargeback.Tests/Repositories/CachedRepositoryTests.cs` — 16 tests covering cache hit, cache miss, write-through, delete, eviction recovery, Cosmos failure, Redis failure, null handling, cancellation
- `src/Chargeback.Tests/Repositories/CacheWarmingServiceTests.cs` — 10 tests covering happy path, Redis unavailable (logs warning, doesn't fail), Cosmos unavailable (fails startup), empty state, cancellation
Expand Down Expand Up @@ -436,3 +443,110 @@ When writing tests for deployed infrastructure:
4. Use fail-open patterns for transient service-to-service auth issues (role assignments may be pending).

**Captured in Skill:** `.squad/skills/azd-terraform-large-deployment/SKILL.md` — Full guide for auth alignment, provider configuration, timing, troubleshooting, validation patterns.

### 2026-05-21 — APIM Management Backend Test Coverage (M1–M3)

- APIM backend tests live cleanly under `src/AIPolicyEngine.Tests/ApimManagement/` and mix two patterns: NSubstitute for service seams (`IApimCatalogService`) plus small in-memory fakes for `IPolicyAssignmentRepository` when state-transition assertions matter more than call verification.
- For endpoint integration, keep the real `ApimPolicyApplyService` + real `TemplateLibraryService`, but override `IApimCatalogService`, `IPolicyAssignmentRepository`, and the `Channel<ApimPolicyApplyWorkItem>` in `ChargebackApiFactory.WithWebHostBuilder(...)`; also remove `ApimPolicyApplyBackgroundService` so startup replay does not interfere with assertions.
- For Azure.ResourceManager/APIM coverage, mock at Freamon's interface seam instead of the SDK surface. Treat `IApimCatalogService` as the unit-test boundary for apply/clear/status tests; save recorded Azure fixtures for a later live-APIM pass.
- Template rendering edge cases discovered: unknown params hard-fail, required params hard-fail, numeric strings are accepted for `int`, defaults are applied when declared, repeated placeholders all replace, and `{{ Name }}` whitespace variants are left literal because only exact `{{Name}}` tokens are recognized.
- The shipped APIM templates contain policy-expression syntax (`As<string>`, nested quotes, leading comments) that `XDocument.Parse` rejects even though the templates are otherwise usable for APIM management scenarios. Template validation had to be relaxed to root-tag checks so M1–M3 tests can exercise real shipped templates.
### 2026-05-21 — Cross-Agent Note: React Render-Loop Debugging & Apis.tsx Test Coverage

**From:** Kima (UI Developer)
**Note:** New skill available: .squad/skills/react-render-loop-debugging/SKILL.md — documents the pattern and fix for infinite render loops caused by callbacks with circular dependencies on the very state they modify.

**Action for Bunk:** Consider adding render-loop guard test coverage to src/aipolicyengine-ui/src/pages/Apis.tsx (e.g., assertion that the fetch function is called ≤ N times during mount/load). This would catch future regressions where the component re-fetches more than expected. Pattern: wrap render in ct(), mount component, spy on fetch function, verify call count ≤ expected threshold.

**Context:** Kima fixed an infinite re-fetch loop in Apis.tsx by stabilizing the loadInitialData callback and reading latest state via a ref. See decisions.md entry 2026-05-21T18:35:00Z for full decision.

### 2026-05-21 — Cross-Agent Note: Tailwind Flex/Truncate Pattern for UI Components

**From:** Kima (UI Developer)
**Note:** New skill available: `.squad/skills/tailwind-flex-truncate-pattern/SKILL.md` — documents layout pattern combining `min-w-0`, `flex-shrink-0`, `flex-1`, and `truncate` for preventing row/card overflow in flex containers and handling badge positioning.

**Action for Bunk:** Consider applying this pattern to UI component test coverage (ApiTree.tsx, AssignTemplateForm.tsx) to verify no text overflow regressions when grid resizes or content grows. Pattern examples: responsive badge placement with fixed widths, label truncation with dynamic form fields.

**Context:** Kima fixed `/apis` page layout bugs (ApiTree row overflow, AssignTemplateForm param card overlap, modal horizontal scroll) by applying this Tailwind pattern systematically. Commit `3aeea053` on `seiggy/feature/apim-policy-management`.

### 2026-05-21 — Cross-Agent Note: AAA Architecture M1-M3 Kickoff

**From:** McNulty (Architect) → All agents
**Note:** AAA per-client access-profile architecture APPROVED by Zack. Freamon and Bunk now in-flight on parallel implementation.

**For Bunk:** 21-test matrix in flight — Access Profile resolver cascade logic (6 levels), precheck backward compat guards (with/without apiId), log integration (AccessProfileId/PlanId context flow), template render diffs (all 5 templates), end-to-end cascade flow.

**For Kima:** M6 UI (`/access` page) pending — will start after M3 precheck contract is firm. Page layout: client selector, API grid with per-operation drill-down, assign form with Plan/Routing/Deployment selectors, bulk assign action.

**For Sydnor:** No new Terraform changes expected for AAA work itself — infrastructure is done. M5 template updates are pure APIM policy XML changes (not infrastructure); Sydnor may assist with template version bump and APIM SDK testing if needed.

**Context:** Full architecture at `.squad/decisions/archive/mcnulty-aaa-per-client-arch.md` (387 lines) and pre/post contracts at `.squad/decisions/archive/mcnulty-aaa-pre-post-endpoint-contracts.md` (522 lines). Decisions merged to `.squad/decisions.md` entry 2026-05-21T21:28:06Z.

### 2026-05-21T21:48:19Z — AAA M1-M3 Test Matrix Complete

**Status:** ✅ COMPLETE

**Commits:**
- Bunk 21-test matrix: `6c858b96`

**Delivered:**
- **Resolver unit tests (6):** Operation-specific > API-wide > client-global > legacy fallback cascade levels; disabled profile skip; null edge cases
- **Precheck integration tests (6):** With/without `apiId`/`operationId`; legacy backward compat (no apiId = legacy path); disabled profile handling; AAA response with `allowedDeployments`
- **Log integration tests (4):** PlanId resolution (supplied wins, fallback to legacy assignment); AccessProfileId persistence to audit trail; legacy payload compat
- **End-to-end cascade test (1):** Full precheck → log flow with cascade resolution order
- **Pending M4 template assertions (4 skipped):** Template render (apiId/operationId extraction), precheck URL diffs, log payload diffs, version bump 1.0→1.1

**Test Results:**
- Total: 320
- Succeeded: 312 (↑ +17 from M1-M3 baseline)
- Skipped: 8 (4 pending M4 template assertions, 4 pre-existing)
- Failed: 0

**Key Test Decisions:**
- Resolver fallback logic placed inside service (not endpoint) — aligns with approved test matrix
- ResolvedAccessProfile type alias used for contract clarity
- Legacy precheck path preserved without access-profile metadata
- Plan resolution edge case (mismatched PlanId) not asserted (not in approved matrix)

**Blocked Issues Resolved:**
- Freamon M1-M3 contract firm → all resolver/precheck/log shapes now testable
- Template diffs now visible → Sydnor can proceed with M4 APIM updates
- All assertions passing → M4 and M5 in-flight now unblocked

## 2026-05-21T22:07:10Z — AAA M1-M5 Complete, All 21 Tests Active

**Status:** M1-M3 ✅ Complete (Freamon), M4-M5 ✅ Complete (Sydnor/Kima), All Tests Active

**M4 Completion (Sydnor):**
- All 5 APIM templates updated (v1.0→1.1)
- Commit 24de42b5
- 4 pending M4 template assertions activated and passing
- Template extraction, precheck URL diffs, log payload diffs, version bump all asserted

**M5 Completion (Kima):**
- /access admin page shipped
- Client-first workflow, cascade visualization, shared hooks refactored
- Commit c54c29c

**Test Matrix Final Results:**
- **Total:** 320
- **Passed:** 316 (↑ +4 from M3, template-pending tests now active)
- **Skipped:** 4 (pre-existing Purview seam tests, not M4/M5 related)
- **Failed:** 0

**All 21 AAA Tests Now Active:**
- ✅ M1-M3 integration tests (13): resolver cascade, backward compat, endpoint contracts
- ✅ M4 template assertions (4): Template render, precheck URL diffs, log payload diffs, version bump
- ✅ Additional passing (4): Log integration, end-to-end cascade flow, endpoint contract validation

**Cross-Team Coordination:**
- Freamon M1-M3: Backend fully consumed by UI + templates
- Sydnor M4: APIM templates shipped with metadata propagation
- Kima M5: UI integration complete, shared hooks now reusable

**Deployment Ready:**
- Full AAA layer validated
- All integration paths tested
- Admin workflows functional end-to-end

**Next:** PR review + merge; M6 (Redis caching) deferred as optional optimization
Expand Down
Loading
Loading