Commit graph

47 commits

Author SHA1 Message Date
Snider
45e9fed280 feat: add InspectAttention pass-through on InferenceAdapter
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-23 00:37:37 +00:00
Claude
1c5fd160f2
chore: refresh go.sum after upstream tag updates
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 23:36:25 +00:00
Snider
9d74275568 refactor: migrate CLI imports from core/go to core/cli
Update imports from forge.lthn.ai/core/go/pkg/cli to
forge.lthn.ai/core/cli/pkg/cli following CLI package split.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 23:29:51 +00:00
Claude
1110eac4a5
chore: sync workspace dependency versions
Run go work sync to align dependency versions across workspace.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 21:42:15 +00:00
Snider
a6fb45da67 refactor: apply go fix modernizers for Go 1.26
Automated fixes: interface{} → any, range-over-int, t.Context(),
wg.Go(), strings.SplitSeq, strings.Builder, slices.Contains,
maps helpers, min/max builtins.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 21:00:16 +00:00
Snider
ab14be25cc chore: bump go directive to 1.26.0
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 20:33:48 +00:00
Snider
86fc6a0138 chore: pin forge deps to v0.0.1 tags for Go 1.26 compat
Go 1.26 rejects non-semver version strings (like 'main') in go.mod.
Tags v0.0.1 now exist on all forge repos — workspace still overrides
for local development.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 20:15:06 +00:00
Snider
926fb268f6 chore: use workspace-resolved versions, drop replace directives
Forge module versions now use main branch resolution via ~/Code/go.work
workspace. Removes local replace directives — the central go.work handles
all cross-repo resolution during development.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 19:49:36 +00:00
Snider
950b67d25d chore: add missing go-i18n dependency via go mod tidy
Pre-existing issue: cmd/cmd_benchmark.go imports go-i18n/reversal
but the dependency was absent from go.mod.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 17:48:36 +00:00
Snider
7601614e07 test: update all test assertions for Result type
All Backend.Generate/Chat calls now return Result. Test assertions
updated to use .Text and check .Metrics where appropriate.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 17:45:32 +00:00
Snider
3b6dba5d85 refactor(cmd): unwrap Result.Text across all commands
Updates cmd_ab, cmd_sandwich, cmd_lesson, cmd_sequence,
cmd_benchmark, cmd_serve, and api/routes.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 17:41:16 +00:00
Snider
ef44f0ae25 refactor: unwrap Result.Text in expand, judge, agent_eval
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 17:39:17 +00:00
Snider
22cc1a5afd refactor(service): Generate returns Result
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 17:38:14 +00:00
Snider
44e063c1fa refactor(http-textmodel): unwrap Result.Text from Backend calls
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 17:37:56 +00:00
Snider
52f27fc476 feat(llama): return Result from Generate/Chat
Delegates to HTTPBackend which already returns Result.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 17:37:34 +00:00
Snider
8a36bafa83 feat(http): return Result from Generate/Chat
HTTP backend returns Result{Text: text} with nil Metrics since
remote APIs don't provide Metal-level inference metrics.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 17:37:18 +00:00
Snider
d90bd7b779 feat(adapter): return Result with Metrics from TextModel
InferenceAdapter.Generate and Chat now return Result{Text, Metrics}
where Metrics is populated from the underlying TextModel.Metrics().

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 17:36:53 +00:00
Snider
5578671f90 feat: add Result type, break Backend interface to return Result
Backend.Generate and Backend.Chat now return (Result, error) instead of
(string, error). Result carries the response text and optional
inference.GenerateMetrics for backends that support them.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 17:36:16 +00:00
Snider
dcf58d041d feat: add Ubuntu workstation setup script from CLI
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-21 21:20:13 +00:00
Snider
812c926dac feat: migrate cmd/ml from CLI repo, resolve forge deps
Move all 40 ML command files from core/cli/cmd/ml to go-ml/cmd/.
Commands self-register via init() + cli.RegisterCommands().

- Fixed stale go-ai/ml import in cmd_ab.go (now uses go-ml + go-mlx)
- Disabled cmd_train.go (needs go-mlx training API export)
- Removed all local replace directives, deps resolve from forge
- go build ./... passes cleanly

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-21 19:14:58 +00:00
Snider
0c238589af feat(api): add REST route group for ML endpoints via go-api
Implements RouteGroup and StreamGroup interfaces from go-api, exposing
ML inference service methods as REST endpoints: GET /backends, GET /status,
POST /generate. Includes 12 integration tests covering interface satisfaction,
engine registration, envelope format, and error handling.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 16:00:52 +00:00
Snider
861e44fedd docs: add README with quick start and docs links
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 15:11:19 +00:00
Snider
3918051112 docs: graduate TODO/FINDINGS into production documentation
Replace internal task tracking (TODO.md, FINDINGS.md) with structured
documentation in docs/. Trim CLAUDE.md to agent instructions only.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 15:01:55 +00:00
Claude
7075d7cbe7
fix(go.mod): correct replace path for core/go
Was ../host-uk/core (wrong), now ../go matching workspace layout.

Co-Authored-By: Charon <charon@lethean.io>
2026-02-20 14:22:47 +00:00
Snider
74ebbe634c docs: mark deferred items complete in TODO — all phases done
Memory controls handled by go-mlx internally. Integration smoke test
covered by Phase 4 mock tests; real-model test deferred to LEM Lab.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 12:45:28 +00:00
Snider
1fc4c640ff docs: mark Phase 4 test coverage complete — all phases done
25 benchmarks baselined on M3 Ultra, 34 backend tests, 6 race-condition
tests. go test -race clean.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 03:49:54 +00:00
Snider
09bf40301d test: add Phase 4 test coverage and benchmarks
Backend tests: LlamaBackend (20 tests via httptest mock), MLX/InferenceAdapter
(8 tests via mock TextModel). Race condition tests: concurrent scoring (20
responses), mixed suites fan-out, semaphore boundary (concurrency=1), context
cancellation, heuristic-only (50 responses), multi-model concurrent map writes.
Benchmarks: heuristic (5 sizes), exact match (4 patterns), JSON extraction
(6 variants), judge round-trip (2 suites), ScoreAll (2 modes), sub-components
(5 heuristic stages). All pass with -race.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 03:49:07 +00:00
Snider
c925391174 docs: mark Phase 3 Step 3.4 agent tests complete — Phase 3 done
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 03:23:43 +00:00
Snider
3e227610fe test: add agent subsystem tests (25 tests, 528 LOC)
Tests for AdapterMeta (model family → tag/prefix/stem mapping),
FindUnscored (checkpoint filtering), BufferInfluxResult/ReplayInfluxBuffer
(JSONL persistence round-trip), and DiscoverCheckpoints (SSH output parsing
via fakeTransport mock implementing RemoteTransport interface).

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 03:23:13 +00:00
Snider
987831bd16 docs: mark Phase 3 Step 3.3 configurable infrastructure complete
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 03:18:38 +00:00
Snider
12f3a1c79d refactor: extract hardcoded values into package constants
Move magic numbers and strings into named constants in agent_config.go:
- EpochBase (was 1739577600 in 5 locations)
- 5 InfluxDB measurement names (capability_score, probe_score, etc.)
- 2 DuckDB table names (checkpoint_scores, probe_results)
- Probe defaults (temperature, max tokens, response truncation)
- InfluxBufferFile, LogSeparatorWidth, InterCheckpointDelay

Replace hardcoded probe counts ("23", "6") with len(CapabilityProbes),
len(ContentProbes). 7 files modified, no functional changes.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 03:18:19 +00:00
Snider
6f6bdd7c5c docs: mark Phase 3 Step 3.2 RemoteTransport complete
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 03:10:08 +00:00
Snider
1c2a6a6902 feat: add RemoteTransport interface for SSH abstraction
Introduce RemoteTransport interface (Run, CopyFrom, CopyTo) with
SSHTransport implementation using ssh/scp binaries. AgentConfig gains
a Transport field with lazy initialization from M3 credentials.

All internal callers (DiscoverCheckpoints, processMLXNative,
processWithConversion) now use cfg.transport() instead of global
SSHCommand/SCPFrom. Old functions preserved as deprecated wrappers.

Enables mock injection for testing agent loop without real SSH.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 03:09:42 +00:00
Snider
33939fe038 docs: mark Phase 3 Step 3.1 agent.go split complete
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 03:05:45 +00:00
Snider
eae9ec9b38 refactor: split agent.go (1070 LOC) into 5 focused files
Decompose monolithic agent.go into concern-based files:
- agent_config.go (97 LOC): AgentConfig, Checkpoint, model maps
- agent_execute.go (215 LOC): RunAgentLoop, discovery, scoring dispatch
- agent_eval.go (397 LOC): MLX native + conversion eval, capability/content probes
- agent_influx.go (291 LOC): InfluxDB scoring push, buffer/replay
- agent_ssh.go (102 LOC): SSH/SCP helpers, env utilities

No functional changes. All tests pass.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 03:05:11 +00:00
Snider
58854390eb docs: add Phase 3 agent.go structure audit to FINDINGS.md
Documented 6 logical sections, hardcoded infrastructure,
and testable functions (AdapterMeta, FindUnscored, buffer).

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 02:13:06 +00:00
Snider
6847cc9d24 docs: refine Phase 3 agent.go decomposition with line-level split plan
1,070 LOC agent.go → 5 files: agent_config (95), agent_execute (200),
agent_eval (355), agent_influx (270), agent_ssh (90). Added SSH
transport interface, infrastructure constants, and test tasks.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 02:12:23 +00:00
Snider
57c8a97dfe docs: mark Phase 2 backend consolidation complete
All 4 steps done in commit 747e703:
- Step 2.1: Message type alias (inference.go, adapter.go)
- Step 2.2: GenOpts extension with TopK/TopP/RepeatPenalty
- Step 2.3: StreamingBackend deprecation
- Step 2.4: CLAUDE.md Backend Architecture section

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 02:06:49 +00:00
Snider
747e703c7b feat: Phase 2 backend consolidation — Message alias, GenOpts, deprecation
- Replace Message struct with type alias for inference.Message (backward compat)
- Remove convertMessages() — types are now identical via alias
- Extend GenOpts with TopK, TopP, RepeatPenalty (mapped in convertOpts)
- Deprecate StreamingBackend with doc comment (only 2 callers, both in cli/)
- Simplify HTTPTextModel.Chat() — pass messages directly
- Update CLAUDE.md with Backend Architecture section
- Add 2 new tests, remove 1 obsolete test

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 02:05:59 +00:00
Snider
fe70eb0ce1 docs: add Phase 2 StreamingBackend audit results to FINDINGS.md
Full audit of StreamingBackend usage across ecosystem:
- Only 2 callers (both in host-uk/cli, out of go-ml scope)
- All other consumers use Backend.Generate() (non-streaming)
- GenOpts vs GenerateConfig field comparison documented
- backend_mlx.go dead imports marked as FIXED (Phase 1)

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 01:54:26 +00:00
Snider
898c4c228d docs: refine Phase 2 backend consolidation tasks with audit results
Based on comprehensive codebase analysis:
- Only 2 files use StreamingBackend (both in host-uk/cli)
- All other consumers use Backend.Generate() (non-streaming)
- Precise steps: type alias Message, extend GenOpts, deprecate StreamingBackend

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 01:53:27 +00:00
Snider
c3c2c14dba feat(backend): add HTTP/Llama TextModel wrappers + verify downstream
Phase 1 Steps 1.4 and 1.5 complete:

- HTTPTextModel wraps HTTPBackend as inference.TextModel (Generate/Chat
  yield entire response as single Token, Classify unsupported,
  BatchGenerate sequential)
- LlamaTextModel embeds HTTPTextModel, overrides ModelType -> "llama"
  and Close -> llama.Stop()
- 19 new tests (17 HTTPTextModel + 2 LlamaTextModel), all passing
- Verified service.go and judge.go downstream consumers unchanged
- Updated CLAUDE.md: backend_mlx.go DONE, architecture table current,
  critical context reflects Phase 1 complete
- Updated TODO.md: Steps 1.4 and 1.5 marked done

Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 01:23:34 +00:00
Snider
a4d7686147 feat(adapter): bridge go-inference TextModel to ml.Backend/StreamingBackend
InferenceAdapter wraps inference.TextModel (iter.Seq[Token]) to satisfy
ml.Backend (string returns) and ml.StreamingBackend (TokenCallback).

- adapter.go: InferenceAdapter with Generate/Chat/Stream/Close
- adapter_test.go: 13 test cases with mock TextModel (all pass)
- backend_mlx.go: rewritten from 253 LOC to ~35 LOC using go-inference
- go.mod: add forge.lthn.ai/core/go-inference dependency
- TODO.md: mark Phase 1 steps 1.1-1.3 complete

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 00:52:34 +00:00
Snider
e7959720c5 docs: add go mod download note and clarify backend_mlx state
CLAUDE.md updated: first-run needs go mod download, backend_mlx.go
imports dead go-mlx subpackages (Phase 1 fixes this).

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 00:40:00 +00:00
Snider
84757b8331 docs: comprehensive domain expert session brief for go-inference migration
Rewrites CLAUDE.md with full interface mapping (ml.Backend → inference.TextModel),
adapter design pattern, broken import context, and local dependency paths.

Expands TODO.md Phase 1 into 5 concrete steps with code patterns for
InferenceAdapter, backend_mlx.go rewrite, and downstream verification.

Updates FINDINGS.md with type correspondence table and before/after comparison.

Fixes go.mod replace directives for ~/Code/ layout and adds go-inference.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-19 21:55:50 +00:00
Virgil
88e926cc24 docs: add TODO.md, FINDINGS.md for fleet delegation
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-19 21:33:53 +00:00
Snider
7c8e762a86 feat: extract go-ml from go-ai as standalone ML package
Inference backends (MLX, llama.cpp, HTTP), scoring engine, agent
orchestrator, GGUF management, DuckDB storage, Parquet I/O.
Adds CLAUDE.md/TODO.md/FINDINGS.md.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-19 18:32:04 +00:00