Commit Graph
144 Commits
Author SHA1 Message Date
sam cb1b0eb11a feat(telegram): typing indicator + Markdown rendering (part of 16.6)
Two gaps visible in the live heyarchie bot:

1. No typing indicator. A non-command message runs a full LLM turn
   (seconds), during which the chat looked dead. defaultHandler now
   shows the typing action for the duration, refreshed every 4s since
   Telegram clears it after ~5s.

2. ParseMode was never set, so LLM Markdown reached users verbatim:
   literal **bold**, backticks, and pipe tables. helpHandler was worse
   -- it emitted <b>Archie Gateway</b> with no ParseMode, so the raw
   tags were shown.

The SDK has no Markdown->Telegram converter (EscapeMarkdown does the
inverse: it escapes text so it renders literally), and neither native
parse mode helps, since Telegram's Markdown dialects use single-asterisk
*bold* whereas LLMs emit **bold**. So markdownToHTML converts to the
HTML subset Telegram accepts, mapping headings to <b>, bullets to '•',
and tables to <pre> (Telegram has no table element). Send falls back to
unformatted text if Telegram rejects the markup, so a conversion bug can
never swallow a reply.
2026-07-27 04:47:21 +10:00
sam 4c0fc12450 test message 2026-07-27 04:39:27 +10:00
sam 38a746a891 fix: make agent-container Docker network explicitly configurable
archied's container-mode agent tasks were all failing with "nats: no
responders available for request" in production. Root cause: pool.go's
selfNetwork() auto-detects the daemon's own Docker network by looking up
a container named after os.Hostname(), then joins spawned agent
containers to that same network so they can resolve "nats" by name.
On carina this detection was silently failing (wrong/stale hostname vs.
actual container ID) and returning "", so every per-task agent container
landed on the default bridge network instead — unable to resolve "nats",
never subscribing, hence "no responders" on every request.

selfNetwork() swallowed every failure silently (only logged on success),
so this had no diagnostic trail.

Fix: added Containers.Network config field (containers.network in
config.toml) so deployments can name the network explicitly instead of
relying on fragile self-detection; selfNetwork() remains as a fallback
but now logs a warning on every failure path so this doesn't silently
recur. Wired through container.Config and cmd/archied/main.go.
2026-07-27 04:25:28 +10:00
sam 63719cc3ec fix: restore [forge] token_env backward compat, fixing prod crash-loop
Both archied production containers (archie-core-archied-1 and -winter-1)
were crash-looping on carina with "forge token (engine \"env\", key
\"ARCHIE_GITHUB_TOKEN\") is required" despite being configured for gitea.

Root cause: the secrets-engine migration replaced [forge]'s flat
token_env string field with a {engine, key} struct (Forge.Token), but
dropped the old field entirely instead of keeping it as a deprecated
fallback like NATSConfig and TelegramConfig already do. TOML silently
ignores unknown keys, so deployed configs still using token_env had
their token config dropped without any warning, and finalize()
defaulted to demanding ARCHIE_GITHUB_TOKEN.

Fix: re-added Forge.TokenEnv and honor it in finalize() when the new
Token struct is unset, matching the existing NATS/Telegram pattern.
New-style [forge.token] still wins if both are present. Added
regression tests for both cases.

Operationally also fixed the two live configs on carina
(~/.config/archie/config.toml, winter.toml) to the new schema, and
added missing work_dir/db_path to winter.toml (its container had no
config-overlay, so it was defaulting to /root/.local/share/archie
instead of the mounted volume). Both containers verified healthy and
processing real issues after restart.
2026-07-27 04:13:04 +10:00
sam b9ecf37a48 refactor: replace fmt.Sprintf with fmt.Appendf in test 2026-07-27 04:03:23 +10:00
sam 6fe1a7d037 fix: lint cleanup across repo (errcheck, staticcheck, ineffassign, unused)
- daemon.go: real bug — maybeRetryParked resolved fg := d.forgeFor(task)
  (matching markDead's pattern) but called d.Forge.SetStateLabel instead
  of fg.SetStateLabel, silently using the wrong forge client for
  multi-identity/multi-forge task routing. Fixed to use fg throughout.
- telegram.go: updateThreadID existed but was never called anywhere;
  wired it into updateLoggingMiddleware so debug logs include thread_id.
- Two SA9003 empty-branch tests (nell adapter_test.go, tools
  toolentry_test.go) were dead assertions with no body; implemented the
  actual check instead of deleting them.
- memory manager_test.go: mockProvider.lastConfigSchema/lastBackupPaths
  were declared but never recorded; wired GetConfigSchema/BackupPaths to
  populate them and strengthened the aggregation tests to assert on
  per-provider content, not just counts.
- Removed genuinely dead gateway messageevent_test.go helpers (intPtr/
  i64Ptr, marked //go:fix inline, already fully superseded by the new()
  builtin used throughout the file).
- Remaining errcheck findings (defer Close/Flush/Write, os.Setenv, etc.
  in test files) fixed with the existing `_ = ` convention already used
  elsewhere in the codebase.

go build ./..., go test ./... (all packages ok), and
golangci-lint run ./... all clean.
2026-07-27 03:49:33 +10:00
sam 97e6a54da5 fix: MCP stdio transport lifecycle races and dead SendTimeout config
Implement the SendTimeout config field (previously silently ignored) via a
timeout-bounded write helper, and close two related races found during
adversarial review: Start()/Stop() could interleave across separate lock
acquisitions, and a subprocess spawned by a fresh Start() or a
crash-triggered restart could clobber a StateStopped already committed and
reported by a concurrent Stop(). Both spawn-commit paths now funnel through
a single guarded commitSpawnedProcess. Closes archie-core-abg.17.16,
archie-core-abg.17.23, archie-core-abg.17.41.
2026-07-27 03:46:47 +10:00
sam f73b2d1c8c feat: memory manager sync/prefetch/scan/shutdown + broad in-flight epic work
Checkpoint commit covering concurrent work across several archie-core-abg
epics to avoid losing in-progress state:

- Memory manager (18.7-18.16): background sync pipeline, prefetch with
  timeout, memory-write notification, threat scanning, shutdown drain
  with abandoned-write tracking, frozen snapshot pattern. Wired
  ScanContent and NotifyMemoryToolWrite into HandleToolCall so scanning
  and notification actually apply to writes, not just exist as unused
  primitives.
- Fixed a literal unresolved merge-conflict that had been committed to
  internal/memory/scrubber/scrubber.go.
- Tool provider/registry, MCP client/transport (stdio, HTTP, SSE),
  multimodal results, disclosure.
- Pairing device auth store, rate limiting.
- Gateway compression, session store, tasks.
- Various workflow, plugin host, and agentexec updates.
2026-07-27 03:34:46 +10:00
sam 2b1045c0ad feat: secrets-engine registry with yaegi extension interface (archie-core-xec)
Adds internal/secret: a pluggable Engine interface (Name/Version/Resolve)
resolved through a Registry, so secrets backends (sops, Bitwarden Secrets
Manager, Vault/OpenBao) aren't hard-coded into the binary. Only the "env"
engine is compiled in; custom engines are Yaegi-interpreted .go plugins
loaded via Registry.LoadDir, mirroring internal/plugin's conventions
(secretextract provides the generated, nil-guarded symbol table for the
Yaegi/Go interface boundary).

config.Forge.TokenEnv is replaced end-to-end with config.Forge.Token
(secret.SecretRef{Engine, Key}) -- finalize() defaulting, forge token
resolution in cmd/archied/main.go, and per-identity validation that now
requires an explicit token instead of silently resolving to "". No
backwards-compat shim.

Provider.APIKeyEnv, NATSConfig.TokenEnv, and TelegramConfig.TokenEnv are
deliberately not migrated here -- they're forwarded by name to
ai-sdk/runtime and subprocess workers rather than resolved centrally,
which needs its own eager-resolve-then-inject design pass
(archie-core-xec.4). The three shipped engine plugins (sops, bws,
vault/openbao) are tracked separately as archie-core-xec.1-3.

Adversarially reviewed by a fresh agent with no implementation context;
fixed the two findings that survived (missing per-identity token
validation, underdocumented nil-wrapper Resolve edge case).
2026-07-26 14:49:32 +10:00
sam 146acf5466 feat: secret engine registry foundation (archie-core-xec)
internal/secret package:
- Engine interface (Name, Version, Resolve) for pluggable secret backends
- SecretRef type replacing TokenEnv/APIKeyEnv string fields
- ResolveOrEnv for backward-compatible env-var fallback
- Built-in env engine registered by default
- Registry with Register/Get/Resolve/LoadDir (yaegi-based)
- DefaultRegistry() singleton for one-off resolution
- 12 tests, race-clean

Scoped to foundation only. Provider/NATS/Telegram migration deferred
to xec.4 (separate bead — those call sites forward env var names to
subprocesses/runtimes and need eager-resolve-then-inject, not a simple
field rename).

40/40 packages pass with -race.
2026-07-26 14:20:19 +10:00
sam b95993c44a fix: address adversarial review findings (21v + 19v)
Session persistence (21v):
- Mutex coverage on all nellSessionStore read operations
- Router.Store nil guard in handleStatus()

Config (19v):
- Remove dead code no-op in finalize() (Label='' assignment)
- Nil guard on loadFeatureFile() cfg parameter

40/40 packages pass with -race.
2026-07-26 13:56:25 +10:00
sam f4787a819d feat: email channel + Channel interface with config schema validation
Email channel (internal/channels/email):
- SMTP server receiving inbound emails on configurable port
- Multipart body extraction (text/plain from MIME)
- SMTP relay for outbound replies with STARTTLS + AUTH
- 8 tests, race-clean

Channel interface (internal/channels/channel.go):
- ConfigSchema() — JSON Schema for channel configuration
- ValidateConfig() — validates channel-specific config at startup
- All three channels (Telegram, Email, Webhook) implement it
- Compile-time guard: var _ channels.Channel = (*Gateway)(nil)

Config: ChatConfig.Email added (listen_addr, relay_addr).
Daemon: email gateway wired into main.go behind chat.email block.

40 packages pass with -race.
2026-07-26 13:36:56 +10:00
sam 20a1210d0e feat: webhook platform + persona registry (items 5+6)
Webhook platform (internal/channels/webhook):
- Gateway adapter with HTTP server, HMAC validation, dot-notation template extraction
- Per-route configuration with secret-based signing
- Deliver-to-origin mode for sync responses
- 11 tests, race-clean

Persona registry (internal/gateway/persona.go):
- PersonaRegistry with per-session active persona selection
- DefaultPersonas(): helpful, concise, technical, creative, teacher
- Persona prompt prepended to system prompt in LLMResponder
- Thread-safe, 5 tests

Config: ChatConfig.WebhookAddr added for webhook listen address.
All 39 packages pass with -race.

Closes abg.5.3, abg.34.
2026-07-26 10:39:58 +10:00
sam b261ee4b91 feat: context compression for long-running sessions
CompressionConfig with threshold-based triggering (default 50% of 128k window).
Protects first 3 and last 20 messages. Truncated middle replaced with statistical
summary (turns, tokens removed, topic range). CompressHistory() returns
CompressedView with before/after token counts. Integrated into Telegram
LLMResponder — fetches 100-message window, compresses before LLM call.

Matches Hermes config: threshold=0.5, protect_first=3, protect_last=20.
All 38 packages pass with -race.

Closes abg.33.
2026-07-26 10:36:24 +10:00
sam 8d4f4eb89d feat: verify Telegram topic thread support — already functional
ThreadID flows end-to-end: Telegram update → gateway.Message →
sessionKey() → NellDB session store → reply routing. Added
updateThreadID() helper for middleware logging. All 38 pass.
2026-07-26 10:34:26 +10:00
sam 948efde036 feat: session persistence — message storage, history retrieval, search
SessionStore extended with SaveMessage, RecentMessages, SearchMessages.
NellDB-backed implementation uses a separate DocDB collection for messages
keyed by session:seq. Conversation history loaded into LLM context for each
Telegram message. Responses persisted. Substring search fallback (vector
search deferred to memory provider embedding integration).

Adapter.Store() exported to share the underlying NellDB engine for session
collections without opening a second log.

Telegram LLMResponder now:
- Saves inbound messages to session store
- Loads 20 most recent messages as chat.Message history
- Sends full conversation context to llm.Chat()
- Persists the assistant response

All 38 packages pass with -race.
2026-07-26 10:33:13 +10:00
sam 0314955587 feat: wire memory, guardrails, and tool registry into daemon agent loop
Memory:
- MemoryManager created in main.go with built-in file-backed provider
- SystemPromptBlock() injected into every agent stage request via ExtraRules
- memoryPrompt() helper on Daemon, threaded through TaskContext.SystemPrompt

Guardrails:
- GuardrailEngine created from DefaultGuardrailConfig in main.go
- RecordSuccess/RecordFailure called after every agent stage run
- Threaded through TaskContext.Guardrails for per-task guardrail enforcement

Tool registry:
- NewRegistry() created at startup, MCP servers started from config
- Passed to Daemon.ToolRegistry for dynamic tool discovery

Daemon changes:
- Memory, Guardrails, ToolRegistry fields added (nil-safe, backward compat)
- TaskContext gains SystemPrompt + Guardrails fields
- Agent stage injects memory context into ExtraRules
- Agent stage records guardrail state after each run

Telegram LLM routing deferred (TODO comment) — gateway commands work.
All 38 packages pass with -race.
2026-07-26 10:25:07 +10:00
sam e8f78dd0d5 test: regression tests for all audit gaps — 6 enhanced + 4 new packages
Telegram: splitLongMessage (8 cases), isChatAllowed, updateMetadata (4 cases),
  panicRecoveryMiddleware, updateLoggingMiddleware, authorizedMessage, stop-while-stopped
Container: error paths, payload round-trip, overwrite, minimal payload
Events: buffer defaults, subscribe-after-close, double-close safety,
  slow-subscriber isolation, multi-subscriber ordering, publish timestamping
NATS RPC: envelope edge cases, JSON round-trip, request timeout, rollback
NellDB: empty store (6 ops), concurrent enqueue/claim (20 goroutines),
  context cancellation, oversized payload clipping, unmarshalable data,
  status transitions, events ordering, recover stale, clear terminal
Gateway tasks: empty/long title, idempotent enqueue, chat label

New packages with tests (formerly zero-test):
  internal/gate (220 lines), internal/gate/gateextract,
  internal/plugin/pluginextract, internal/workflow/wfextract

All 37 packages pass. Fixes regression gaps from audit.
2026-07-26 10:05:44 +10:00
sam 8356863712 feat: Tools P1 — guardrails, classification, budget, availability, disclosure, dispatch
- ToolCallGuardrailConfig + GuardrailEngine with RecordSuccess/RecordFailure
- ToolClassification bitmask (idempotent/mutating) with dispatch gating
- TurnBudget for token/char accounting with spill-to-disk
- AvailabilityCache with TTL + failure grace window
- Progressive disclosure engine for tool schema filtering
- Tool dispatch executor with parallel/serial classification
- RecordSuccess fix: now returns GuardrailDecision (no-progress threshold)
- All tests pass with -race, 58 new test functions across 6 test files
2026-07-26 09:53:38 +10:00
sam f6d51416f0 chore: replace 607 em-dashes with double hyphens project-wide
Includes MCP crash-after-init test fix (crash moved from handle() to serve()
entry point so transport sees immediate subprocess death).
2026-07-26 09:53:33 +10:00
sam 52cc8f8a14 feat: memory P1 — sync pipeline, prefetch, notify, frozen snapshot, threat scanning, shutdown drain (18.7-18.9, 18.14-18.16)
sync.go — background serialized writer (single goroutine) for async
memory writes. Prefetch with 8s timeout per provider.

scanner.go — threat pattern scanning for memory content.

manager.go — notify_memory_tool_write bridging built-in writes to
external providers. Shutdown drain with 5s timeout.

All 6 impl + 6 verify beads closed. Memory epic complete.
2026-07-26 09:22:12 +10:00
sam 942deb9336 feat: built-in file-backed memory tool (18.12, 18.13)
internal/memory/builtin/provider.go — MemoryProvider backed by
MEMORY.md + USER.md files. LLM-callable memory tool with
add/replace/remove actions using section-sign delimited entries
and substring matching.

internal/memory/builtin/store.go — file read/write with atomic
replace and chmod 0600.
2026-07-26 08:58:27 +10:00
sam e8fe1b12a7 feat: tool schema normalization for memory providers (18.11)
internal/memory/schema.go — normalizes memory-provider-exported
tool schemas between bare and wrapped OpenAI formats. Handles
both function-call wrapper objects and bare name+description+params
shapes. Converges to a consistent internal representation.
2026-07-26 08:58:26 +10:00
sam bff3c40ca9 merge: integrate memory infrastructure features (StreamingContextScrubber, schema normalization, built-in store, memory edit actions)
Resolve conflict in `.beads/` tracking files and scrubber implementation:
- Accept 8642f40's full implementation of StreamingContextScrubber with io.Writer interface, partial chunk boundary handling, nested tags, zero-alloc fast path, and comprehensive tests.
- Take incoming changes for issues tracking: close multiple verification tasks (18.10–18.13, 18.23–18.26) after adversarial review, update status for in-progress tasks (18.17, 18.18).
2026-07-26 02:26:25 +10:00
sam d48953d9e7 fix: Flush() leaking in-block content when stream ends mid-close-tag
Pending bytes buffered while inside a <memory> block were unconditionally
emitted as literal text by Flush, leaking hidden memory-context content
into visible streamed output when a stream cut off mid-tag (e.g. "...secret</mem").
Track pendingInBlock at capture time so Flush discards in-block pending
bytes instead of emitting them. Also corrects stale doc comments claiming
underlying writer errors are surfaced (they're intentionally discarded).

Found by adversarial review of 18.10.
2026-07-26 02:11:28 +10:00
sam 886591f674 feat: StreamingContextScrubber for memory-context fence stripping (18.10)
Stateful io.Writer that strips <memory>...</memory> fences from
streaming output, handling partial chunks split across tag
boundaries, nested tags, and missing closing tags.
2026-07-26 02:08:10 +10:00
sam f0c2a3eda5 beads: sync memory verification fixes + beads state 2026-07-26 01:57:41 +10:00
sam 0746950cb7 fix: MCP transport framing + crash retry + test harness (17.16)
framing.go: documented that readMessage caller must manage the
bufio.Reader lifetime. Creating a new bufio.Reader per call silently
drops buffered data and breaks multi-message streams.

transport.go: added crashCount check alongside startupFailures for
the MaxRetries limit — crash-looping subprocesses (spawn succeeds
but process immediately dies) now count toward the retry cap.

transport_test.go: replaced os.Exit(1) with syscall.Exit(1) in
crash-after-init behavior — Go's test harness intercepts os.Exit
and panics instead of exiting, keeping the process and its pipes
alive indefinitely. Replaced os.Exit(0) with runtime.Goexit() in
TestMCPServerHelper for clean goroutine exit.

Framing multiple-message test passes. Crash retry tests may need
further debugging in the transport spawn/reader lifecycle.
2026-07-26 01:57:41 +10:00
sam 3b9c280b12 wip: MCP transport types + framing + tests (17.16 partial)
Deepseek workflow ran before hitting session limit. Delivered:
  types.go — TransportState enum, JSON-RPC 2.0 Request/Response/Error
  framing.go — Content-Length header framing (LSP-compatible, 4MB max)
  transport_test.go — 585 lines of tests (red: implementation missing)

Memory verification fixes also included (lifecycle, manager, test updates).

transport.go still needed — the main MCPServer Connect/Disconnect
implementation. Tests are written, implementation is ~200 lines.
2026-07-26 01:40:05 +10:00
sam 156453cf74 fix: tool registry — 8 bugs from adversarial review (17.1, 17.2)
Verification review found 8 bugs, all fixed with regression tests:
  - Available() deadlock: CheckFn evaluated outside RLock
  - Register() shared references: Clone() defensive copy before storage
  - Clone() shallow nested schemas: deepCopyAny for maps/arrays
  - stringLit: no backtick/escape handling → strconv.Unquote
  - intLit: no negative/hex/octal/binary → strconv.ParseInt
  - Discover: abort on first error → Continue + errors.Join
  - isRegisterCall: too broad → only DefaultRegistry() calls match
  - schemaLit: only string values → handle ints, bools, nested maps

38 tests pass. All 34 packages green. golangci-lint + gofmt clean.

Closes: archie-core-abg.17.1, 17.2
2026-07-26 01:31:17 +10:00
sam bc1caf67aa feat: BasePlatformAdapter interface + Session types (16.3, 16.5, 16.9, 16.10, 16.11)
adapter.go — SendResult struct (success, message_id, error, retryable,
retry_after, continuation_message_ids, error_kind), ChatInfo struct
(name, type, chat_id, thread_id), BasePlatformAdapter interface
(Connect, Disconnect, Send, ChatInfo).

session.go — SessionSource (platform, chat_id/name/type, user_id/name,
thread_id, guild_id, scope_id, profile, is_bot, metadata) with Key()
for deterministic session key. SessionContext wrapping source with
connected_platforms, home_channels, session_key/id, timestamps.

session_store.go — SessionStore interface (GetOrCreate, Get, Reset,
List, GetByChannel, Touch, Delete, Close) + nellSessionStore backed
by nell.DocDB with mutex-guarded Save/Delete for race safety.

Verification: 4 findings fixed (gofmt alignment, race on mutex,
!= true anti-pattern, missing zero-value assertions). 58 tests pass
(incl -race), go vet + gofmt + golangci-lint clean.

Closes: archie-core-abg.16.3, 16.5, 16.9, 16.10, 16.11
2026-07-26 01:29:36 +10:00
sam 30b76f2ead feat: MessageType enum + MessageEvent struct (16.1, 16.2)
internal/gateway/messagetype.go — 14-value MessageType enum with
IsMedia(), IsRich(), IsEphemeral() classification helpers.

internal/gateway/messageevent.go — platform-neutral MessageEvent:
text, type, media attachments (file metadata, dimensions, duration),
reply context (message ID, text, author), editing support (edited
flag, edit timestamp), capability flags (streaming, code blocks).

Verification agent found 7 issues, 5 fixed (pointer types for
FileSize/Width/Height/Duration, MsgSticker in IsMedia, IsRich
coverage, ToLegacy edge cases), 2 correctly deferred.

42 tests pass. Build + vet + fmt clean.

Closes: archie-core-abg.16.1, archie-core-abg.16.2
2026-07-26 01:19:38 +10:00
sam b61b736f77 feat: tool registry package stub (archie-core-abg.17) 2026-07-26 01:08:02 +10:00
sam 4c1cc151a5 feat: NellDB storage backend replacing SQLite (archie-core-abg.30)
Extracted store.TaskStore interface (20 methods) covering task
lifecycle, queries, and observability. Separate WorkflowStore for
the agent RPC proxy.

New internal/nell/ package:
  - OpenStore(path, nodeID) — persistent logstore.LogStore backend
  - OpenMemory(nodeID) — in-memory store for tests
  - Full TaskStore implementation via sdk.DocDB with MVCC

All consumers updated to interface:
  - daemon.Daemon.Store, webui.Server.Store, storerpc.Server.Store
  - workflow.TaskContext.Store (WorkflowStore)
  - cmd/archied uses nell.OpenStore(cfg.DBPath, cfg.BotUser)

7 integration tests. Build + 32 packages pass.

Closes: archie-core-abg.30
2026-07-26 01:06:05 +10:00
sam 54e21bfbde feat: feature-based YAML config with conf.d/ (LoadDir API)
Implemented archie-core-abg.19 — split monolithic config.toml into
modular feature files:

  config.yaml              — daemon-level fields
  conf.d/gateway.yaml      — chat channels, platforms
  conf.d/tools.yaml        — MCP servers, tool policy
  conf.d/memory.yaml       — memory provider config
  conf.d/models.yaml       — LLM providers and models
  conf.d/identities.yaml   — identity configs

New API: LoadDir(baseDir, overlayDir string) (Config, error)
  - Missing files = feature disabled (no error)
  - Legacy config.toml fallback when config.yaml absent
  - Overlay merges on top of base
  - Validation: unknown/duplicate/malformed files rejected
  - YAML tags added to all 14 config types
  - New types: MemoryConfig, ToolsConfig, MCPServer, ToolPolicy
  - Extra map[string]any for conf.d/ plugins

28 tests green. Build + full config suite passes.

Closes: archie-core-abg.19
2026-07-26 01:04:35 +10:00
sam 415065ac66 test: feature-based config contract (28 tests for archie-core-abg.19)
Defines the LoadDir(baseDir, overlayDir) (Config, error) API:
  - Daemon config in config.yaml
  - Feature files in conf.d/ (Linux convention): gateway, tools,
    memory, models, identities
  - Missing files = feature disabled (no error)
  - Legacy config.toml fallback when config.yaml absent
  - Overlay merges on top of base
  - Validation: unknown/duplicate/malformed files rejected
  - New types: MemoryConfig, ToolsConfig, MCPServer, ToolPolicy

28 red tests — awaiting implementer.
2026-07-26 00:54:26 +10:00
sam ae744d1cc4 feat: /spawn gateway command for chat-initiated tasks
TaskCreator interface on gateway.Router allows chat users to create
tasks via /spawn <title>. Implemented as gateway-local command (no LLM
needed). StoreTaskCreator wraps the daemon's store and uses the first
configured repo as the task workspace with timestamp-based synthetic
issue numbers to avoid collisions with Gitea-issued tasks.

Wired into archied's gateway startup: when repos are configured,
router.Tasks is populated so /spawn works. When no repos are
configured, /spawn returns 'not configured'.

Closes: archie-core-abg.13
2026-07-25 23:54:06 +10:00
sam 9df02f2b60 fix: golangci-lint baseline to zero findings (39→0)
19 files touched. All fixes are in code — no lint configuration
weakened:
- Added unchecked error handling in defer cleanup paths
- Removed dead variables and unused functions
- Added missing imports (io in gitea.go)
- Simplified conditions (TrimSuffix, De Morgan, slices.Contains)

Also fixes JetStream TempDir teardown race (archie-core-340):
t.Cleanup(srv.Shutdown) now registers after t.TempDir() so
server shutdown (including JetStream files) completes before
temp dir removal. Added srv.WaitForShutdown() for deterministic
cleanup ordering.

Closes: archie-core-756, archie-core-340
2026-07-25 23:51:13 +10:00
sam 399ca66e32 feat: multi-identity daemon config and core
internal/config/ — IdentityConfig struct for [[identities]] TOML
array. Backward-compatible: empty Identities uses legacy
single-identity fields unchanged. Validation for identity name,
bot_user, repos, forge type.

internal/daemon/ — IdentityRunner bundles per-identity forge client,
worktree manager, repos, and config. NewIdentityRunner constructor.
Run() starts one goroutine per identity with independent poll loops
for failure isolation. cycleForIdentity() polls identity repos via
dedicated forge client and drains shared store.

Design decision: per-identity goroutine with shared infrastructure
(store, NATS, container pool, event bus, web UI, plugin registry).

Closes: archie-core-abg.3, archie-core-abg.4
2026-07-25 23:50:58 +10:00
sam f36b6f2e41 feat: gateway architecture with Telegram channel
internal/gateway/ — Gateway interface, Router with gateway-local
command dispatch (commands handled directly, no LLM needed).
ModelManager interface for /model and /models support.

internal/channels/telegram/ — Telegram Gateway using go-telegram/bot
v1.18.0 (ported from GopherClaw). Webhook support, middleware,
allowed-chat filtering, long-message splitting.

internal/config/ — ChatConfig + TelegramConfig optional TOML block.

Cmd wiring in archied/main.go: starts Telegram gateway when
[chat.telegram] token_env is configured.

Gateway-local commands implemented: /status, /help, /model, /models.
Write actions (/spawn, /approve, /cancel) follow in abg.13.

Closes: archie-core-abg.5, archie-core-abg.14, archie-core-abg.15
2026-07-25 23:50:52 +10:00
sam 1975a3d842 Merge branch 'main' into feat/56-duplicate-workflow-warning-fires-on-normal-builtin-overrides 2026-07-25 08:53:02 +00:00
sam c603b3596d Merge branch 'main' into feat/55-esc-misses-single-quotes-enabling-attribute-js-breakout-in-t 2026-07-25 01:29:59 +00:00
sam af9203bbd4 Merge branch 'main' into feat/50-metadataarchieplugins-frontmatter-list-is-parsed-but-unused 2026-07-25 01:29:41 +00:00
sam 9c731710b3 Merge branch 'main' into fix/49-gofmt-fix-misaligned-taskref-struct-fields-in-storagego 2026-07-25 01:29:13 +00:00
archie f83380e1bf clip() can truncate strings mid-rune, producing invalid UTF-8 (archie)
Implements #47
2026-07-24 18:06:37 +00:00
archie 6f72f38f5e fix: baseline gate repair (go vet ./...) 2026-07-24 18:04:15 +00:00
archie 8e76e5c7b3 fix: gofmt: fix misaligned TaskRef struct fields in storage.go (archie)
Fixes #49
2026-07-24 17:52:33 +00:00
archie af17f4cd66 test: failing repro for #49 2026-07-24 17:51:39 +00:00
archie ca92e24008 fix: baseline gate repair (go vet ./...) 2026-07-24 17:47:19 +00:00
archie 69b317a7c2 metadata.archie.plugins frontmatter list is parsed but unused (archie)
Implements #50
2026-07-24 17:42:17 +00:00