Skip to content

feat(enterprise): guard trace cleanup with leases#94

Closed
Gracker wants to merge 1 commit intofeature/enterprise-multi-tenant-tp-supervisorfrom
feature/enterprise-multi-tenant-cleanup-guard
Closed

feat(enterprise): guard trace cleanup with leases#94
Gracker wants to merge 1 commit intofeature/enterprise-multi-tenant-tp-supervisorfrom
feature/enterprise-multi-tenant-cleanup-guard

Conversation

@Gracker
Copy link
Copy Markdown
Owner

@Gracker Gracker commented May 8, 2026

Summary

  • make enterprise /api/traces/cleanup admin-only via trace:delete_any
  • block cleanup with 409 when scoped trace processor leases still have active holders
  • drain/release idle scoped leases before cleanup and clean only processors for current workspace traces
  • record trace_cleanup_blocked and trace_cleanup_completed audit events

Verification

  • cd backend && PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH" npx jest --runInBand src/routes/__tests__/enterpriseTraceMetadataRoutes.test.ts src/services/__tests__/traceProcessorService.test.ts
  • cd backend && PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH" npm run typecheck
  • cd backend && PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH" npm run test:core
  • cd backend && PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH" npm run test:scene-trace-regression
  • PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH" npm run verify:pr
  • git diff --check

@Gracker
Copy link
Copy Markdown
Owner Author

Gracker commented May 9, 2026

已通过 commit 67856ec (merge) + 023a84a (frontend rebuild) 合入 main,关闭此 PR。

@Gracker Gracker closed this May 9, 2026
yun571 pushed a commit to yun571/SmartPerfetto that referenced this pull request May 11, 2026
Land Plan 44 (Spark Gracker#94, Gracker#95) — project / world memory plus the
feedback → case → skill draft pipeline.

Critical invariant: this contract does NOT modify the existing
session-scope `analysisPatternMemory.ts`. Plan 44 introduces an
independent project + world store at runtime
(`backend/src/agentv3/projectMemory.ts`, landed in D-phase). The
existing 200-entry session store, weighted Jaccard matching, and
supersede integration stay untouched.

Types added to `backend/src/types/sparkContracts.ts`:

- `ProjectMemoryStatus` — 5-state status machine inlined to keep
  `backend/src/types/` independent of `backend/src/agentv3/`. Mirrors
  agentv3's PatternStatus including `disputed_late`. Doc note flags
  that the two unions must stay in sync; if agentv3 changes, mirror
  the change here.
- `ProjectMemoryEntry` — one entry. Carries optional `promotionPolicy`;
  the Plan 44 service layer (`projectMemory.saveProjectMemoryEntry`)
  enforces that a `'world'`-scope entry MUST have a policy. Schema
  itself keeps it optional so older snapshots remain readable.
- `FeedbackPipelineEntry` — feedback pipeline state. Uses the shared
  `CaseRef` from C0 base types so this contract does NOT depend on
  Plan 54's CaseNode shape, breaking the Gracker#44Gracker#54 schema cycle that
  Codex flagged in round 1.
- `MemoryRagSelfImprovementContract` — service surface bundling
  entries + pipeline + recent RAG retrievals.

Storage location for project + world entries:
`backend/logs/analysis_project_memory.json` with shape
`{entries: ProjectMemoryEntry[], promotionAudit: ...}`. Audit log
schema is finalized in §4.3 of the design doc.

Five new test cases in `__tests__/sparkContracts.test.ts` cover:

- ProjectMemoryStatus matches the 5-state machine, no `auto_inferred`
- project entry can omit promotionPolicy
- world entry carries promotionPolicy with reviewer for audit
- FeedbackPipelineEntry uses CaseRef shape, not CaseNode
- contract bundles entries + pipeline + recent retrievals

Test count: 55 (was 50).

Test tier: contract / type-only. `npx tsc --noEmit` clean,
sparkContracts.test.ts passes 55/55. Trace regression intentionally
not run per the tiered policy in commit d8529e1.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant