refactor: remove dead BasePlatformAdapter code
This commit is contained in:
1 parent
29fba1740f
commit
d998c33b0d
5 files changed
+5
-240
No files matched your search
@@ -43,3 +43,4 @@
|
||||
{"id":"int-389951a8f299a389cbb0432044362797","kind":"field_change","created_at":"2026-08-22T11:55:19.903017141Z","actor":"Sam Catlow","issue_id":"archie-core-1ysw.3","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Retry refresh now removes all non-HEAD worktree content including ignored output while preserving .git, tracked symlinks, and gitlinks; missing bases fail closed."}}
|
||||
{"id":"int-56c541cf59441d3b82a65bc0ee53e38c","kind":"field_change","created_at":"2026-08-22T11:55:20.137923996Z","actor":"Sam Catlow","issue_id":"archie-core-1ysw.4","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Retry refresh now removes all non-HEAD worktree content including ignored output while preserving .git, tracked symlinks, and gitlinks; missing bases fail closed."}}
|
||||
{"id":"int-91757c22c0f3dff173e70e5eeff9447c","kind":"field_change","created_at":"2026-08-22T11:59:36.859035164Z","actor":"Sam Catlow","issue_id":"archie-core-1ysw.5","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Three-dot diff operations now fail closed when base and HEAD have no common ancestor; regression covers Diff, ChangedFiles, and ChangedLines."}}
|
||||
{"id":"int-2fceaface0b1804f99343a043a446532","kind":"field_change","created_at":"2026-08-22T12:16:02.43722871Z","actor":"Sam Catlow","issue_id":"archie-core-azbo","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Removed the unwired BasePlatformAdapter, SendResult, ChatInfo, and their test-only stub. CapabilitiesOf is absent from the current checkout/history. Gateway and worktree tests pass. task check passes all packages except the pre-existing tracked agentworker architecture failure archie-core-hqst."}}
|
||||
+2
-2
@@ -40,8 +40,8 @@
|
||||
{"_type":"issue","id":"archie-core-g7tm","title":"telegram: finalize the reply through a live context, matching the error branch","description":"The success path calls live.finalize(turnCtx, reply) with the raw cancellable turn context (telegram.go:582), while the error branch two lines above deliberately uses context.WithoutCancel(turnCtx). If /stop lands during finalize, the rich edit, the plain-text retry, and the split-send fallback all abort with context.Canceled (go-telegram/bot builds requests with NewRequestWithContext), so the authoritative reply is never delivered and the live message keeps the ▌ cursor forever. The reply is persisted to the ledger, so the loss is delivery-level — but the user sees a frozen half-answer.\n\nFailure: a long tool-using turn is /stop-ped as it completes; turnCtx is cancelled mid-finalize; every send fails on the dead context; the chat shows the last live frame with a blinking cursor and no final answer.\n\nFound by code-review of PR #476 (feat/467, merged 98e8dda).","design":"live.finalize(context.WithoutCancel(turnCtx), reply) — the one-liner the error branch already uses. Consider making finalize take a live context internally rather than trusting each caller to remember.","acceptance_criteria":"A /stop landing mid-finalize still delivers the authoritative reply and drops the cursor; a test covers the cancellable-context finalize path.","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-14T14:43:08Z","created_by":"Sam Catlow","updated_at":"2026-08-14T15:07:36Z","started_at":"2026-08-14T14:53:28Z","closed_at":"2026-08-14T15:03:28Z","close_reason":"Fixed in internal/channels/telegram/live.go and telegram.go: finalize/abandon strip context cancellation before sending (mirroring each other), ToolCall escapes Markdown metacharacters via bot.EscapeMarkdown, splitLongMessage splits on rune boundaries. All new/changed tests verified red-then-green; task check clean; adversarial review pass found no blocking issues.","external_ref":"https://github.com/samcharles93/archie-core/issues/484","labels":["code-review","streaming","telegram"],"dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-tb3a","title":"Fix streaming review blockers for inline tool calls","description":"Resolve the four evidence-gated findings in merged inline tool-call streaming: preserve the authoritative Telegram reply when final edits fail; keep Telegram network I/O off the model FullStream consumer and cancellable; correlate tool inputs with results and render a bounded redacted parameter summary; snapshot show_tool_calls per live reply to avoid reload races. Add regression tests for every path and run task check plus lint/race validation.","acceptance_criteria":"Regression tests fail on the merged implementation and pass after the fix. Final edit failure falls back to normal split delivery. Delta and ToolCall callbacks do not wait on Telegram HTTP and stop cancels in-flight rendering. Completed tool events include bounded redacted parameters correlated by tool-call ID. Reload cannot race an in-flight reply's show_tool_calls setting. task check passes, golangci-lint reports no new findings, and focused race tests pass.","notes":"Implemented in worktree /tmp/archie-core-tb3a on branch fix/archie-core-tb3a. Added cancellable async Telegram rendering, final edit failure fallback through normal split delivery, call-ID-correlated bounded conservative parameter summaries, atomic per-reply show_tool_calls snapshots, SSE/UI parameter rendering, rebuilt ui/dist, and regression tests. Validation: GOFLAGS=-buildvcs=false task check passed; golangci-lint --new-from-rev=HEAD ./... reported 0 issues; focused race suite passed; fresh adversarial reviewer reported PASS with zero findings. Plain task check is blocked in linked worktrees by Go VCS stamping exit 128, hence buildvcs override.","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-13T18:05:35Z","created_by":"Sam Catlow","updated_at":"2026-08-14T15:07:36Z","started_at":"2026-08-13T18:05:39Z","closed_at":"2026-08-13T18:35:26Z","close_reason":"Completed and independently reviewed; worktree left uncommitted per conservative repository policy.","external_ref":"https://github.com/samcharles93/archie-core/issues/485","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-dzx","title":"Remove duplicate archie-agent safe.directory setup","description":"## Problem\\ncmd/archie-agent/main.go configures git safe.directory inline and then calls markWorktreeSafe, so startup writes the same global git configuration twice.\\n\\n## Scope\\nKeep markWorktreeSafe as the single tested production path and remove the older inline exec.Command block/import. Add regression coverage proving startup wiring has exactly one authoritative safe-directory call.\\n\\n## Acceptance\\n- archie-agent startup invokes markWorktreeSafe exactly once\\n- no second inline safe.directory command remains in main.go\\n- cmd/archie-agent tests and repository quality gate pass","acceptance_criteria":"Single tested safe.directory setup path remains; duplicate inline command is removed; tests and task check pass","notes":"Red proof: TestMainConfiguresWorktreeSafetyOnce failed with 2 setup paths before implementation. Green proof: go test/vet/build ./cmd/archie-agent/... passed; golangci-lint --new-from-rev=HEAD reported 0 issues. Fresh adversarial review found no blockers. Full task check was not run because the working tree contains unrelated in-progress changes and task check rewrites files; scoped package gate used per repository protocol.","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-13T16:10:09Z","created_by":"Sam Catlow","updated_at":"2026-08-13T16:13:48Z","started_at":"2026-08-13T16:10:24Z","closed_at":"2026-08-13T16:13:48Z","close_reason":"Removed duplicate inline safe.directory setup; markWorktreeSafe is now the single tested production path","external_ref":"https://github.com/samcharles93/archie-core/issues/470","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-azbo","title":"Remove dead BasePlatformAdapter interface from internal/gateway","description":"`gateway.BasePlatformAdapter` (internal/gateway/adapter.go, Connect/Disconnect/Send/ChatInfo) is implemented by nothing outside its own test stub. It landed in commit bc1caf6 alongside the Session types and was never wired.\n\nEvery live channel instead implements `channels.Channel` (= `gateway.Gateway`: Name/Start/Stop, plus ConfigSchema/ValidateConfig) -- asserted at internal/channels/telegram/telegram.go:1229, internal/channels/email/email.go:389, internal/channels/webhook/webhook.go:224. So the repo carries two parallel channel abstractions and the newer one is inert.\n\nIt also has an internal contradiction that is likely why it was never implemented: the doc comment says the daemon instantiates 'one adapter per active bot identity x platform' (adapter.go:59) but `ChatInfo(ctx) (ChatInfo, error)` is documented as 'static metadata about the conversation a platform adapter is connected to' (adapter.go:36-38) with no chat argument. Telegram's Gateway is a single instance serving many chats, so ChatInfo(ctx) has no single answer. Send(ctx, MessageEvent) is fine for both models since MessageEvent carries ChannelID; ChatInfo is the part that only makes sense per-conversation.\n\nOutbound delivery is assigned to the not-yet-built `internal/domain/messaging` by docs/architecture/migration-decisions.md section 2, so this interface should not be revived in place -- it should be deleted and its intent re-expressed there.\n\n## Scope\n\n- Delete BasePlatformAdapter and its test stub from internal/gateway/adapter.go / adapter_test.go.\n- Keep SendResult and ChatInfo structs if domain/messaging or the media work still wants them; they are separable from the interface.\n- Decouple gateway.CapabilitiesOf from BasePlatformAdapter (it currently takes one) so the capability mechanism survives the removal.\n\n## Acceptance criteria\n\n- BasePlatformAdapter no longer exists; `task check` passes.\n- No behaviour change: nothing implemented it, so nothing should need rewiring.\n- Any type retained from adapter.go has at least one live consumer, or is removed too.","status":"open","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-08-22T12:04:10Z","created_by":"Sam Catlow","updated_at":"2026-08-22T12:04:10Z","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-hqst","title":"TestApplicationOwnsNoTransportWireMechanics fails: persistent_runner.go imports encoding/json","description":"internal/app/agentworker/architecture_test.go's TestApplicationOwnsNoTransportWireMechanics fails on main (pre-existing, unrelated to archie-core-qk8m): persistent_runner.go imports encoding/json, tripping the check that agentworker's app layer owns no transport wire mechanics. Introduced by e351581 (feat(storage): persist agent project state). Confirmed via git stash that this fails identically with none of the mcp-npm-cache changes applied.","status":"open","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-08-22T11:09:58Z","created_by":"Sam Catlow","updated_at":"2026-08-22T11:09:58Z","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-azbo","title":"Remove dead BasePlatformAdapter interface from internal/gateway","description":"`gateway.BasePlatformAdapter` (internal/gateway/adapter.go, Connect/Disconnect/Send/ChatInfo) is implemented by nothing outside its own test stub. It landed in commit bc1caf6 alongside the Session types and was never wired.\n\nEvery live channel instead implements `channels.Channel` (= `gateway.Gateway`: Name/Start/Stop, plus ConfigSchema/ValidateConfig) -- asserted at internal/channels/telegram/telegram.go:1229, internal/channels/email/email.go:389, internal/channels/webhook/webhook.go:224. So the repo carries two parallel channel abstractions and the newer one is inert.\n\nIt also has an internal contradiction that is likely why it was never implemented: the doc comment says the daemon instantiates 'one adapter per active bot identity x platform' (adapter.go:59) but `ChatInfo(ctx) (ChatInfo, error)` is documented as 'static metadata about the conversation a platform adapter is connected to' (adapter.go:36-38) with no chat argument. Telegram's Gateway is a single instance serving many chats, so ChatInfo(ctx) has no single answer. Send(ctx, MessageEvent) is fine for both models since MessageEvent carries ChannelID; ChatInfo is the part that only makes sense per-conversation.\n\nOutbound delivery is assigned to the not-yet-built `internal/domain/messaging` by docs/architecture/migration-decisions.md section 2, so this interface should not be revived in place -- it should be deleted and its intent re-expressed there.\n\n## Scope\n\n- Delete BasePlatformAdapter and its test stub from internal/gateway/adapter.go / adapter_test.go.\n- Keep SendResult and ChatInfo structs if domain/messaging or the media work still wants them; they are separable from the interface.\n- Decouple gateway.CapabilitiesOf from BasePlatformAdapter (it currently takes one) so the capability mechanism survives the removal.\n\n## Acceptance criteria\n\n- BasePlatformAdapter no longer exists; `task check` passes.\n- No behaviour change: nothing implemented it, so nothing should need rewiring.\n- Any type retained from adapter.go has at least one live consumer, or is removed too.","notes":"Discovery confirmed CapabilitiesOf is absent from the current checkout and gateway history. SendResult and ChatInfo have no live consumers, so all three legacy declarations are removed. Red test: TestLegacyPlatformAdapterTypesAreRemoved failed on BasePlatformAdapter, ChatInfo, and SendResult before deletion; gateway package suite passes after deletion. Full task check currently reaches one unrelated pre-existing failure: internal/app/agentworker TestApplicationOwnsNoTransportWireMechanics reports persistent_runner.go imports JSON wire encoding.","status":"closed","priority":2,"issue_type":"task","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-22T12:04:10Z","created_by":"Sam Catlow","updated_at":"2026-08-22T12:16:02Z","started_at":"2026-08-22T12:08:39Z","closed_at":"2026-08-22T12:16:02Z","close_reason":"Removed the unwired BasePlatformAdapter, SendResult, ChatInfo, and their test-only stub. CapabilitiesOf is absent from the current checkout/history. Gateway and worktree tests pass. task check passes all packages except the pre-existing tracked agentworker architecture failure archie-core-hqst.","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-hqst","title":"TestApplicationOwnsNoTransportWireMechanics fails: persistent_runner.go imports encoding/json","description":"internal/app/agentworker/architecture_test.go's TestApplicationOwnsNoTransportWireMechanics fails on main (pre-existing, unrelated to archie-core-qk8m): persistent_runner.go imports encoding/json, tripping the check that agentworker's app layer owns no transport wire mechanics. Introduced by e351581 (feat(storage): persist agent project state). Confirmed via git stash that this fails identically with none of the mcp-npm-cache changes applied.","status":"in_progress","priority":2,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-22T11:09:58Z","created_by":"Sam Catlow","updated_at":"2026-08-22T12:16:11Z","started_at":"2026-08-22T12:16:11Z","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-1ysw.9","title":"Align branch naming behavior, API, tests, and documentation","description":"branchPrefix ignores title and body despite the documented title-prefix contract, contains a checked-in lint-failing FIXME and a no-op, and branchSlug documents 40 characters while implementing 60.","acceptance_criteria":"The chosen title/label precedence is explicit and tested for unlabeled and conflicting inputs; dead parameters and no-op residue are removed; slug documentation and boundary tests agree with 60; scoped lint passes.","status":"open","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-08-22T11:01:48Z","created_by":"Sam Catlow","updated_at":"2026-08-22T11:01:48Z","dependencies":[{"issue_id":"archie-core-1ysw.9","depends_on_id":"archie-core-1ysw","type":"parent-child","created_at":"2026-08-22T21:01:48Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-1ysw.7","title":"Clean no-change worktrees at terminal completion","description":"BuildNoChanges transitions directly to merged without a PR, bypassing the only production worktree cleanup path and leaking a full clone.","acceptance_criteria":"Both direct and container no-change completion remove the identity-correct worktree while parked worktrees remain available; lifecycle regression tests cover the terminal path.","status":"open","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-08-22T11:01:47Z","created_by":"Sam Catlow","updated_at":"2026-08-22T11:01:47Z","dependencies":[{"issue_id":"archie-core-1ysw.7","depends_on_id":"archie-core-1ysw","type":"parent-child","created_at":"2026-08-22T21:01:46Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-1ysw.5","title":"Preserve three-dot failure semantics without a merge base","description":"patch silently computes a direct tree diff when base and HEAD have no merge base, contradicting its three-dot contract and corrupting diff-cap and gate inputs.","acceptance_criteria":"Unrelated histories return a clear error from Diff, ChangedFiles, and ChangedLines; shared-history merge-base behavior remains covered.","status":"closed","priority":2,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-22T11:01:46Z","created_by":"Sam Catlow","updated_at":"2026-08-22T11:59:37Z","started_at":"2026-08-22T11:55:44Z","closed_at":"2026-08-22T11:59:37Z","close_reason":"Three-dot diff operations now fail closed when base and HEAD have no common ancestor; regression covers Diff, ChangedFiles, and ChangedLines.","dependencies":[{"issue_id":"archie-core-1ysw.5","depends_on_id":"archie-core-1ysw","type":"parent-child","created_at":"2026-08-22T21:01:45Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
package gateway
|
||||
|
||||
import "context"
|
||||
|
||||
// SendResult captures the outcome of a Send operation through a platform
|
||||
// adapter. It classifies errors so callers can implement retry policies
|
||||
// without inspecting platform-specific error types.
|
||||
type SendResult struct {
|
||||
// MessageID is the platform-assigned identifier of the sent message.
|
||||
// Empty when the send failed before the platform acknowledged it.
|
||||
MessageID string
|
||||
|
||||
// Success is true when the platform accepted the message.
|
||||
Success bool
|
||||
|
||||
// Retryable is true when the error is transient -- rate limits, network
|
||||
// timeouts, temporary platform outages -- and the caller should retry
|
||||
// with backoff.
|
||||
Retryable bool
|
||||
|
||||
// Error is the underlying error when Success is false.
|
||||
Error error
|
||||
|
||||
// ErrorCode classifies the failure for observability and retry-policy
|
||||
// decisions. Values:
|
||||
//
|
||||
// "" -- no error (Success == true)
|
||||
// "rate_limited" -- platform rejected due to rate limiting
|
||||
// "network" -- connection lost or timeout
|
||||
// "auth" -- token expired or credentials invalid
|
||||
// "invalid_message" -- message content rejected by platform
|
||||
// "internal" -- unexpected adapter or platform error
|
||||
ErrorCode string
|
||||
}
|
||||
|
||||
// ChatInfo is static metadata about the conversation a platform adapter is
|
||||
// connected to. Adapters return this from ChatInfo() so callers can display
|
||||
// context without knowing platform internals.
|
||||
type ChatInfo struct {
|
||||
// ID is the platform-specific chat identifier.
|
||||
ID string
|
||||
|
||||
// Title is the human-readable chat name (group title, DM username,
|
||||
// channel name).
|
||||
Title string
|
||||
|
||||
// Type is the chat kind: "private", "group", "channel", "supergroup".
|
||||
Type string
|
||||
|
||||
// Platform names the adapter ("telegram", "discord", "web").
|
||||
Platform string
|
||||
}
|
||||
|
||||
// BasePlatformAdapter is the interface every platform adapter must implement.
|
||||
// Each implementation owns its connection lifecycle and translates
|
||||
// platform-specific events into the shared MessageEvent model.
|
||||
//
|
||||
// The daemon instantiates one adapter per active bot identity × platform and
|
||||
// calls Connect to start the event loop. Inbound messages are delivered to a
|
||||
// shared handler; outbound messages flow through Send.
|
||||
type BasePlatformAdapter interface {
|
||||
// Connect establishes the persistent connection and starts the inbound
|
||||
// message loop. It blocks until ctx is cancelled or the connection
|
||||
// fails irrecoverably. Implementations should reconnect transient
|
||||
// failures internally.
|
||||
Connect(ctx context.Context) error
|
||||
|
||||
// Disconnect gracefully tears down the connection. After Disconnect
|
||||
// returns the adapter may be reused by calling Connect again.
|
||||
Disconnect(ctx context.Context) error
|
||||
|
||||
// Send delivers a message event to the platform. The returned
|
||||
// SendResult classifies the outcome so callers can decide whether
|
||||
// to retry.
|
||||
Send(ctx context.Context, event MessageEvent) (SendResult, error)
|
||||
|
||||
// ChatInfo returns static metadata about the connected conversation.
|
||||
// Useful for logging, status displays, and multi-bot dashboards.
|
||||
ChatInfo(ctx context.Context) (ChatInfo, error)
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// stubAdapter is a minimal BasePlatformAdapter for testing.
|
||||
type stubAdapter struct {
|
||||
info ChatInfo
|
||||
}
|
||||
|
||||
func (s *stubAdapter) Connect(ctx context.Context) error { return nil }
|
||||
func (s *stubAdapter) Disconnect(ctx context.Context) error { return nil }
|
||||
func (s *stubAdapter) Send(ctx context.Context, e MessageEvent) (SendResult, error) {
|
||||
return SendResult{Success: true, MessageID: "msg-1"}, nil
|
||||
}
|
||||
|
||||
func (s *stubAdapter) ChatInfo(ctx context.Context) (ChatInfo, error) {
|
||||
return s.info, nil
|
||||
}
|
||||
|
||||
var _ BasePlatformAdapter = (*stubAdapter)(nil)
|
||||
|
||||
func TestSendResult_Success(t *testing.T) {
|
||||
sr := SendResult{
|
||||
MessageID: "abc123",
|
||||
Success: true,
|
||||
}
|
||||
if !sr.Success {
|
||||
t.Error("expected Success to be true")
|
||||
}
|
||||
if sr.MessageID != "abc123" {
|
||||
t.Errorf("expected MessageID abc123, got %s", sr.MessageID)
|
||||
}
|
||||
if sr.ErrorCode != "" {
|
||||
t.Error("expected empty ErrorCode for success")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSendResult_RateLimited(t *testing.T) {
|
||||
sr := SendResult{
|
||||
Success: false,
|
||||
Retryable: true,
|
||||
Error: errors.New("rate limited: retry after 30s"),
|
||||
ErrorCode: "rate_limited",
|
||||
}
|
||||
if sr.Success {
|
||||
t.Error("expected Success to be false")
|
||||
}
|
||||
if !sr.Retryable {
|
||||
t.Error("expected Retryable to be true for rate_limited")
|
||||
}
|
||||
if sr.ErrorCode != "rate_limited" {
|
||||
t.Errorf("expected ErrorCode rate_limited, got %s", sr.ErrorCode)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSendResult_NetworkError(t *testing.T) {
|
||||
sr := SendResult{
|
||||
Success: false,
|
||||
Retryable: true,
|
||||
Error: errors.New("connection refused"),
|
||||
ErrorCode: "network",
|
||||
}
|
||||
if sr.ErrorCode != "network" {
|
||||
t.Errorf("expected ErrorCode network, got %s", sr.ErrorCode)
|
||||
}
|
||||
if !sr.Retryable {
|
||||
t.Error("expected network errors to be retryable")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSendResult_AuthError(t *testing.T) {
|
||||
sr := SendResult{
|
||||
Success: false,
|
||||
Retryable: false,
|
||||
Error: errors.New("token expired"),
|
||||
ErrorCode: "auth",
|
||||
}
|
||||
if sr.Retryable {
|
||||
t.Error("expected auth errors to be non-retryable")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSendResult_InvalidMessage(t *testing.T) {
|
||||
sr := SendResult{
|
||||
Success: false,
|
||||
Retryable: false,
|
||||
Error: errors.New("message too long"),
|
||||
ErrorCode: "invalid_message",
|
||||
}
|
||||
if sr.Retryable {
|
||||
t.Error("expected invalid_message to be non-retryable")
|
||||
}
|
||||
}
|
||||
|
||||
func TestChatInfo_Fields(t *testing.T) {
|
||||
ci := ChatInfo{
|
||||
ID: "chat-42",
|
||||
Title: "Engineering",
|
||||
Type: "group",
|
||||
Platform: "telegram",
|
||||
}
|
||||
if ci.ID != "chat-42" {
|
||||
t.Errorf("expected ID chat-42, got %s", ci.ID)
|
||||
}
|
||||
if ci.Title != "Engineering" {
|
||||
t.Errorf("expected Title Engineering, got %s", ci.Title)
|
||||
}
|
||||
if ci.Type != "group" {
|
||||
t.Errorf("expected Type group, got %s", ci.Type)
|
||||
}
|
||||
if ci.Platform != "telegram" {
|
||||
t.Errorf("expected Platform telegram, got %s", ci.Platform)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBasePlatformAdapter_Stub(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
a := &stubAdapter{info: ChatInfo{
|
||||
ID: "ch-1",
|
||||
Title: "test-chat",
|
||||
Type: "private",
|
||||
Platform: "web",
|
||||
}}
|
||||
|
||||
if err := a.Connect(ctx); err != nil {
|
||||
t.Errorf("Connect: %v", err)
|
||||
}
|
||||
|
||||
ci, err := a.ChatInfo(ctx)
|
||||
if err != nil {
|
||||
t.Fatalf("ChatInfo: %v", err)
|
||||
}
|
||||
if ci.Title != "test-chat" {
|
||||
t.Errorf("expected Title test-chat, got %s", ci.Title)
|
||||
}
|
||||
|
||||
sr, err := a.Send(ctx, MessageEvent{Type: MsgText, Text: "hi"})
|
||||
if err != nil {
|
||||
t.Fatalf("Send: %v", err)
|
||||
}
|
||||
if !sr.Success {
|
||||
t.Error("expected Send to succeed")
|
||||
}
|
||||
|
||||
if err := a.Disconnect(ctx); err != nil {
|
||||
t.Errorf("Disconnect: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -211,12 +212,7 @@ func repositoryUsesURL(dir, want string) bool {
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
for _, got := range remote.URLs {
|
||||
if got == want {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(remote.URLs, want)
|
||||
}
|
||||
|
||||
// refresh brings an already-prepared worktree back in line with the
|
||||
|
||||
Reference in new issue
Block a user