Repository navigation
Description
Summary
A comprehensive proposal for ML/AI tooling to improve Sequant's accuracy, code quality enforcement, and spec adherence. These recommendations come from a staff AI engineer perspective, focusing on measurable improvements and data-driven iteration.
Core insight: You can't improve what you can't measure. The foundation is an evaluation infrastructure that makes everything else data-driven.
Problem Statement
Current limitations in Sequant:
| Area | Current State | Gap |
|---|---|---|
| Measurement | Basic success/failure metrics | No systematic eval of output quality |
| Code Search | Keyword-based (grep) | Misses semantic matches |
| Spec Quality | Natural language AC | No validation of testability/completeness |
| Code Analysis | Regex patterns for secrets | Misses deep vulnerabilities |
| Adherence | Manual review in /qa | No automated AC↔code mapping |
| Debugging | Execution logs | Can't trace why Claude made decisions |
| Learning | None | Doesn't improve from past failures |
Proposed Improvements
1. Evaluation & Measurement Infrastructure
Goal: Systematic measurement of AI output quality
1.1 Evals Framework
- Integrate promptfoo or Braintrust
- Create evaluation datasets:
- AC extraction accuracy (issue → extracted AC vs human-labeled)
- Plan quality (/spec output vs expert plans)
- Verdict correctness (/qa false positives/negatives)
- Automated regression testing on prompt changes
1.2 A/B Testing Infrastructure
- Track prompt versions in metrics.json
- Compare success rates per prompt version
- Statistical significance testing for prompt changes
// Extend metrics-schema.ts
promptVersions: z.record(z.string(), z.object({
version: z.string(),
successRate: z.number(),
avgTokens: z.number(),
avgLatency: z.number(),
sampleSize: z.number()
}))Tools: promptfoo (OSS, local), Braintrust (cloud)
2. Semantic Code Understanding
Goal: Find relevant code by meaning, not just keywords
2.1 Local Embedding Index
- Use Ollama + nomic-embed-text for local embeddings
- Index codebase on
sequant init, incremental updates on file changes - Store in LanceDB (local, no server)
2.2 RAG for Context Injection
- Before /exec: retrieve semantically relevant code
- Similar features
- Related tests
- Architectural patterns
- Inject as context to reduce hallucination
Example query: "where do we handle authentication" → finds auth code even without keyword "auth"
Tools: Ollama (local LLM/embeddings), LanceDB (local vector DB), Chroma (alternative)
3. Formal Spec Verification
Goal: Ensure AC items are testable and complete
3.1 AC Linting
- Static analysis of acceptance criteria before /exec
- Flag vague terms: "should work properly", "handle edge cases"
- Require measurable outcomes: "returns 400 status code"
- Detect missing test criteria
3.2 Property-Based Test Generation
- Integrate fast-check patterns
- /testgen outputs property tests, not just unit tests
- Auto-generate edge cases from type signatures
3.3 Contract Extraction
- Extract TypeScript interfaces from AC
- Validate implementation satisfies contracts
- Use ts-morph for AST analysis
Tools: fast-check (property testing), ts-morph (TypeScript AST)
4. Advanced Code Quality Analysis
Goal: Deeper analysis than regex patterns
4.1 CodeQL Integration
- Deep semantic analysis for vulnerabilities
- Data flow analysis for taint tracking
- Run locally, free for OSS
4.2 Semgrep Rules
- Custom Sequant-specific rules
- Pattern: "never use
anyin this codebase" - Pattern: "all API routes must validate input"
- More powerful than regex, catches structural issues
4.3 ast-grep for Structural Search
- Find patterns like "function without error handling"
- Faster and more precise than regex
- Custom rules per stack
4.4 Quality Scoring
- Integrate complexity metrics (cyclomatic, cognitive)
- Gate /qa verdicts on maintainability scores
- Track quality trends over time
Tools: CodeQL (free for OSS), Semgrep (free tier), ast-grep (OSS), SonarQube (optional)
5. Adherence Verification
Goal: Automated verification that code changes address AC items
5.1 Semantic Diff Analysis
- Embed AC items and code diffs
- Cosine similarity to detect if changes are "on-topic"
- Flag changes unrelated to any AC (scope creep detection)
5.2 Traceability Matrix
- Auto-generate AC → file → test mapping
- /qa verifies every AC has test coverage
- Highlight untested AC items
AC-1: User login → src/auth/login.ts → tests/auth/login.test.ts ✓
AC-2: Error display → src/components/Error.tsx → (no test) ⚠️
AC-3: Rate limiting → (no implementation) → (no test) ✗
5.3 Coverage Gap Analysis
- Beyond line coverage: branch, condition coverage
- Flag untested branches in changed code
- Integrate with /qa verdicts
Tools: Custom embeddings + cosine similarity, c8/nyc for coverage
6. Agent Observability & Debugging
Goal: Understand why Claude made certain decisions
6.1 Structured Tracing
- Integrate LangFuse (OSS, self-hostable) or Arize Phoenix (local)
- Trace every Claude call with inputs/outputs
- Token usage, latency, cost per phase
- Replay failed runs for debugging
6.2 Decision Explanation
- Add
reasoningfield to /qa verdicts - Log why AC was marked NOT_MET vs PARTIALLY_MET
- Structured reasoning chains
6.3 Cost Tracking
- Track tokens per skill, per issue
- Identify expensive operations
- Optimize prompts for efficiency
Tools: LangFuse (OSS), Arize Phoenix (local), LangSmith (cloud alternative)
7. Prompt Engineering Infrastructure
Goal: Systematic prompt management and optimization
7.1 Prompt Templating
- Separate prompts from SKILL.md logic
- Version control prompt changes independently
- Hot-reload prompts without code changes
7.2 Few-Shot Example Library
- Curated examples of good outputs
- Good /spec plans
- Good /qa verdicts
- Good /exec implementations
- Inject dynamically based on issue type
- Improves consistency without fine-tuning
7.3 Chain-of-Thought Enforcement
- Force step-by-step reasoning before verdicts
- Structured output format for reasoning
- Audit trail for decisions
Tools: Custom templating, JSON schema validation
8. Test Quality Assurance
Goal: Ensure tests actually catch bugs
8.1 Mutation Testing
- Integrate Stryker Mutator
- Introduce bugs, verify tests catch them
- Gate /qa on mutation score thresholds
- Run incrementally on changed code only
8.2 Test Smell Detection
- Flag assertion-free tests
- Detect tests that always pass
- Identify flaky test patterns
Tools: Stryker (mutation testing), custom linting rules
9. Self-Improvement Loop
Goal: Sequant that learns from its mistakes
9.1 Failure Analysis Pipeline
- When /qa fails, capture structured "why"
- Build dataset: (issue, failed_approach, working_approach)
- Feed back into prompts as negative examples
9.2 Success Pattern Mining
- Cluster successful implementations
- Extract common patterns per issue type
- "For auth issues, these 5 approaches worked"
9.3 User Feedback Collection
- Post-merge prompt: "Was this satisfactory? [1-5]"
- Correlate scores with prompt versions, AC quality
- No fine-tuning needed - just prompt optimization
9.4 Continuous Prompt Optimization
- Use eval scores to guide prompt changes
- Automated prompt variant testing
- Gradual rollout of improved prompts
Tools: Custom pipeline, promptfoo for automated testing
Implementation Roadmap
Phase 1: Foundation (P0)
| Item | Effort | Impact | Dependencies |
|---|---|---|---|
| Evals framework (promptfoo) | M | High | None |
| Semgrep integration | S | High | None |
| Basic observability (LangFuse) | S | Medium | None |
Outcome: Can measure quality, catch more issues, debug failures
Phase 2: Intelligence (P1)
| Item | Effort | Impact | Dependencies |
|---|---|---|---|
| Local embeddings + RAG | M | High | Phase 1 |
| AC linting | M | Medium | Phase 1 |
| Traceability matrix | M | High | Embeddings |
Outcome: Smarter context retrieval, better spec quality, adherence tracking
Phase 3: Quality (P2)
| Item | Effort | Impact | Dependencies |
|---|---|---|---|
| CodeQL integration | M | High | None |
| Semantic diff analysis | L | High | Embeddings |
| Mutation testing | M | Medium | None |
Outcome: Deep security analysis, scope creep detection, test quality assurance
Phase 4: Learning (P3)
| Item | Effort | Impact | Dependencies |
|---|---|---|---|
| Failure analysis pipeline | L | High | Observability |
| Success pattern mining | L | High | Embeddings |
| Continuous optimization | L | Very High | Evals, all above |
Outcome: Self-improving system
Tool Summary
| Category | Tool | License | Local-First | Notes |
|---|---|---|---|---|
| Evals | promptfoo | MIT | ✅ | Primary recommendation |
| Evals | Braintrust | Commercial | ❌ | Cloud alternative |
| Embeddings | Ollama | MIT | ✅ | Local LLM/embeddings |
| Vector DB | LanceDB | Apache 2.0 | ✅ | No server needed |
| Static Analysis | Semgrep | LGPL | ✅ | Custom rules |
| Static Analysis | CodeQL | Custom | ✅ | Free for OSS |
| Static Analysis | ast-grep | MIT | ✅ | Structural search |
| Observability | LangFuse | MIT | ✅ | Self-hostable |
| Observability | Arize Phoenix | Apache 2.0 | ✅ | Fully local |
| Mutation Test | Stryker | Apache 2.0 | ✅ | JS/TS support |
| Property Test | fast-check | MIT | ✅ | Property-based |
| AST Analysis | ts-morph | MIT | ✅ | TypeScript AST |
All primary recommendations are local-first and open source, consistent with Sequant's philosophy.
Success Metrics
| Metric | Current | Target | How to Measure |
|---|---|---|---|
| /qa false positive rate | Unknown | <5% | Evals vs human review |
| AC extraction accuracy | Unknown | >90% | Evals vs labeled data |
| Security issues caught | Regex only | +50% | CodeQL/Semgrep findings |
| Context relevance | Keyword | Semantic | User feedback, adherence |
| Debug time for failures | Hours | Minutes | Time to root cause |
| Test mutation score | Unknown | >80% | Stryker reports |
Open Questions
- Embedding model choice: nomic-embed-text vs code-specific models (CodeBERT, StarCoder embeddings)?
- Vector DB: LanceDB vs Chroma vs SQLite with pgvector extension?
- Observability hosting: Self-host LangFuse vs local-only Arize Phoenix?
- Eval dataset creation: Manual labeling vs synthetic generation vs production sampling?
- Prompt versioning: Git-based vs database vs hybrid?
References
- promptfoo documentation
- LangFuse self-hosting
- Semgrep rules
- Stryker mutation testing
- LanceDB quickstart
- Ollama embedding models
Labels
enhancementrfcml-infrastructure
/cc @tony - Ready for prioritization and roadmap discussion
Activity
admarble commentedon Jan 29, 2026
Performance Analysis by User Use Case
Typical User Workflows
Based on Sequant's design, here are the primary use cases and their performance profiles:
/spec→/exec→/qa)/fullsolve 123)sequant run 1,2,3,4,5)Performance Impact Analysis
1. Evals Framework (promptfoo)
Recommendation: Run evals nightly or on prompt changes only, not every PR.
2. Local Embeddings + RAG
sequant init, incremental afterUse Case Impact:
/spec/exec/qaRecommendation:
nomic-embed-text(768-dim, good quality/speed tradeoff)3. AC Linting
Recommendation: Fast enough to run on every
/spec. Include override mechanism.4. Static Analysis Tools
Use Case Impact:
/qa(laptop)/qa(CI)/fullsolveRecommendation:
5. Semantic Diff Analysis
Recommendation: Enable by default in
/qa. Minimal overhead, high value for scope creep detection.6. Observability (LangFuse/Phoenix)
Use Case Impact:
/spec(3-5 Claude calls)/exec(10-20 calls)/fullsolve(30-50 calls)Recommendation:
7. Mutation Testing (Stryker)
Use Case Impact:
/qa/fullsolveRecommendation:
--mutation-testflag for explicit opt-in8. Property-Based Testing (fast-check)
Recommendation: Generate property tests in
/testgen, but make iteration count configurable. Default to 100, allow reduction to 10 for CI speed.Resource Budget by Use Case
Solo Developer on Laptop (8 GB RAM, no GPU)
/spec/exec/qaVerdict: ✅ Acceptable. RAM is the constraint - may need to unload Ollama between phases.
CI Runner (GitHub Actions, 7 GB RAM, 2 cores)
Verdict: ✅ Feasible with tiered approach. Skip heavy tools (CodeQL, Stryker) in PR checks.
Batch Processing (5+ issues overnight)
Verdict: ✅ No new concerns. Existing patterns handle batch well.
Latency Budget Summary
Target: < 20% overhead on typical workflows
Memory Budget Summary
Target: < 4 GB additional RAM for full feature set
Recommended Configuration Tiers
Tier 1: Lightweight (< 1 GB overhead)
{ "embeddings": false, "semgrep": true, "astGrep": true, "observability": false, "codeql": false, "mutationTesting": false }For: CI runners, low-RAM machines, quick iterations
Tier 2: Balanced (2-3 GB overhead) ⭐ Recommended
{ "embeddings": true, "semgrep": true, "astGrep": true, "observability": "local", "codeql": false, "mutationTesting": false }For: Daily development on modern laptops
Tier 3: Full (4+ GB overhead)
{ "embeddings": true, "semgrep": true, "astGrep": true, "observability": "full", "codeql": "on-demand", "mutationTesting": "on-demand" }For: Security-sensitive projects, quality audits
Performance Testing Plan
Before shipping each feature, validate:
Micro-benchmarks
Integration benchmarks
/spectotal time increase: < 20%/qatotal time increase: < 30%User experience
Summary
Bottom line: The P0+P1 features add ~2-3 GB RAM and ~20% latency overhead. This is acceptable for the accuracy/quality gains, especially since Sequant workflows already take minutes, not seconds.
admarble commentedon Jan 29, 2026
Integration & Complexity Analysis
The Over-Engineering Risk
Sequant's core value is discipline without friction. Adding 9 new systems risks violating this principle. This analysis evaluates each proposal against:
Complexity Scorecard
Detailed Integration Analysis
1. Evals Framework (promptfoo) ✅ LOW COMPLEXITY
Integration Points:
Dependencies:
Failure Modes:
Maintenance:
Verdict: ✅ Ship it. Zero runtime risk, high value for prompt iteration.
2. Embeddings + RAG⚠️ HIGH COMPLEXITY
Integration Points:
Dependencies:
Failure Modes:
Maintenance:
Simpler Alternative:
Verdict:⚠️ High value but high complexity. Consider phased approach:
3. AC Linting ✅ LOW COMPLEXITY
Integration Points:
Dependencies:
// No new dependencies - pure TypeScriptImplementation:
Failure Modes:
Verdict: ✅ Ship it. Zero dependencies, immediate value, low maintenance.
4. Semgrep ✅ LOW COMPLEXITY
Integration Points:
Dependencies:
Failure Modes:
Maintenance:
Simpler Alternative: None needed - Semgrep IS the simple solution compared to CodeQL.
Verdict: ✅ Ship it. Optional external binary, high value, graceful degradation.
5. CodeQL⚠️ MEDIUM COMPLEXITY
Integration Points:
Dependencies:
# 500 MB+ binary download gh extension install github/gh-codeqlFailure Modes:
Maintenance:
Simpler Alternative: Semgrep covers 70% of CodeQL's value with 10% of the complexity. CodeQL adds:
Verdict:⚠️ Optional, on-demand only. Don't include in default workflow. Add
sequant security-auditcommand that runs CodeQL explicitly.6. Semantic Diff Analysis⚠️ HIGH COMPLEXITY (depends on #2)
Integration Points:
Dependencies:
Failure Modes:
Simpler Alternative:
Verdict:⚠️ Defer until #2 is proven. Start with keyword overlap, upgrade later.
7. Observability (LangFuse/Phoenix)⚠️ MEDIUM COMPLEXITY
Integration Points:
Dependencies:
Failure Modes:
Maintenance:
Simpler Alternative:
Verdict:⚠️ Start with JSONL logging, add Phoenix later. Full observability is nice-to-have, not must-have.
8. Mutation Testing (Stryker) ✅ LOW COMPLEXITY
Integration Points:
Dependencies:
Failure Modes:
Maintenance:
Verdict: ✅ Ship as opt-in flag. Dev dependency only, clear value, no runtime risk.
9. Self-Improvement Loop ❌ HIGH COMPLEXITY
Integration Points:
Dependencies:
Failure Modes:
Maintenance:
Simpler Alternative:
Verdict: ❌ Defer to v2.0+. Too complex for current stage. Start with manual pattern curation.
Dependency Tree Impact
Current Sequant dependencies: ~15 runtime, ~20 dev
Proposed additions by tier:
Total if all shipped:
Complexity Budget Recommendation
Given Sequant's "discipline without friction" philosophy, propose a complexity budget:
Revised Recommendations
Based on complexity analysis, revised priority:
Ship Now (Low Complexity, High Value)
Ship with Opt-In Flag
Defer (Needs More Design)
Defer to v2.0+
The 80/20 Path
Maximum value with minimum complexity:
This gives you:
Without:
Decision Framework
For each future proposal, ask:
If any answer is "no", reconsider or defer.
admarble commentedon Jan 29, 2026
Closing this RFC after assessment. The proposal adds significant complexity (12+ dependencies, 9 subsystems) for marginal gains over what Claude Code + Opus 4.5 already provides natively.
Key concerns:
Extracting high-value items into focused issues:
These deliver 80% of the value with 20% of the complexity. See follow-up issues.