Skip to content

Add PostgreSQL message route tests - #6

Closed
samxu01 wants to merge 1 commit into
mainfrom
codex/add-tests-to-improve-backend-coverage
Closed

samxu01 wants to merge 1 commit into
mainfrom
codex/add-tests-to-improve-backend-coverage

Conversation

@samxu01

@samxu01 samxu01 commented May 28, 2025

Copy link
Copy Markdown
Contributor

Summary

  • handle content field in message controller
  • update integration test for messages
  • add integration tests for PostgreSQL message routes using pg-mem

Testing

  • npm test

@samxu01 samxu01 closed this May 28, 2025
@samxu01
samxu01 deleted the codex/add-tests-to-improve-backend-coverage branch February 2, 2026 04:34
samxu01 added a commit that referenced this pull request May 24, 2026
Cron tick 2 captured a substantive review pass from Cody on PR #434
+ Claude's local MCP-tool-loading gap (Phase-4 finding #6). Cody's
findings are valid:

  P1 install.ts runtimeType fallback overreads — manifest.runtime.type
     for marketplace rows carries deployment shapes (standalone/
     commonly-hosted/hybrid) not canonical runtime identities; needs
     narrowing to manifest.runtime.runtimeType OR a shape→identity
     translator.
  P1 v2 marketplace Discover wired to /api/marketplace/browse
     (Installable schema) but install/remove still POST /api/apps/
     pods/:podId/apps (legacy App schema). Install clicks will fail.
  P2 AppCard fields lost in the Discover→App shim — kind, category,
     marketplace.totalInstalls, marketplace.logoUrl, etc.
  Test gap: AppsMarketplacePage.test.tsx still mocks old route, no
     regression coverage on /api/marketplace/browse.

Cody also drafted concrete Phase 2 shape for clawdbot bootstrap
(A+B+C bundle + COMMONLY_LOCAL_CLAWDBOT=1 + new `commonly dev
clawdbot` command) + noted backend schedulerService.ts ALREADY emits
heartbeat events — gap is the CLI wrapper dropping them. Lower-risk
than building cron from scratch.

I posted a huddle acknowledgment delegating fixes: Nova to draft the
install.ts narrowing fix, Cody to fully rewire the marketplace surface
(install/remove + AppCard mapping + test update), Theo to convert into
board tasks. Two-PR delivery (revisions on #434 + Phase 2 standalone)
is fine.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
samxu01 added a commit that referenced this pull request May 24, 2026
…); 2 Phase-4 findings

Phase 2 restart on new branch:

- Claude (sam-local) shipped a complete docs/local-dev/credentials.md
  runbook + .env.example restructure as text-to-commit at 6:34 PM
  (before the prior close-out cron exited). Path/recipe needs minor
  adjustments before commit. Routed to Theo/Cody/Nova for paste +
  push, with 30-min claim-the-orphan timer.
- Phase-4 #10 added: monitor cron should not stop the instant a
  stop condition hits — run one more tick after delay to catch
  long-tail in-flight responses. Claude's 2.E delivery would have
  been picked up on tick T+102min if I hadn't cancelled at T+97.
- Phase-4 #11 added: Claude (CLI-wrapper) writes principles to its
  OWN claude-code memory store (~/.claude/projects/...), NOT
  Commonly's agentmemories collection. Direct mongo query confirms
  theo/nova/cody have 0 rows in agentmemories. Cross-agent memory
  continuity doesn't work for CLI wrappers — compounds with #6
  (MCP tools not loaded).

No branch commits on phase-2 yet. 12-min monitor cron 88af22d0
armed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
samxu01 added a commit that referenced this pull request May 24, 2026
…e 2 ~80%

Cron R4 epilogue (stop condition firmly hit):

Cody resolved the Theo+Nova claim collision by shipping all of
Phase 2.A + 2.B + 2.D in a single comprehensive commit 3d398ab
(+812 lines, 4 files) while the others were still acknowledging.

What landed in 3d398ab:
- docker-compose.dev.yml: Dockerfile.commonly → Dockerfile default
  on both clawdbot compose services (Phase 2.B, 2-line change)
- dev.sh: +71 lines — read_env_value / is_truthy_env_value helpers
  + COMMONLY_LOCAL_CLAWDBOT=1 gating on the clawdbot profile (2.A)
- cli/src/commands/dev.js: +593 lines — new `commonly dev clawdbot`
  bootstrap subcommand: login → pod → install moltbot → harvest
  runtime token → write external/clawdbot-state/config/moltbot.json
  with controlUi flag → drop OPENCLAW_USER_TOKEN +
  OPENCLAW_RUNTIME_TOKEN into .env (Phase 2.D)
- cli/__tests__/dev.test.mjs: +148 lines NEW regression test file

Cody's session total: 5 code commits across PR #434 + phase-2.
Theo + Nova: 0 code commits between them.

The standout signal of the session: in this multi-agent setup,
cloud-codex (Cody) is the sole implementer; openclaw moltbots add
review + coordination value but can't ship code today. Captured in
Phase-4 #14 (workspace gap) + #6 + #11 + #15 (tool registry gaps).

Final Phase 2 state:
  ✅ 2.E shipped (3fa0565)
  ✅ 2.A+B+D shipped (3d398ab)
  🟡 2.C openclaw bundled-skills upstream — cross-repo, needs Sam
  📐 ADR-2.F implementation — design complete, code natural-next-sprint

Cron 88af22d0 cancelled. Phase 2 ~80% complete.

Total Phase-4 affordance findings: 17. Memory entries written: 2
(feedback-agents-collab-execute-not-handoff,
feedback-claim-the-orphan-stalled-peer-work).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
lilyshen0722 pushed a commit that referenced this pull request Jul 19, 2026
…ff (#685)

reconnectionAttempts: 5 idi. socket.io gecikmeyi üstel artırdığı için bu ~17
saniyelik bir pencere demek (1s→2s→4s→5s→5s, delayMax 5000 varsayılanı).
Bu pencereyi aşan HER kesintide — laptop uykusu, backend deploy'u, uzun ağ
blip'i — socket KALICI olarak pes ediyor ve bir daha denemiyordu. Sayfa açık
kalıyor, REST ile yüklenmiş eski mesajlar duruyor, yeni hiçbir şey gelmiyor:
kullanıcı sessizce bayat veriye bakıp 'mesajım gitmedi mi?' diyor. Pod'u açık
bırakıp agentları izlemek bu üründe beklenen kullanım (canlı gözlendi
2026-07-16: sekme ~1 saat sonra ölü, F5 ile düzeliyor).

A/B ölçümü (aynı backend, iki istemci yan yana, 45sn kesinti):
  ESKİ(5): deneme #5 -> *** PES ETTİ — bir daha denemeyecek ***
  YENİ(∞): deneme #6 -> *** YENİDEN BAĞLANDI *** -> CONNECT
12sn'lik kısa kesintide ikisi de toparlıyor — sorun yalnız uzun kesintide.

Değişiklik:
- reconnectionAttempts: Infinity + reconnectionDelayMax 30sn + jitter 0.5
  (sunucu dönene kadar dener; backoff ile sunucuyu dövmez)
- visibilitychange/online/focus -> hemen connect(): backoff 30sn'ye çıkabildiği
  için kullanıcı sekmeye döndüğünde bir sonraki denemeyi beklemesin. Sunucu
  taraflı kapatmada (io.disconnect) otomatik reconnect devreye girmez —
  bu olaylar o durumun da tek kurtarma yolu.
- Listener'lar cleanup'ta kaldırılıyor.

Doğrulama: tsc SocketContext.tsx için temiz (repodaki diğer tip hataları
mevcut ve ilgisiz); vite HMR derledi, hata yok.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
samxu01 pushed a commit that referenced this pull request Aug 4, 2026
@ux-lead handed over material rather than filing a competing entry, and
the strongest part of it is something neither of us set out to find.

Entry #6 recorded that the heartbeat cue names a tool which cannot serve
it, and was CORRECTED on 2026-08-04 — commonly_log_cycle is the writer,
shipped since May. Hours after that retraction was written into this
file, a second seat hit the deployed cue, ran the same three
commonly_save_my_memory shapes, collected the same three 400s, and
reached entry #6's original conclusion: "cycles is unwritable from an
MCP seat, write daily instead." Fourth occurrence of one failure, and
the first to happen after the answer existed in writing — with the
identical `daily` workaround this audit records as the original damage.

The retraction was filed where the mistake was diagnosed, not where it
is produced. Agents do not read the audit; they read payload.content,
and that string still named the wrong tool until PR #818. A fix to a
false model has to land at the surface generating it.

The genus, three instances the same day at three layers, none with any
notion of driver class in the code: the heartbeat cue (HEARTBEAT.md does
not exist on MCP seats — provisioned into moltbot PVCs only; and the
cycle-write tool name), the mention cues (commonly_open_dm /
commonly_read_attachment vs commonly_dm_agent / commonly_read_file), and
the agentEventService requeue (redelivery for pull drivers, a 20-minute
deletion countdown for push/native). Every individual existence check
passes for the population the author belongs to, which is why it
survives: "does this exist" is not answerable without naming the caller.

Also records the sprint's best agent-facing artifact as a positive
example — the 400 that names the exact required payload shape — with the
one gap that keeps it from being complete: it names the payload, not the
tool that accepts it.

Cross-links entry #6 so a reader of the retraction learns it did not hold.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lilyshen0722 added a commit that referenced this pull request Aug 4, 2026
… around (#820)

* docs(ax): delivered mentions drop the author field (entry 11)

Second identity defect, orthogonal to entry 7 and not fixed by #791: the
store records per-seat authorship and stable ids, the delivery envelope
carries neither. Every authorship claim an agent makes about its own
conversation is an inference until it pages the log.

Three near-misses from one seat in an hour, all caught by fetch and none
by the channel — including one about to be written into this file.

Includes the corollary that nearly made this entry wrong: paging the
record is not sufficient without naming the stage. A "no such entry on
any ref" negative was produced by a workspace whose fetch refspec is
main-only, while the cited entries were live on open PR #803 — the same
week two seats called ADR-018 nonexistent with a 97-line stub on #790.

Renumbered 9 -> 11 after #803 merged entries 8-10 mid-review.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(ax): entry 11 — three seats, three mechanisms, two rules

@ux-lead's correction (52379): their false negative was not fetch scope.
Their clone mirrors all 288 refs and already held the branch; the cause was
a self-imposed `head -20` that stopped alphabetically before `docs/`.
@pod-architect's (52380) was listing docs/adr/ in a working tree. Three
independent mechanisms, not one bug three times — which makes the finding
stronger, and "we all checked main" would have been untrue of two seats.

Adds the second rule their case needs and mine doesn't: a negative drawn
from an enumeration must report its denominator.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(ax): entry 11 — delivery can precede readability

The entry's own mitigation (page the log, match on id) has a window where
it structurally cannot run: a message already delivered and being acted on
was absent from the store at two reads a minute apart, newest id 52380.
For that interval the only available basis is the envelope's impression.

Measured, not derived — the interval's length is unknown; only that it is
not always zero.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(ax): entry 11 — retract the delivery-window claim, carry createdAt

The third finding asserted "delivery can precede readability" on the
strength of two store reads that returned 52380 as newest. The
timestamps refute it: 52380 was created 11:32:35.857Z and 52381 at
11:37:33.105Z, so both reads fell inside that gap and 52380 genuinely
was the newest message. The message being answered was 52375, created
11:19:30.261Z — fourteen minutes old and readable throughout. Absence
at the head was read as absence from the store.

Replaced with the mechanism that does explain it, found by @ux-lead
(msg 52394) and re-verified here from a fresh fetch: a redelivery
carries no age. That is a second missing field in the same envelope,
so the durable fix needs createdAt alongside author and id —
recovering age from an id costs the store page that time pressure
suppresses.

Also marks the three-errors-per-hour count as a floor rather than a
total, since later mechanisms are not delivery-envelope defects.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(ax): entry 11 — the envelope carries the author; the prompt doesn't

Retracts this entry's central mechanism claim. It said the delivery
envelope carries neither author nor id. Verified from source: the
chat.mention payload (agentMentionService.ts:752-765) carries
messageId, userId, username and createdAt, and agentsRuntime.ts:391
returns it whole.

The loss is one layer further in. buildContentForTarget (:531-553)
composes payload.content from four frames plus the raw body, and none
names a sender or a time — those four frames are verbatim the
bracketed blocks atop every turn this seat receives, so the
confirmation is first-hand.

So the fix is a fifth frame in this repo, not a third field and not an
upstream driver PR. Also records that it is not a one-liner: the
function takes no sender or timestamp, so it needs a formatter, a
signature extension and four call sites (:757, :805, :872, :912).

Declaring a field absent without grepping the surface that owns it is
entry 6's mistake, reproduced in the same file three days later by two
seats including this entry's author. Found by @pod-architect (52400),
located by @ux-lead (52403).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(ax): entry 12 — a protocol field promised, never written, routed around

ADR-004:70/72/73 promise `attempts` on every event, oblige drivers to dedup,
and document the counter as incrementing on redelivery. It ships in every
polled event via the `{ ...event }` spread in list() and it is always 0 —
$inc fires only on the two terminal transitions, never in the
pending<->delivered cycle the counter exists to measure.

The evidence that this is an AX defect rather than a bug: our own reference
driver implements the mandated idempotency against a local side-store keyed
on event id (cli/src/commands/agent.js:713) instead of reading the field.
A broken field with a cheap local workaround produces no bug reports.

Also records two adjacent findings from the same read — the requeue filters
on `ackedAt`, which is not a field in the model, and three of four driver
classes (native, webhook, MCP) terminate inside the requeue's target
population with no ack path, so a succeeded webhook re-POSTs at 10 minutes.
And the two in-repo CLI drivers disagree on ack-after-crash against an
unambiguous ADR-004 invariant 8.

Stacked on #813 (entry 11) so the two appends don't conflict.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(ax): entry 12 — the same bullet also promises "next poll" and means 15min

ADR-004:73 makes two promises. The counter was the first; the second is
"re-deliver on next poll". list() hardcodes status:'pending' (:921), so an
unacked delivered event is returned by no poll — it is invisible until the
requeue flips it back, at a 10-min threshold on a */10 cron, i.e. a 10-20
min floor against the same ADR's "3-10s for interactive agents" (:75).

Also records that the requeue runs before the deletes inside one
garbageCollect() pass, so an event reaching ~30 min unacked is requeued and
deleted in the same function without ever being served — which is why the
observed pattern is ~2 effective redeliveries and then silence.

And corrects the proposed terminal-transition rationale: 'failed' retention
is 168h, identical to delivered/acked, so the transition buys observability
(error field + lifecycle log + admin surface), not faster reclamation. The
cap is also near-unreachable at defaults, so the stranding risk only arms if
AGENT_EVENT_STALE_PENDING_MINUTES is raised.

Second non-conformance found by @sprint-review; verified from source and
folded in here rather than filed as a competing entry.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(ax): entry 12 — measure it in production instead of arguing it

~3h of backend logs. `attempts` holds exactly two values ever: 1073 enqueued
lines all attempts=0, 917 acknowledged lines all attempts=1. The redelivery
value the spec promises was never observed once.

18 GC passes deleted 202 events at status:'pending' with no per-event trace
(there is no logEventLifecycle('deleted') call). Reconstructing attribution
from enqueued/acknowledged lifecycle ids, restricted to events settled past
the 30-min sweep deadline: 792 settled, 151 never acked (19%) — including
15 of 72 chat.mention (21%).

Records @sprint-review's selection-effect framing: every event analysed
while building redelivery detectors was one that came back.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(ax): entry 12 — name the genus the four findings share

attempts=0, a 10-min threshold sampled by a 10-min cron, an empty
reviewDecision, and mergeStateStatus=BLOCKED are one defect: the value read
is correct and insufficient, and the decoder lives on a second surface the
first never names. An absent field prompts a search; a present, plausible,
incomplete one closes the question instead.

Records the operational rule (when an empty/zero/default value is
load-bearing, find the surface that separates not-applicable from
not-present) and the human half — in three of the four, the refuting datum
was in the reader's own output before the wrong conclusion was published.

Synthesis by @sprint-review.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(ax): entry 13 — one instruction, two driver classes

@ux-lead handed over material rather than filing a competing entry, and
the strongest part of it is something neither of us set out to find.

Entry #6 recorded that the heartbeat cue names a tool which cannot serve
it, and was CORRECTED on 2026-08-04 — commonly_log_cycle is the writer,
shipped since May. Hours after that retraction was written into this
file, a second seat hit the deployed cue, ran the same three
commonly_save_my_memory shapes, collected the same three 400s, and
reached entry #6's original conclusion: "cycles is unwritable from an
MCP seat, write daily instead." Fourth occurrence of one failure, and
the first to happen after the answer existed in writing — with the
identical `daily` workaround this audit records as the original damage.

The retraction was filed where the mistake was diagnosed, not where it
is produced. Agents do not read the audit; they read payload.content,
and that string still named the wrong tool until PR #818. A fix to a
false model has to land at the surface generating it.

The genus, three instances the same day at three layers, none with any
notion of driver class in the code: the heartbeat cue (HEARTBEAT.md does
not exist on MCP seats — provisioned into moltbot PVCs only; and the
cycle-write tool name), the mention cues (commonly_open_dm /
commonly_read_attachment vs commonly_dm_agent / commonly_read_file), and
the agentEventService requeue (redelivery for pull drivers, a 20-minute
deletion countdown for push/native). Every individual existence check
passes for the population the author belongs to, which is why it
survives: "does this exist" is not answerable without naming the caller.

Also records the sprint's best agent-facing artifact as a positive
example — the 400 that names the exact required payload shape — with the
one gap that keeps it from being complete: it names the payload, not the
tool that accepts it.

Cross-links entry #6 so a reader of the retraction learns it did not hold.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant