Skip to content

Commit 124830a

Browse files
authored
feat: add Collection.ForkCount for lineage-wide fork counting (#475)
* docs(13): capture phase context * docs(state): record phase 13 context session * docs(13): research collection ForkCount implementation * docs(phase-13): add validation strategy * docs(13): create phase plan for Collection.ForkCount * feat(13-01): add ForkCount to Collection interface with HTTP and embedded implementations - Add ForkCount(ctx) (int, error) to Collection interface - HTTP impl issues GET to /fork_count and decodes JSON {count: n} - Embedded impl returns explicit unsupported error * test(13-01): add ForkCount unit tests for HTTP and embedded paths - HTTP happy path: server returns {"count":5}, assert result == 5 - HTTP error path: server returns 500, assert error returned - Embedded path: assert unsupported error message * docs(13-01): complete Collection ForkCount interface and implementations plan - Add 13-01-SUMMARY.md with execution results - Update STATE.md position and metrics - Update ROADMAP.md progress * docs(13-02): add ForkCount section to collection forking docs - Add "Checking Fork Count" section with Python and Go code examples - Add ForkCount row to Fork API Reference table - Add lineage-wide semantics note to Notes section * feat(13-02): add runnable Fork + ForkCount example - Create examples/v2/fork_count/main.go demonstrating Fork followed by ForkCount - Show lineage-wide semantics where source and fork report same count - Use run() pattern to satisfy gocritic exitAfterDefer lint rule * docs(13-02): complete ForkCount documentation and example plan - Add 13-02-SUMMARY.md with task results and deviations - Update STATE.md with plan progress and metrics - Update ROADMAP.md with phase 13 completion status - Mark FC-05, FC-06 requirements complete * docs(phase-13): complete phase execution * docs(phase-13): evolve PROJECT.md after phase completion * Fix cloud-only fork count docs and example * Polish fork count docs and example comments * docs(13): ship phase 13 — PR #475
1 parent 4910d59 commit 124830a

20 files changed

Lines changed: 1603 additions & 19 deletions

.planning/PROJECT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ Go applications can use Chroma and embedding providers through a stable, portabl
7171
| Pivot Phase 7 from vLLM/Nemotron to VoyageAI | vLLM lacks NVOmniEmbedModel support; VoyageAI multimodal validates portability with text/image/video | ✓ Good |
7272

7373
---
74-
*Last updated: 2026-03-28 — Phase 12 (SDK auto-wiring research) complete: verified auto-wiring behavior across Python, JS, Rust, and chroma-go SDKs. All Go-specific enhancements documented as deliberate; no removals recommended.*
74+
*Last updated: 2026-03-28 — Phase 13 (Collection ForkCount) complete: added ForkCount method to Collection interface with HTTP and embedded implementations, unit tests, documentation, and runnable example.*

.planning/REQUIREMENTS.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@
6767
- [x] **FORK-03**: Shared EFs are wrapped in a `sync.Once`-based close-once adapter that makes `Close()` idempotent as defence-in-depth
6868
- [x] **FORK-04**: Tests cover Fork + Close lifecycle including idempotent close, use-after-close errors, and ownership gating without panics
6969

70+
### Collection ForkCount
71+
72+
- [ ] **FC-01**: `pkg/api/v2.Collection` interface includes `ForkCount(ctx context.Context) (int, error)`
73+
- [ ] **FC-02**: HTTP implementation issues `GET .../fork_count` and decodes `{"count": n}` using strict struct with `json:"count"` tag
74+
- [ ] **FC-03**: Embedded/local implementation returns explicit unsupported error matching existing Fork/Search pattern
75+
- [ ] **FC-04**: Tests cover HTTP happy path, HTTP failure path, and embedded unsupported path
76+
- [x] **FC-05**: Forking docs page includes ForkCount section with Go and Python examples and API reference row
77+
- [x] **FC-06**: Runnable Fork + ForkCount example exists under `examples/v2/`
78+
7079
## v2 Requirements
7180

7281
### Provider Adoption
@@ -127,12 +136,18 @@
127136
| FORK-02 | Phase 11 | Complete |
128137
| FORK-03 | Phase 11 | Complete |
129138
| FORK-04 | Phase 11 | Planned |
139+
| FC-01 | Phase 13 | Planned |
140+
| FC-02 | Phase 13 | Planned |
141+
| FC-03 | Phase 13 | Planned |
142+
| FC-04 | Phase 13 | Planned |
143+
| FC-05 | Phase 13 | Planned |
144+
| FC-06 | Phase 13 | Planned |
130145

131146
**Coverage:**
132-
- v1 requirements: 35 total
133-
- Mapped to phases: 35
147+
- v1 requirements: 41 total
148+
- Mapped to phases: 41
134149
- Unmapped: 0
135150

136151
---
137152
*Requirements defined: 2026-03-18*
138-
*Last updated: 2026-03-26 -- added FORK-01/02/03/04 for phase 11*
153+
*Last updated: 2026-03-28 -- added FC-01/02/03/04/05/06 for phase 13*

.planning/ROADMAP.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This roadmap initializes GSD planning for the current brownfield milestone focus
2626
- [x] **Phase 10: Code Cleanups** - Extract shared path safety utilities, fix *context.Context anti-pattern, add registry test cleanup, fix resolveMIME for URL-backed sources. (issues #456, #461, #466, #469) (completed 2026-03-26)
2727
- [x] **Phase 11: Fork Double-Close Bug** - Fix EF pointer sharing in Fork() that causes double-close on client.Close(). (issue #454) (completed 2026-03-26)
2828
- [x] **Phase 12: SDK Auto-Wiring Research** - Trace contentEmbeddingFunction auto-wiring behavior in official Chroma SDKs. (issue #455) (completed 2026-03-28)
29-
- [ ] **Phase 13: Collection.ForkCount** - Add ForkCount endpoint support for upstream /fork_count API. (issue #460)
29+
- [x] **Phase 13: Collection.ForkCount** - Add ForkCount endpoint support for upstream /fork_count API. (issue #460) (completed 2026-03-28)
3030
- [ ] **Phase 14: Delete with Limit** - Add delete-with-limit support for upstream limit parameter. (issue #439)
3131
- [ ] **Phase 15: OpenRouter Embeddings Compatibility** - Add first-class OpenRouter support via provider preferences and encoding_format. (issue #438)
3232
- [ ] **Phase 16: Twelve Labs Embedding Function** - Add Twelve Labs multimodal embedding provider. (issue #190)
@@ -177,7 +177,7 @@ Plans:
177177
| 10. Code Cleanups | 2/2 | Complete | 2026-03-26 |
178178
| 11. Fork Double-Close Bug | 2/2 | Complete | 2026-03-26 |
179179
| 12. SDK Auto-Wiring Research | 1/1 | Complete | 2026-03-28 |
180-
| 13. Collection.ForkCount | 0/0 | Not started | - |
180+
| 13. Collection.ForkCount | 2/2 | Complete | 2026-03-28 |
181181
| 14. Delete with Limit | 0/0 | Not started | - |
182182
| 15. OpenRouter Embeddings | 0/0 | Not started | - |
183183
| 16. Twelve Labs EF | 0/0 | Not started | - |
@@ -257,10 +257,10 @@ Plans:
257257
3. Embedded/local behavior returns an explicit unsupported error.
258258
4. Tests cover HTTP happy path, failure path, and embedded unsupported path.
259259
5. Forking docs mention the new method.
260-
**Plans:** 0 plans
260+
**Plans:** 2/2 plans complete
261261

262262
Plans:
263-
- [ ] TBD (run /gsd:plan-phase 13 to break down)
263+
- [x] TBD (run /gsd:plan-phase 13 to break down) (completed 2026-03-28)
264264

265265
### Phase 14: Delete with Limit
266266
**Goal:** Add limit parameter support to collection delete operations, matching upstream Chroma PRs #6573/#6582.

.planning/STATE.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
gsd_state_version: 1.0
33
milestone: v0.4.1
44
milestone_name: Provider-Neutral Multimodal Foundations
5-
status: Ready to plan
6-
stopped_at: Phase 12 context gathered
7-
last_updated: "2026-03-28T13:06:51.466Z"
5+
status: "Phase 13 shipped — PR #475"
6+
stopped_at: Completed 13-02-PLAN.md
7+
last_updated: "2026-03-29T14:41:08.046Z"
88
progress:
99
total_phases: 18
10-
completed_phases: 12
11-
total_plans: 27
12-
completed_plans: 27
10+
completed_phases: 13
11+
total_plans: 29
12+
completed_plans: 29
1313
---
1414

1515
# Project State
@@ -23,7 +23,7 @@ See: .planning/PROJECT.md (updated 2026-03-18)
2323

2424
## Current Position
2525

26-
Phase: 13
26+
Phase: 14
2727
Plan: Not started
2828

2929
## Performance Metrics
@@ -70,6 +70,8 @@ Plan: Not started
7070
| Phase 10 P02 | 7min | 2 tasks | 6 files |
7171
| Phase 11 P01 | 3min | 2 tasks | 4 files |
7272
| Phase 11 P02 | 1min | 1 tasks | 1 files |
73+
| Phase 13 P01 | 2min | 2 tasks | 5 files |
74+
| Phase 13 P02 | 2min | 2 tasks | 2 files |
7375

7476
## Accumulated Context
7577

@@ -121,6 +123,8 @@ Recent decisions affecting current work:
121123
- [Phase 11]: Forked collections get close-once wrapped copies of parent EFs, preventing double-close even if ownsEF check is bypassed
122124
- [Phase 11]: Use atomic.Int32 close counters in mocks to verify exact call counts without race conditions
123125
- [Phase 11]: Test ownership gating via direct struct construction - no server required
126+
- [Phase 13]: Follow IndexingStatus GET+JSON pattern for ForkCount HTTP implementation
127+
- [Phase 13]: Use run() pattern in fork_count example to satisfy gocritic exitAfterDefer lint rule
124128

125129
### Roadmap Evolution
126130

@@ -153,6 +157,6 @@ None.
153157

154158
## Session
155159

156-
**Last Date:** 2026-03-28T09:27:37.840Z
157-
**Stopped At:** Phase 12 context gathered
158-
**Resume File:** .planning/phases/12-sdk-auto-wiring-research/12-CONTEXT.md
160+
**Last Date:** 2026-03-28T15:25:22.491Z
161+
**Stopped At:** Completed 13-02-PLAN.md
162+
**Resume File:** None

0 commit comments

Comments
 (0)