Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae7d3852e2 | ||
|
|
3878dddaa7 |
@@ -158,7 +158,10 @@ deleted it, FK SET NULL) re-links every still-tracked file. A truncated
|
||||
listing (200 dirs / 1000 files / depth 12 caps) creates new members but
|
||||
never reconciles deletions. Dials are netguard-pinned (ports 80/443 outside
|
||||
tests), credentials travel only in a Basic `Authorization` header (never the
|
||||
URL), and redirects are refused outright. Creation AND every sync re-check
|
||||
URL), and redirects are refused outright. Rate-limited answers (429/503) are
|
||||
retried up to 3 times honoring `Retry-After` (capped at 30s), directory walks
|
||||
are paced 100ms apart, and the engine's per-sync budget is 6 minutes — large
|
||||
shares throttle instead of failing. Creation AND every sync re-check
|
||||
`AllowConnector("webdav")` from the entitlement catalog; a downgrade
|
||||
suppresses syncs instead of deleting anything.
|
||||
|
||||
|
||||
@@ -7,6 +7,19 @@ Versions correspond to git tags and to the published image set
|
||||
(the line was reset to 0.2.x at 0.2.14 — Superbrain is pre-beta).
|
||||
Dates are tag dates.
|
||||
|
||||
## 0.3.6 — 2026-11-24
|
||||
|
||||
### Fixed
|
||||
- **WebDAV on large shares**: Nextcloud throttles bursty PROPFIND walks, so
|
||||
production's 1,000+ file share failed intermittently with "unexpected
|
||||
answer (429)" and "context deadline exceeded". PROPFIND now retries
|
||||
429/503 up to 3 times honoring `Retry-After` (capped at 30s, ctx-bound,
|
||||
linear backoff without the header), the directory walk paces 100ms between
|
||||
requests, and the engine's per-sync budget grows from 3 to 6 minutes.
|
||||
Truncation semantics are unchanged (a capped walk still never reconciles
|
||||
deletions); unit tests cover recover-after-429 and the bounded attempt
|
||||
count.
|
||||
|
||||
## 0.3.5 — 2026-11-24
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -48,7 +48,7 @@ SUPERBRAIN_APP_IP="192.168.0.94"
|
||||
SUPERBRAIN_MIGRATE_IP="192.168.0.95"
|
||||
# Release to install; the generic `upgrade` flow keeps .env in step with the
|
||||
# service file's VERSION afterwards.
|
||||
SUPERBRAIN_IMAGE_VERSION="0.3.5"
|
||||
SUPERBRAIN_IMAGE_VERSION="0.3.6"
|
||||
|
||||
# render_superbrain_compose writes the app-dir compose file. Called by
|
||||
# config_superbrain (install) and by deploy/federated/update.sh after a lib
|
||||
|
||||
@@ -2,7 +2,7 @@ NAME=superbrain
|
||||
DESCRIPTION="Bookmark & Knowledge Base"
|
||||
DOCS=https://github.com/andrew/superbrain
|
||||
CONTAINER=federatedcomputer/superbrain-app
|
||||
VERSION=0.3.5
|
||||
VERSION=0.3.6
|
||||
INTERNAL_IP=192.168.0.93
|
||||
DEPENDS="postgresql"
|
||||
PORTS=3000
|
||||
|
||||
@@ -91,7 +91,7 @@ func httpClient(conn Conn) *http.Client {
|
||||
// ListTools connects, initializes and lists the server's tools, then closes
|
||||
// the session. The context bounds the whole exchange.
|
||||
func ListTools(ctx context.Context, conn Conn) ([]Tool, error) {
|
||||
client := mcpsdk.NewClient(&mcpsdk.Implementation{Name: "superbrain", Version: "0.3.5"}, nil)
|
||||
client := mcpsdk.NewClient(&mcpsdk.Implementation{Name: "superbrain", Version: "0.3.6"}, nil)
|
||||
var transport mcpsdk.Transport
|
||||
hc := httpClient(conn)
|
||||
switch conn.Transport {
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -146,6 +147,13 @@ func List(ctx context.Context, conn Conn) (*ListResult, error) {
|
||||
if rel != "" {
|
||||
dirURL += "/"
|
||||
}
|
||||
if dials > 1 {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil, ctx.Err()
|
||||
case <-time.After(walkPace):
|
||||
}
|
||||
}
|
||||
entries, err := propfindEntries(ctx, conn, dirURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -218,7 +226,13 @@ type parsed struct {
|
||||
// propfind issues a PROPFIND with the given Depth and returns the raw
|
||||
// response (caller closes the body). Both Check and List build the same
|
||||
// request; only Depth differs.
|
||||
//
|
||||
// Rate limits (429/503 — Nextcloud throttles bursty PROPFIND walks) are
|
||||
// retried up to rateRetries times, honoring Retry-After (capped at
|
||||
// rateWaitCap so a hostile server cannot pin the sync); without the header
|
||||
// a short linear backoff applies. Every wait is ctx-bound.
|
||||
func propfind(ctx context.Context, conn Conn, target, depth string) (*http.Response, error) {
|
||||
for attempt := 0; ; attempt++ {
|
||||
req, err := http.NewRequestWithContext(ctx, "PROPFIND", target, strings.NewReader(propfindBody))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -229,8 +243,46 @@ func propfind(ctx context.Context, conn Conn, target, depth string) (*http.Respo
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not reach the WebDAV share: %w", err)
|
||||
}
|
||||
if (res.StatusCode == http.StatusTooManyRequests || res.StatusCode == http.StatusServiceUnavailable) && attempt < rateRetries {
|
||||
wait := rateLimitWait(res.Header.Get("Retry-After"), attempt)
|
||||
_ = res.Body.Close()
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil, fmt.Errorf("could not reach the WebDAV share: %w", ctx.Err())
|
||||
case <-time.After(wait):
|
||||
}
|
||||
continue
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
rateRetries = 3
|
||||
rateWaitCap = 30 * time.Second
|
||||
rateWaitDefault = 5 * time.Second
|
||||
// walkPace spaces directory PROPFINDs so a bounded walk stays under
|
||||
// common server rate limits instead of tripping them and paying
|
||||
// Retry-After waits on every request.
|
||||
walkPace = 100 * time.Millisecond
|
||||
)
|
||||
|
||||
// rateLimitWait parses Retry-After (delay-seconds form; the HTTP-date form
|
||||
// falls back to the default) and caps it. attempt is zero-based.
|
||||
func rateLimitWait(header string, attempt int) time.Duration {
|
||||
if secs, err := strconv.Atoi(strings.TrimSpace(header)); err == nil && secs >= 0 {
|
||||
d := time.Duration(secs) * time.Second
|
||||
if d > rateWaitCap {
|
||||
d = rateWaitCap
|
||||
}
|
||||
return d
|
||||
}
|
||||
d := rateWaitDefault * time.Duration(attempt+1)
|
||||
if d > rateWaitCap {
|
||||
d = rateWaitCap
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
const propfindBody = `<?xml version="1.0" encoding="utf-8"?>` +
|
||||
`<propfind xmlns="DAV:"><prop>` +
|
||||
|
||||
@@ -197,3 +197,52 @@ func TestNormalizeBasePercentSafety(t *testing.T) {
|
||||
t.Fatalf("double or missing encoding: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
// A 429 with Retry-After is retried, not fatal: the walk recovers once the
|
||||
// throttle window passes (Nextcloud rate-limits bursty PROPFIND walks).
|
||||
func TestListRetriesRateLimit(t *testing.T) {
|
||||
allowPrivate(t)
|
||||
hits := 0
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
hits++
|
||||
if hits == 1 {
|
||||
w.Header().Set("Retry-After", "1")
|
||||
http.Error(w, "slow down", http.StatusTooManyRequests)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/xml")
|
||||
w.WriteHeader(http.StatusMultiStatus)
|
||||
_, _ = w.Write([]byte(`<multistatus xmlns="DAV:">` +
|
||||
`<response><href>/dav/</href><propstat><prop><resourcetype><collection/></resourcetype></prop></propstat></response>` +
|
||||
`<response><href>/dav/a.txt</href><propstat><prop><resourcetype/><getetag>"A1"</getetag></prop></propstat></response>` +
|
||||
`</multistatus>`))
|
||||
}))
|
||||
t.Cleanup(ts.Close)
|
||||
res, err := List(context.Background(), Conn{BaseURL: ts.URL + "/dav", Username: davUser, Password: davPass})
|
||||
if err != nil {
|
||||
t.Fatalf("429 then 207 must recover: %v", err)
|
||||
}
|
||||
if len(res.Files) != 1 || res.Files[0].Path != "a.txt" || hits != 2 {
|
||||
t.Fatalf("retry walk wrong: files=%v hits=%d", res.Files, hits)
|
||||
}
|
||||
}
|
||||
|
||||
// Persistent 429s stay bounded: exactly rateRetries+1 attempts, then the
|
||||
// server's answer surfaces (no infinite retry loop pinning the sync tick).
|
||||
func TestListRateLimitBounded(t *testing.T) {
|
||||
allowPrivate(t)
|
||||
hits := 0
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
hits++
|
||||
w.Header().Set("Retry-After", "0")
|
||||
http.Error(w, "slow down", http.StatusTooManyRequests)
|
||||
}))
|
||||
t.Cleanup(ts.Close)
|
||||
_, err := List(context.Background(), Conn{BaseURL: ts.URL + "/dav", Username: davUser, Password: davPass})
|
||||
if err == nil || !strings.Contains(err.Error(), "429") {
|
||||
t.Fatalf("persistent 429 must surface: %v", err)
|
||||
}
|
||||
if hits != rateRetries+1 {
|
||||
t.Fatalf("attempts = %d, want %d", hits, rateRetries+1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ const (
|
||||
tick = 5 * time.Minute // engine cadence
|
||||
syncEvery = 30 * time.Minute // per-connection freshness target
|
||||
perTick = 10 // connections claimed per tick
|
||||
syncTimeout = 3 * time.Minute // one full reconcile
|
||||
syncTimeout = 6 * time.Minute // one full reconcile (large walks pace + retry 429s)
|
||||
lastErrCap = 500
|
||||
dialBudget = 10 // outbound.Reserve window per owner (tests + syncs)
|
||||
dialWindow = time.Minute
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ name = "superbrain-mcp"
|
||||
# Versioned in lockstep with the Superbrain release it speaks to (house
|
||||
# tooling tracks one version per app); the federated mcpserver gateway
|
||||
# installs this package and spawns `superbrain-mcp` per linked instance.
|
||||
version = "0.3.5"
|
||||
version = "0.3.6"
|
||||
description = "MCP server for Superbrain — bookmarks, tags and pages over the Superbrain REST API"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
"""Superbrain MCP server — bookmarks, tags and pages for AI tooling."""
|
||||
|
||||
__version__ = "0.3.5"
|
||||
__version__ = "0.3.6"
|
||||
|
||||
Reference in New Issue
Block a user