Skip to content

Chore: migrate chat and agent-settings - #3

Merged
tlgimenes merged 7 commits into
mainfrom
chore/add-agent
Apr 3, 2025
Merged

tlgimenes merged 7 commits into
mainfrom
chore/add-agent

Conversation

@tlgimenes

@tlgimenes tlgimenes commented Apr 3, 2025 •

Copy link
Copy Markdown
Contributor

migrates chat and agent settings here

@tlgimenes tlgimenes changed the title wip Chore: migrate chat and agent-settings Apr 3, 2025
@tlgimenes
tlgimenes merged commit 40f5419 into main Apr 3, 2025
@tlgimenes
tlgimenes deleted the chore/add-agent branch April 3, 2025 23:18
viniciusventura29 added a commit that referenced this pull request May 12, 2026
pedrofrxncx pushed a commit that referenced this pull request May 12, 2026
tlgimenes added a commit that referenced this pull request Jun 8, 2026
…st-leg republish (TDD, all gates green)

Fixes #3698-follow: cluster-daemon proxy channel now tolerant of transient subscriber gaps.

PART #1 — Per-slot backoff (proxy-poller.ts)
- Root cause: shared errorStreak across proxy concurrency slots. One systemic error (e.g.
  Cloudflare 520 on the 28s long-poll) backed off BOTH slots → 1–30s zero-subscriber gap
  → dispatch publish to links.proxy.req.<userSub> dropped → proxy_no_first_frame 15s later.
- Fix: move errorStreak into each slot(). Each slot backs off only its own failures; one
  recovering slot re-polls immediately while another retries, keeping ≥1 live subscriber
  through intermittent errors.
- Test: new "per-slot backoff" test with concurrency:2 asserts seenStreaks=[0,0] not [0,1].

PART #2 — Request-leg tolerance (link-proxy-routes.ts, proxy-poller.ts)
- Root cause: fire-and-forget core-NATS publish with no buffer. A single blind publish
  is lost if it lands in a daemon poll/backoff gap; no retry, no durability.
- Fix: cluster-side bounded republish + daemon reqId dedup.
  (A) proxy-abort-registry.register() now returns AbortController|null; null if reqId
      already in-flight (duplicate delivery dedup). handleProxyRequest bails on null
      before try/finally, so duplicate copy doesn't unregister the original.
  (B) createProxyDispatch republishes RequestFrame every 1s (injectable republishIntervalMs,
      0=off) until first reply frame. Stopped by markFirstFrame/cleanup/first-frame-timeout
      (never outlives dispatch, bounded by 15s window). Daemon dedup makes double-execution
      impossible (emits first frame only after upstream responds).
- Tests: registry dedup test + "re-publishes...then stops" cluster test.

Verification: 36 affected-test pass, 110 link tests pass, fmt/lint/typecheck clean.

⚠️ Daemon caveat: proxy-abort-registry.ts marked "SHIPPED DAEMON — needs human review
before merge." Small change, well-tested, but shipped in `decocms` CLI.

Remaining: #3 tie proxy-readiness to claim (doc-vs-code defect), infra fix for CF 520,
plus this dedup safety pattern may apply elsewhere (runAbortRegistry in thread-gate-workflow).

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
tlgimenes added a commit that referenced this pull request Jun 8, 2026
…st-leg republish (TDD, all gates green) (#3704)

Fixes #3698-follow: cluster-daemon proxy channel now tolerant of transient subscriber gaps.

PART #1 — Per-slot backoff (proxy-poller.ts)
- Root cause: shared errorStreak across proxy concurrency slots. One systemic error (e.g.
  Cloudflare 520 on the 28s long-poll) backed off BOTH slots → 1–30s zero-subscriber gap
  → dispatch publish to links.proxy.req.<userSub> dropped → proxy_no_first_frame 15s later.
- Fix: move errorStreak into each slot(). Each slot backs off only its own failures; one
  recovering slot re-polls immediately while another retries, keeping ≥1 live subscriber
  through intermittent errors.
- Test: new "per-slot backoff" test with concurrency:2 asserts seenStreaks=[0,0] not [0,1].

PART #2 — Request-leg tolerance (link-proxy-routes.ts, proxy-poller.ts)
- Root cause: fire-and-forget core-NATS publish with no buffer. A single blind publish
  is lost if it lands in a daemon poll/backoff gap; no retry, no durability.
- Fix: cluster-side bounded republish + daemon reqId dedup.
  (A) proxy-abort-registry.register() now returns AbortController|null; null if reqId
      already in-flight (duplicate delivery dedup). handleProxyRequest bails on null
      before try/finally, so duplicate copy doesn't unregister the original.
  (B) createProxyDispatch republishes RequestFrame every 1s (injectable republishIntervalMs,
      0=off) until first reply frame. Stopped by markFirstFrame/cleanup/first-frame-timeout
      (never outlives dispatch, bounded by 15s window). Daemon dedup makes double-execution
      impossible (emits first frame only after upstream responds).
- Tests: registry dedup test + "re-publishes...then stops" cluster test.

Verification: 36 affected-test pass, 110 link tests pass, fmt/lint/typecheck clean.

⚠️ Daemon caveat: proxy-abort-registry.ts marked "SHIPPED DAEMON — needs human review
before merge." Small change, well-tested, but shipped in `decocms` CLI.

Remaining: #3 tie proxy-readiness to claim (doc-vs-code defect), infra fix for CF 520,
plus this dedup safety pattern may apply elsewhere (runAbortRegistry in thread-gate-workflow).

Co-authored-by: Claude Haiku 4.5 <[email protected]>
viktormarinho added a commit that referenced this pull request Jun 24, 2026
#1 Inherited-public files now render a read-only "shared via a parent folder"
state instead of the editable 3-way control — clicking "Org only" used to toast
success while the published parent kept serving it (false confirmation).
Restores the guard the old 2-way switch had.

#2 Unlock rate limiter no longer trusts the spoofable leftmost X-Forwarded-For
alone: prefer cf-connecting-ip / x-real-ip, and add a per-share global cap
(50/5min, IP-independent) as a backstop so rotating XFF can't fully unthrottle
brute-force. Per-IP cap (10/5min) stays for the normal case.

#3 Password hashing/verification moved to async scrypt — scryptSync on the
public, unauthenticated /unlock route blocked the event loop and serialized
concurrent attempts. Callers + tests updated to await.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
viktormarinho added a commit that referenced this pull request Jun 25, 2026
* feat(org-fs): scaffold password-share columns (share_password_hash, share_secret)

First step of password-protected sharing (design:
.context/file-share-password-spec.md). Adds the two nullable columns the
gate needs — a scrypt hash (null = fully public, set = password-gated) and a
per-node secret rotated on password change to invalidate unlock cookies.
Layered on read_public (link-accessible); proxy gate + UI follow after
design sign-off.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* feat(org-fs): password-protected sharing (proxy gate + 3-way share UI)

Adds a third share mode on top of public sharing. The /read proxy serves an
interstitial password form before content; one unlock (a signed, scoped
cookie) covers the node the password sits on — a file, or a whole folder + its
assets — mirroring public. Most-specific published node governs.

- crypto (share-password.ts): scrypt hash/verify, per-node share_secret,
  HMAC unlock tokens (MESH_JWT_SECRET); rotation + expiry fail closed.
- storage: derive shareMode in the DTO (hash never leaves the server),
  setShareMode, resolveGoverningShare (most-specific public node).
- service: OrgFs.setShareMode (hash + rotate secret), resolveReadAccess
  (private/public/password + govPath/secret).
- route: read branch (cookie check → form), POST /unlock (scrypt verify,
  rate-limited, sets scoped cookie), /public now takes { mode, password? }.
  Members bypass the prompt; non-members/anonymous get the form. Password
  content is never shared-cached.
- middleware: carve-out so non-members can POST /unlock.
- UI: ShareControls 3-way control (Org only / Public / Password) + password
  field; card badge gains a password (key) tier.
- tests: crypto unit (7) + integration (governing resolution, inheritance,
  most-specific override, password-change rotation).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(org-fs): rate-limit unlock by governing node, not requested path

Address review #1: a folder password is one credential for the whole subtree,
so keying the brute-force limiter on the requested file path let an attacker
multiply the lockout by guessing sibling sub-paths under the same share.
Resolve the governing share first, then key the limiter on access.govPath.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(org-fs): harden password gate per 2nd review (3 findings)

#1 Inherited-public files now render a read-only "shared via a parent folder"
state instead of the editable 3-way control — clicking "Org only" used to toast
success while the published parent kept serving it (false confirmation).
Restores the guard the old 2-way switch had.

#2 Unlock rate limiter no longer trusts the spoofable leftmost X-Forwarded-For
alone: prefer cf-connecting-ip / x-real-ip, and add a per-share global cap
(50/5min, IP-independent) as a backstop so rotating XFF can't fully unthrottle
brute-force. Per-IP cap (10/5min) stays for the normal case.

#3 Password hashing/verification moved to async scrypt — scryptSync on the
public, unauthenticated /unlock route blocked the event loop and serialized
concurrent attempts. Callers + tests updated to await.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
viktormarinho added a commit that referenced this pull request Jun 26, 2026
- #1: stamp catalog items with the Deco Store well-known source id so
  connections.tsx's `_registryId` registry filter and source badges keep
  working under the single catalog (proper filter removal lands in a later
  phase, with the rest of the per-registry machinery).
- #2: the catalog is live by default (REGISTRY_CATALOG_URL has a default), so
  fix the app.ts / settings comments that claimed it "ships dark when unset".
- #3: drop the now-unused registry-utils helpers (inferRegistryListToolName,
  isWellKnownRegistry, flattenPaginatedItems, extractItemsFromResponse,
  callRegistryTool) left dangling by the REST migration — keeps knip green.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant