feat(team): harden share pipeline — Ollama client, helper extraction, segmented sync#49
Merged
feat(team): harden share pipeline — Ollama client, helper extraction, segmented sync#49
Conversation
Priority 1 - Fix broken things:
- Rewrite test/team.test.ts with bun:test (was using console.assert, wrong imports)
- Fix unit-level dedup in share.ts (was matching on random UUID, now content_hash only)
- Fix duration calculation in segment.ts (use actual timestamps, not messageCount/2)
- Fix replace() → replaceAll() for nested category paths in share.ts
Priority 2 - Code quality:
- Extract shared callOllama() to src/team/ollama.ts with timeout + retry
- Extract shared slugify/datePrefix to src/team/utils.ts
- DRY up share.ts: extract resolveOutputDir, querySessions, writeManifest helpers
- Use isValidCategory from categorize/schema.ts instead of duplicate in segment.ts
- Remove unused SMRITI_DIR import from document.ts
Priority 3 - Test coverage:
- Replace misleading tests in team-segmented.test.ts with mocked Ollama tests
- Add generateDocument, generateDocumentsSequential, and fallback path tests
- Add real DB validation tests using isValidCategory
Priority 4 - Sync integration:
- Fix sync.ts to handle Stage 2 structured output (pipeline: segmented flag)
- Segmented knowledge docs are no longer write-only
Priority 5 - Prompt improvements:
- Constrain Stage 1 to use only listed categories (remove "other valid" text)
- Add {{title}} placeholder and heading instruction to all Stage 2 templates
- Remove hallucination-prone "Links to further reading" from topic template
Also adds docs/demo-script.md showing the full smriti workflow story.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
b24a0e1 to
891fb05
Compare
Contributor
Benchmark Scorecard (ci-small)Bench Scorecard (ci-small)threshold: 20.00%
Summary: WARN (4 metrics) |
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.
Summary
src/team/ollama.ts(new) — Centralized Ollama HTTP client extracted from bothsegment.tsanddocument.ts. Adds 120s timeout, 2-retry exponential backoff, and proper error classification (no retry on 4xx, retry on 5xx and network failures).src/team/utils.ts(new) — Sharedslugify()anddatePrefix()utilities, extracted fromdocument.ts.share.tsextractsresolveOutputDir(),querySessions(),getSessionMessages(), andwriteManifest()as named helpers. Both the segmented and legacy pipelines now share these instead of duplicating 100+ lines each.sync.tsnow detects docs from the segmented pipeline (viameta.pipeline === "segmented") and treats the full body as a single assistant message instead of trying to parse**user**/**assistant**chat patterns that don't exist in generated docs.replaceAll("/", "-")instead ofreplace("/", "-"), so nested categories likedecision/technicalproducedecision-technical/notdecision/technical/.(content_hash, unit_id), avoiding false negatives on re-runs.{{title}}and emit a# Headingusing it. Stage 1 category list locked down with "Use ONLY categories listed above."segment.tsnow calculated from actual message timestamps instead ofmessages.length / 2.Test plan
bun test test/team.test.ts— legacy share pipelinebun test test/team-segmented.test.ts— segmented pipelinesmriti share --project <id> --segmented— verify generated docs have# Headingsmriti syncafter share — verify segmented docs import without being skippeddecision/technical) createsdecision-technical/dir correctly