Skip to content

Commit 2bfae6f

Browse files
authored
feat: reorganize Go package into internal/ subtree (v0.4.0) (#75)
* docs: map existing codebase * docs: initialize project * chore: add project config * docs: complete project research * docs: define v1 requirements * docs: create roadmap (5 phases) * docs(01): capture phase context * docs(state): record phase 1 context session * docs(01): research phase domain * docs(phase-1): add validation strategy * docs(01-layout-design): create phase plan * feat(01-01): add skeleton packages for internal/runtime and internal/library - internal/runtime/runtime.go with bare package declaration and doc comment - internal/library/library.go with bare package declaration and doc comment - go build ./internal/... passes * test(01-01): add anchor validation test for internal package imports - internal_test.go at repo root with package chroma_test - Blank-imports internal/runtime and internal/library - Proves root package can import internal/ packages - go build, go vet, golangci-lint all pass * docs(01-01): complete layout-design plan - Add 01-01-SUMMARY.md with execution results - Update STATE.md with phase completion and decisions - Update ROADMAP.md progress table - Mark LAYOUT-01 and LAYOUT-02 requirements complete * docs(phase-01): complete phase execution * docs(phase-01): evolve PROJECT.md after phase completion * docs(02): capture phase context * docs(state): record phase 2 context session * docs(02): research phase domain * docs(phase-02): add validation strategy * docs(02-file-migration): create phase plan * fix(02): add go test -race compile check to 02-02 verify per checker feedback * feat(02-01): move library files to internal/library/ and export LoadLibrary - Move library.go, library_unix.go, library_windows.go, library_test.go from root to internal/library/ - Change package declaration from chroma to library - Export loadLibrary as LoadLibrary (capital L) in platform files - Preserve build tags verbatim (//go:build !windows, //go:build windows) - All types and helpers remain unexported - Delete original root library files * feat(02-01): bridge chroma.go Init() to call library.LoadLibrary - Add import for github.com/amikos-tech/chroma-go-local/internal/library - Change Init() from loadLibrary(libPath) to library.LoadLibrary(libPath) - go build ./... compiles successfully - Platform build tags verified via GOOS=linux and GOOS=windows go list * docs(02-01): complete library file migration plan - Add 02-01-SUMMARY.md with execution results - Update STATE.md with plan position, decisions, and metrics - Mark LAYOUT-04 requirement as complete in REQUIREMENTS.md * feat(02-02): move implementation files to internal/runtime/ with goruntime alias - Move chroma.go, config.go, embedded.go, errors.go, backup.go, rebuild.go, compaction.go, wal_prune.go to internal/runtime/ - Change package declarations from chroma to runtime - Alias stdlib runtime import as goruntime in files that use SetFinalizer/KeepAlive - Transfer Phase 1 skeleton doc comment to chroma.go, delete runtime.go skeleton - Preserve internal/library import bridge from Plan 01 * feat(02-02): move test files to internal/runtime/, fix paths, remove anchor test - Move 11 test files from root to internal/runtime/ with package runtime - Fix shim/Cargo.toml relative path to ../../shim/Cargo.toml in chroma_test.go - Alias stdlib runtime as goruntime in backup_test.go (runtime.GOOS usage) - Remove internal_test.go Phase 1 anchor test - Zero .go files remain at repo root - go build, go vet, go test -race compile check all pass for ./internal/... * docs(02-02): complete runtime file migration plan - Create 02-02-SUMMARY.md with migration results - Update STATE.md with position, decisions, metrics - Update ROADMAP.md with phase 02 plan progress - Mark LAYOUT-03 requirement as complete * docs(phase-02): complete phase execution * docs(phase-02): evolve PROJECT.md after phase completion * docs(phase-02): add/update validation strategy * docs(phase-03): gather context for root facade phase * docs(phase-03): research root facade domain * docs(phase-03): add validation strategy * docs(03-root-facade): create phase plan * feat(03-01): add root facade re-exporting server, config, and error symbols - doc.go: package documentation for chroma - chroma.go: Server, StartServerConfig types and Init, StartServer, Version, VersionWithError - config.go: ServerConfig, ServerOption types and all With* builder functions plus NewServer - errors.go: error code constants and sentinel error variables * docs(03-01): complete root facade plan - Add 03-01-SUMMARY.md with execution results - Update STATE.md with position, decisions, metrics - Update ROADMAP.md with plan progress - Mark FACADE-01 through FACADE-05 complete in REQUIREMENTS.md * feat(03-02): add embedded.go facade with all embedded types and functions - 32 type aliases re-exporting Embedded, EmbeddedConfig, request/response types - 3 constants: DefaultTenantID, DefaultDatabase, DefaultEmbeddedDir - 7 thin wrapper functions: NewEmbedded, StartEmbedded, DefaultEmbeddedConfig, With* options * feat(03-02): add backup, rebuild, compaction, and WAL prune facade files - backup.go: 7 type aliases, 2 mode constants, 4 option wrapper functions - rebuild.go: 2 type aliases, 4 option wrapper functions - compaction.go: 4 type aliases (types only, methods auto-forward) - wal_prune.go: 3 type aliases, 7 option wrapper functions (includes time.Duration import) * docs(03-02): complete embedded and maintenance facade plan - SUMMARY.md with 2 task commits, 5 facade files created - STATE.md advanced to phase 03 complete - ROADMAP.md updated with plan progress * docs(phase-03): complete phase execution * docs(phase-03): evolve PROJECT.md after phase completion * docs(04): capture phase context * docs(state): record phase 4 context session * docs(04): research phase domain * docs(phase-4): add validation strategy * docs(04): create phase plan * fix(04): revise plan 04-03 based on checker feedback * fix(04-01): correct gci import prefix in .golangci.yml - Replace stale prefix(github.com/chaoslabs-bg/tclr-v2/) with prefix(github.com/amikos-tech/chroma-go-local/) * fix(04-01): suppress SA1019 on deprecated type re-exports in backup.go - Add nolint:staticcheck to ServerBackupOptions and EmbeddedBackupOptions type aliases * fix(04-01): reorder imports in chroma.go for corrected gci prefix - Move project import to its own group per gci formatter sections * feat(04-02): add compile-time API surface gate and behavioral smoke tests - compat_test.go with package chroma_test (external test package) - Compile-time var _ references for all exported symbols (54 types, 37 functions, 14 constants, 5 error vars) - 9 behavioral smoke tests: Init, Version, VersionWithError, DefaultServerConfig, NewServer, DefaultEmbeddedConfig, plus option builders for backup, rebuild, WAL prune * docs(04-02): complete compat-test plan - 04-02-SUMMARY.md with execution results - STATE.md updated with position and decisions - ROADMAP.md updated with plan progress - REQUIREMENTS.md marks TEST-02, TEST-03 complete * docs(04-01): complete lint fix plan - Add 04-01-SUMMARY.md with execution results - Update STATE.md with plan progress and decisions - Update ROADMAP.md with phase 04 progress - Mark BUILD-03 requirement complete * fix(04-03): suppress errcheck on deferred server.Stop in compat_test.go - Wrap deferred server.Stop() call to explicitly discard error value * docs(phase-04): update validation strategy with audit results * docs(04-03): complete full verification pass plan - All make targets, lint, cross-compile verified passing - Phase 4 success criteria approved by user - Requirements TEST-01, TEST-04, BUILD-01, BUILD-02, BUILD-04 marked complete * docs(phase-04): complete phase execution and verification * docs(phase-04): evolve PROJECT.md after phase completion * docs(05): capture phase context * docs(state): record phase 5 context session * docs(05): research phase domain * docs(phase-5): add validation strategy * docs(05): create phase plan * docs(05-02): update README, CLAUDE.md, GO_API_SURFACE for internal/ layout - README.md Project Structure shows facade + internal/runtime + internal/library - README.md Architecture section explains thin facade pattern - CLAUDE.md architecture diagram updated with full facade -> internal mapping - CLAUDE.md Key Patterns includes facade pattern code example - GO_API_SURFACE.md note clarifies types defined in internal/, re-exported at root * docs(05-02): create CHANGELOG.md with v0.4.0 release entry - Keep a Changelog format with UNRELEASED date placeholder - Compatibility statement: no breaking changes, zero modifications required - Comparison link to v0.3.4 baseline * feat(05-01): add api-compat CI job for apidiff on PRs to main - New api-compat job runs only on PRs targeting main - Dynamically resolves latest release tag for comparison - Reports as informational warning, not build failure - Writes results to GITHUB_STEP_SUMMARY for visibility - Gracefully skips if no release tags exist * docs(05-02): complete documentation update plan - SUMMARY.md with task commits and self-check - STATE.md updated with position, decisions, metrics - ROADMAP.md updated with phase 05 progress - REQUIREMENTS.md: DOCS-02, DOCS-03, DOCS-04, COMPAT-03 marked complete * docs(05-01): complete API compatibility verification plan - SUMMARY.md: apidiff confirmed 90 type-alias false positives, zero genuine breaking changes - STATE.md: updated position, decisions, metrics - REQUIREMENTS.md: marked DOCS-01, COMPAT-01, COMPAT-02 complete * docs(phase-05): complete phase execution * docs(phase-05): evolve PROJECT.md after phase completion * docs(05): ship phase 05 — PR #75 * fix(ci): ensure api-compat job exits 0 on expected false positives apidiff returns exit code 1 when it detects changes, even though the type-alias false positives are expected. The if/else block handled the output correctly but didn't force exit 0, causing the step to fail. * fix(ci): use stable Go for api-compat job apidiff@latest requires Go 1.25+ but go.mod specifies 1.21. The api-compat job only runs the apidiff tool, not project code, so it can safely use the latest stable Go. * fix: address PR review feedback (compaction comment, dynamic port) - Add comment to compaction.go explaining why it has types only (uses request structs, not variadic option builders) - Replace hardcoded port 9999 in TestNewServer with dynamic port allocation via net.Listen to avoid CI port conflicts
1 parent a683017 commit 2bfae6f

99 files changed

Lines changed: 15350 additions & 3677 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,38 @@ jobs:
296296
java/panama/build/test-results/test/**
297297
java/panama/build/reports/tests/test/**
298298
if-no-files-found: warn
299+
300+
api-compat:
301+
name: API Compatibility Check
302+
if: github.event_name == 'pull_request' && github.base_ref == 'main'
303+
runs-on: ubuntu-latest
304+
steps:
305+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
306+
with:
307+
fetch-depth: 0
308+
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
309+
with:
310+
go-version: stable
311+
cache: true
312+
- name: Run API compatibility check
313+
run: |
314+
go install golang.org/x/exp/cmd/apidiff@latest
315+
LATEST_TAG=$(git tag -l 'v*' --sort=-v:refname | head -1)
316+
if [ -z "$LATEST_TAG" ]; then
317+
echo "No release tags found -- skipping apidiff"
318+
exit 0
319+
fi
320+
echo "Comparing against: $LATEST_TAG"
321+
OLD_DIR=$(go mod download -json "github.com/amikos-tech/chroma-go-local@${LATEST_TAG}" | jq -r .Dir)
322+
cd "$OLD_DIR" && apidiff -w /tmp/old.txt github.com/amikos-tech/chroma-go-local
323+
cd "$GITHUB_WORKSPACE" && apidiff -w /tmp/new.txt github.com/amikos-tech/chroma-go-local
324+
echo "## API Diff (vs $LATEST_TAG)" >> "$GITHUB_STEP_SUMMARY"
325+
if apidiff -incompatible /tmp/old.txt /tmp/new.txt > /tmp/diff.txt 2>&1; then
326+
echo "No incompatible changes detected." >> "$GITHUB_STEP_SUMMARY"
327+
else
328+
echo '```' >> "$GITHUB_STEP_SUMMARY"
329+
cat /tmp/diff.txt >> "$GITHUB_STEP_SUMMARY"
330+
echo '```' >> "$GITHUB_STEP_SUMMARY"
331+
echo "::warning::API changes detected vs $LATEST_TAG - review step summary"
332+
fi
333+
exit 0

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ formatters:
5252
sections:
5353
- standard
5454
- default
55-
- prefix(github.com/chaoslabs-bg/tclr-v2/)
55+
- prefix(github.com/amikos-tech/chroma-go-local/)
5656
- blank
5757
- dot
5858
custom-order: true

.planning/PROJECT.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# chroma-go-local v0.4.0: Go Subtree Reorganization
2+
3+
## What This Is
4+
5+
A structural refactor of the chroma-go-local repository that moves Go implementation code out of the repo root into a dedicated `go/` subtree. This preserves the current public import path (`github.com/amikos-tech/chroma-go-local`) and all API behavior while making Go/Java/Rust ownership boundaries explicit for long-term maintenance.
6+
7+
## Core Value
8+
9+
The public Go import path and API surface must remain 100% backward-compatible — existing users must not need to change any code.
10+
11+
## Requirements
12+
13+
### Validated
14+
15+
- ✓ Pure Go FFI via purego (no cgo) — existing
16+
- ✓ Server mode (HTTP) and Embedded mode (in-process) — existing
17+
- ✓ Builder pattern configuration with YAML backing — existing
18+
- ✓ Explicit resource lifecycle with finalizer fallback — existing
19+
- ✓ Java scaffold bindings (JNA + Panama) — existing
20+
- ✓ Rust FFI shim with C-compatible exports — existing
21+
- ✓ Cross-platform support (Linux, macOS, Windows) — existing
22+
- ✓ WAL prune maintenance APIs — v0.4.0 (#26)
23+
- ✓ Collection rebuild maintenance API — v0.4.0 (#25)
24+
25+
### Active
26+
27+
- ✓ Add thin root facade to preserve import compatibility — Validated in Phase 3
28+
- ✓ Reorganize tests for subtree layout + API compatibility coverage — Validated in Phase 4
29+
- ✓ Update Make/CI for relocated Go package layout — Validated in Phase 4
30+
- ✓ Refresh docs/examples after Go subtree move — Validated in Phase 5
31+
- ✓ Add compatibility gate checklist for root cleanup refactor — Validated in Phase 5
32+
33+
### Validated in Phase 2: File Migration
34+
35+
- ✓ Move Go implementation into `internal/` subtree without breaking imports — all files in `internal/runtime/` and `internal/library/`
36+
37+
### Out of Scope
38+
39+
- New features or API additions — this is purely structural
40+
- Java binding changes — layout remains unchanged
41+
- Rust shim changes — shim stays in `shim/`
42+
- Go module path change — must remain `github.com/amikos-tech/chroma-go-local`
43+
44+
## Context
45+
46+
The current repo has Go implementation files (chroma.go, config.go, embedded.go, errors.go, library.go, backup.go, rebuild.go, compaction.go, wal_prune.go) mixed at the repo root alongside Rust and Java code. This makes long-term maintenance and Java binding expansion harder. The v0.4.0 milestone moves Go implementation into a clean subtree while the root package becomes a thin facade.
47+
48+
GitHub milestone: v0.4.0 (amikos-tech/chroma-go-local milestone #4)
49+
Umbrella issue: #45
50+
Individual issues: #39, #40, #41, #42, #43, #44
51+
52+
## Constraints
53+
54+
- **Import compatibility**: Root module path `github.com/amikos-tech/chroma-go-local` must remain valid
55+
- **API stability**: No public API signature changes allowed
56+
- **Build system**: `make test`, `make lint`, `make test-all` must pass throughout
57+
- **CI**: GitHub Actions workflows must remain green across OS matrix
58+
- **No circular deps**: New package layout must not introduce circular dependencies
59+
60+
## Key Decisions
61+
62+
| Decision | Rationale | Outcome |
63+
|----------|-----------|---------|
64+
| Sequential phases (one issue per phase) | Refactoring has strict dependency chain; each step must be stable before next | — Pending |
65+
| Subtree under `go/` directory | Keeps Go/Java/Rust separation explicit at repo root level | — Pending |
66+
| Root becomes thin facade | Preserves import path without requiring Go module replace directives | — Pending |
67+
| Proposed layout: `go/internal/runtime/`, `go/internal/library/`, etc. | Internal packages prevent unintended external imports | — Pending |
68+
69+
## Current State
70+
71+
- Phase 1 (Layout Design) complete — skeleton packages created
72+
- Phase 2 (File Migration) complete — all Go implementation (8 files) and test files (11 files) moved to `internal/runtime/`, library FFI loading (4 files) moved to `internal/library/`. Zero .go files remain at repo root. Race-instrumented compilation and cross-compile pass.
73+
- Phase 3 (Root Facade) complete — 9 facade files at repo root (doc.go, chroma.go, config.go, errors.go, embedded.go, backup.go, rebuild.go, compaction.go, wal_prune.go) re-export 54 type aliases and ~37 wrapper functions from internal/runtime. Full public API surface restored. `go build ./...` passes including examples.
74+
- Phase 4 (Build and Test) complete — lint clean (gci prefix fixed, SA1019 suppressed), `compat_test.go` created with 110-symbol compile gate + 9 behavioral smoke tests, all make targets pass, cross-compile verified for 3 OS.
75+
- Phase 5 (Compatibility & Docs) complete — apidiff verified zero genuine breaking changes (90 false positives documented), CI api-compat job added, README/CLAUDE.md/GO_API_SURFACE.md updated for internal/ layout, CHANGELOG.md created with v0.4.0 entry.
76+
77+
---
78+
*Last updated: 2026-03-21 after Phase 5 completion*

.planning/REQUIREMENTS.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Requirements: chroma-go-local v0.4.0
2+
3+
**Defined:** 2026-03-20
4+
**Core Value:** Public Go import path and API surface must remain 100% backward-compatible
5+
6+
## v1 Requirements
7+
8+
### Layout Migration
9+
10+
- [x] **LAYOUT-01**: All Go implementation files moved from repo root into `internal/` subtree at module root
11+
- [x] **LAYOUT-02**: Implementation organized into `internal/runtime/` (server, embedded, config, errors) and `internal/library/` (FFI loading, platform shims)
12+
- [x] **LAYOUT-03**: All FFI globals and `sync.Once` initialization moved atomically to implementation package (no split state)
13+
- [x] **LAYOUT-04**: Platform-specific files (`library_unix.go`, `library_windows.go`) retain correct build tags after move
14+
15+
### Import Facade
16+
17+
- [x] **FACADE-01**: Root package exposes all current public types via type aliases (`type X = impl.X`)
18+
- [x] **FACADE-02**: Root package re-exports all public functions via variable assignments or wrapper calls
19+
- [x] **FACADE-03**: Root package re-exports all constants, variables, and error types
20+
- [x] **FACADE-04**: Root package contains zero implementation logic (pure forwarding only)
21+
- [x] **FACADE-05**: Import path `github.com/amikos-tech/chroma-go-local` remains valid and unchanged
22+
23+
### Test Reorganization
24+
25+
- [x] **TEST-01**: Implementation-focused tests moved alongside new internal packages
26+
- [x] **TEST-02**: Public API compatibility tests remain at root level
27+
- [x] **TEST-03**: `compat_test.go` added at root as compile-time API surface gate
28+
- [x] **TEST-04**: `make test` passes with reorganized test layout
29+
30+
### Build & CI
31+
32+
- [x] **BUILD-01**: Makefile targets updated for new package paths (`make test`, `make lint`, `make test-all`)
33+
- [x] **BUILD-02**: CI workflows (`.github/workflows/ci.yml`) updated for new structure
34+
- [x] **BUILD-03**: Stale `gci` prefix in `.golangci.yml` corrected to `github.com/amikos-tech/chroma-go-local/`
35+
- [x] **BUILD-04**: Cross-compile verification passes for `GOOS=windows`, `GOOS=linux`, `GOOS=darwin`
36+
37+
### Docs & Verification
38+
39+
- [x] **DOCS-01**: `go-apidiff` run against v0.3.4 tag confirms zero breaking changes
40+
- [x] **DOCS-02**: README.md updated with new directory layout and build instructions
41+
- [x] **DOCS-03**: CLAUDE.md updated to reflect new architecture
42+
- [x] **DOCS-04**: GO_API_SURFACE.md references updated for new file locations
43+
44+
### Compatibility Gate
45+
46+
- [x] **COMPAT-01**: Explicit compatibility checklist completed before merge
47+
- [x] **COMPAT-02**: No import-path break for current users verified
48+
- [x] **COMPAT-03**: Release notes include refactor summary and compatibility statement
49+
50+
## v2 Requirements
51+
52+
### Future Improvements
53+
54+
- **FUTURE-01**: Verify `pkg.go.dev` rendering of type aliases to internal paths
55+
- **FUTURE-02**: Evaluate `go-apidiff` as permanent CI gate for future releases
56+
57+
## Out of Scope
58+
59+
| Feature | Reason |
60+
|---------|--------|
61+
| New API features or methods | This is purely structural; new features belong to future milestones |
62+
| Java binding layout changes | Java layout stays in `java/`; not part of this refactor |
63+
| Rust shim changes | Shim stays in `shim/`; no code changes needed |
64+
| Go module path change | Must remain `github.com/amikos-tech/chroma-go-local` |
65+
| Second `go.mod` under `go/` | Creates separate module requiring `replace` directives; breaks published module |
66+
67+
## Traceability
68+
69+
| Requirement | Phase | Status |
70+
|-------------|-------|--------|
71+
| LAYOUT-01 | Phase 1 | Complete |
72+
| LAYOUT-02 | Phase 1 | Complete |
73+
| LAYOUT-03 | Phase 2 | Complete |
74+
| LAYOUT-04 | Phase 2 | Complete |
75+
| FACADE-01 | Phase 3 | Complete |
76+
| FACADE-02 | Phase 3 | Complete |
77+
| FACADE-03 | Phase 3 | Complete |
78+
| FACADE-04 | Phase 3 | Complete |
79+
| FACADE-05 | Phase 3 | Complete |
80+
| TEST-01 | Phase 4 | Complete |
81+
| TEST-02 | Phase 4 | Complete |
82+
| TEST-03 | Phase 4 | Complete |
83+
| TEST-04 | Phase 4 | Complete |
84+
| BUILD-01 | Phase 4 | Complete |
85+
| BUILD-02 | Phase 4 | Complete |
86+
| BUILD-03 | Phase 4 | Complete |
87+
| BUILD-04 | Phase 4 | Complete |
88+
| DOCS-01 | Phase 5 | Complete |
89+
| DOCS-02 | Phase 5 | Complete |
90+
| DOCS-03 | Phase 5 | Complete |
91+
| DOCS-04 | Phase 5 | Complete |
92+
| COMPAT-01 | Phase 5 | Complete |
93+
| COMPAT-02 | Phase 5 | Complete |
94+
| COMPAT-03 | Phase 5 | Complete |
95+
96+
**Coverage:**
97+
- v1 requirements: 24 total
98+
- Mapped to phases: 24
99+
- Unmapped: 0
100+
101+
---
102+
*Requirements defined: 2026-03-20*
103+
*Last updated: 2026-03-20 after roadmap creation*

.planning/ROADMAP.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Roadmap: chroma-go-local v0.4.0 — Go Subtree Reorganization
2+
3+
## Overview
4+
5+
A strictly sequential structural refactor: move all Go implementation files from the repo root into `internal/runtime/` and `internal/library/` subtrees, then restore the root package as a pure-forwarding facade. Each phase must be green before the next begins — the dependency chain is irreversible. The public import path `github.com/amikos-tech/chroma-go-local` and every exported symbol must be identical from a caller's perspective before and after.
6+
7+
## Phases
8+
9+
**Phase Numbering:**
10+
- Integer phases (1, 2, 3): Planned milestone work
11+
- Decimal phases (2.1, 2.2): Urgent insertions (marked with INSERTED)
12+
13+
Decimal phases appear between their surrounding integers in numeric order.
14+
15+
- [x] **Phase 1: Layout Design** - Lock directory structure, create skeleton packages, confirm `internal/` is anchored at module root
16+
- [ ] **Phase 2: File Migration** - Move all Go implementation files into `internal/runtime/` and `internal/library/`, co-locate tests
17+
- [ ] **Phase 3: Root Facade** - Write thin facade at repo root that re-exports every public symbol via type aliases and function vars
18+
- [ ] **Phase 4: Build and Test** - Update Makefile, CI, lint config, and test layout; verify all `make` targets and cross-compile pass
19+
- [ ] **Phase 5: Compatibility and Docs** - Run `go-apidiff` against v0.3.4, add `compat_test.go`, update CLAUDE.md and docs
20+
21+
## Phase Details
22+
23+
### Phase 1: Layout Design
24+
**Goal**: The target directory structure exists as compilable skeleton packages; the `internal/` anchor is confirmed at module root; no files have moved yet
25+
**Depends on**: Nothing (first phase)
26+
**Requirements**: LAYOUT-01, LAYOUT-02
27+
**Success Criteria** (what must be TRUE):
28+
1. `internal/runtime/` and `internal/library/` directories exist at the module root with valid `package` declarations
29+
2. `go build ./...` succeeds with the skeleton in place alongside existing root files
30+
3. The root facade import of `internal/runtime` compiles without "use of internal package not allowed" errors
31+
4. No existing Go files have been relocated; the skeleton is additive only
32+
**Plans:** 1 plan
33+
Plans:
34+
- [x] 01-01-PLAN.md — Create skeleton packages and anchor validation test
35+
36+
### Phase 2: File Migration
37+
**Goal**: All Go implementation files live in `internal/library/` and `internal/runtime/`; the repo root contains no implementation logic; `go test ./internal/...` passes with race detector on
38+
**Depends on**: Phase 1
39+
**Requirements**: LAYOUT-03, LAYOUT-04
40+
**Success Criteria** (what must be TRUE):
41+
1. All FFI globals (`libHandle`, `libOnce`, `ffiMu`, and all function pointers) exist exclusively in `internal/runtime`; the module root has zero `var` state declarations
42+
2. Platform-specific files (`library_unix.go`, `library_windows.go`) are present in `internal/library/` with correct build tags verified via `go list`
43+
3. `go test -race ./internal/...` passes with no data-race reports
44+
4. Per-package test count in `internal/...` accounts for all tests that previously ran at root; no tests are orphaned
45+
**Plans:** 2 plans
46+
Plans:
47+
- [x] 02-01-PLAN.md — Move library files to internal/library/, export LoadLibrary, bridge chroma.go Init()
48+
- [x] 02-02-PLAN.md — Move runtime files and tests to internal/runtime/, fix imports, remove anchor test
49+
50+
### Phase 3: Root Facade
51+
**Goal**: The repo root package re-exports every previously public symbol so that existing callers compile and behave identically without changing a single import statement
52+
**Depends on**: Phase 2
53+
**Requirements**: FACADE-01, FACADE-02, FACADE-03, FACADE-04, FACADE-05
54+
**Success Criteria** (what must be TRUE):
55+
1. Every exported type is re-exported via `type X = internal/runtime.X` (alias, not definition); `chroma.Server` and `runtime.Server` are the same type
56+
2. Every exported function is delegated via `var F = runtime.F`; callers invoking `chroma.NewServer(...)` reach the implementation without wrapping overhead
57+
3. Every exported constant, sentinel error, and package-level variable is forwarded at root; the root file contains zero logic, zero `var` state, and zero `init()` functions
58+
4. `go test ./...` from the module root passes using the existing test suite with no changes to test files
59+
5. The import path `github.com/amikos-tech/chroma-go-local` resolves to the facade package and the package name remains `chroma`
60+
**Plans:** 2 plans
61+
Plans:
62+
- [x] 03-01-PLAN.md — Create core facade files (doc.go, chroma.go, config.go, errors.go)
63+
- [x] 03-02-PLAN.md — Create feature facade files (embedded.go, backup.go, rebuild.go, compaction.go, wal_prune.go)
64+
65+
### Phase 4: Build and Test
66+
**Goal**: All `make` targets pass, the CI matrix stays green, lint is clean, and the test layout reflects the new package structure including a root-level compatibility gate
67+
**Depends on**: Phase 3
68+
**Requirements**: TEST-01, TEST-02, TEST-03, TEST-04, BUILD-01, BUILD-02, BUILD-03, BUILD-04
69+
**Success Criteria** (what must be TRUE):
70+
1. `make test`, `make test-release`, `make lint`, and `make test-all` all pass locally without modification by the caller
71+
2. `golangci-lint run ./...` reports zero issues; the stale `gci` prefix in `.golangci.yml` is corrected to `github.com/amikos-tech/chroma-go-local/`
72+
3. Cross-compile succeeds: `GOOS=linux go build ./...`, `GOOS=darwin go build ./...`, `GOOS=windows go build ./...` all complete without error
73+
4. `compat_test.go` exists at repo root in `package chroma_test` and references every exported symbol; it compiles successfully as a compile-time API surface gate
74+
5. CI workflows (`.github/workflows/ci.yml`) run without modification to the OS matrix or job structure
75+
**Plans:** 3 plans
76+
Plans:
77+
- [x] 04-01-PLAN.md — Fix lint config (gci prefix) and deprecated type nolint directives
78+
- [x] 04-02-PLAN.md — Create compat_test.go with compile-time API surface gate and behavioral smoke tests
79+
- [x] 04-03-PLAN.md — Full verification pass (make test, make lint, cross-compile, CI inspection)
80+
81+
### Phase 5: Compatibility and Docs
82+
**Goal**: Machine-verified API compatibility against the v0.3.4 baseline is confirmed, documentation reflects the new layout, and the release is ready to merge
83+
**Depends on**: Phase 4
84+
**Requirements**: DOCS-01, DOCS-02, DOCS-03, DOCS-04, COMPAT-01, COMPAT-02, COMPAT-03
85+
**Success Criteria** (what must be TRUE):
86+
1. `go-apidiff` run against the v0.3.4 tag reports zero incompatible changes
87+
2. README.md and CLAUDE.md accurately describe the new `internal/runtime/` and `internal/library/` layout; no file paths point to the old root-level implementation files
88+
3. GO_API_SURFACE.md references are updated to reflect new file locations
89+
4. A compatibility checklist is completed and attached to the PR confirming: import path unchanged, no public API removals, no type definition breakages, race detector clean
90+
5. Release notes include a refactor summary and an explicit compatibility statement for existing users
91+
**Plans:** 2 plans
92+
Plans:
93+
- [x] 05-01-PLAN.md — API compatibility verification (apidiff vs v0.3.4) and CI apidiff job
94+
- [x] 05-02-PLAN.md — Documentation refresh (README, CLAUDE.md, GO_API_SURFACE.md) and CHANGELOG.md
95+
96+
## Progress
97+
98+
**Execution Order:**
99+
Phases execute in strict sequential order: 1 -> 2 -> 3 -> 4 -> 5
100+
101+
| Phase | Plans Complete | Status | Completed |
102+
|-------|----------------|--------|-----------|
103+
| 1. Layout Design | 1/1 | Complete | 2026-03-20 |
104+
| 2. File Migration | 2/2 | Complete | 2026-03-20 |
105+
| 3. Root Facade | 0/2 | Not started | - |
106+
| 4. Build and Test | 0/3 | Not started | - |
107+
| 5. Compatibility and Docs | 0/2 | Not started | - |

0 commit comments

Comments
 (0)