Support isolated billing workspaces - #57
Merged
Merged
Conversation
Allow one running server to hold several fully isolated billing datasets so parallel test suites no longer have to restart the server or reset shared state between runs. Requests select a workspace with the X-Billtap-Workspace header or the workspace query parameter; unselected requests keep using the backward-compatible default workspace backed by the configured database_url. Named workspaces open their own SQLite database lazily under a workspaces/ directory and get an independent API handler, so customers, invoices, webhooks, idempotency keys, and test clocks are all isolated. GET /workspaces lists the known workspaces. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reflect the new isolated-workspace feature across the design docs and the product spec: testing isolation guidance, the storage architecture note, functional requirement FR-010, non-functional requirement NFR-008, the API contract Workspaces section, the data-model scoping note, and tasks T147. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
요약
하나의 실행 중인 Billtap 서버가 완전히 격리된 여러 billing 데이터셋을 보유할 수 있도록 멀티 워크스페이스를 추가했습니다. 병렬 테스트 스위트가 더 이상 서버를 재시작하거나 공유 상태를 리셋하지 않고도 각자 독립된 데이터셋을 쓸 수 있습니다.
동작 방식
database_url로 백킹되는default워크스페이스를 사용 — 기존 통합은 무수정 동작.X-Billtap-Workspace헤더 또는?workspace=쿼리 파라미터. 해석된 이름은X-Billtap-Workspace응답 헤더로 에코.<dir>/workspaces/<name>.db에 자체 SQLite DB를 lazy하게 열고 독립 API 핸들러를 받음 → 고객·인보이스·웹훅·멱등성 키·test_clock까지 완전 격리../-/_, 선두는 영숫자, 대소문자 무시. 잘못된 이름은 400.GET /workspaces— 알려진 워크스페이스 목록(메모리 + 디스크 스캔).변경 파일
internal/server/workspace.go(신규) —workspaceManager: 워크스페이스 해석, lazy 스토어 오픈, 디스패치, 목록internal/server/server.go—/v1/·/api/를 워크스페이스 디스패처로 마운트,buildAPIHandler추출,GET /workspaces,Close()추가cmd/billtap/main.go— 종료 시 lazy 워크스페이스 스토어 정리internal/server/workspace_test.go(신규) — 격리·헤더·쿼리·목록·DSN 테스트README.md/CHANGELOG.md— Workspaces 문서검증
go build ./...,go vet ./...,go test ./...전체 통과/workspaces목록, DSN 파생알려진 제한
대시보드 및 호스티드 checkout/portal UI는 프론트엔드가 워크스페이스 헤더를 보내지 않는 한
default워크스페이스를 봅니다. API를 직접 호출하는 테스트는 완전 격리됩니다. UI 워크스페이스 인지는 후속 작업입니다.🤖 Generated with Claude Code