Staging#559
Conversation
summarizeText gained Cloud SQL usage (userRepository/creditService) in the July credit repricing but never declared CLOUD_SQL_SECRETS in its onCall options. The deployed revision therefore had no CLOUD_SQL_* env vars and every call failed 500 with "Missing required Cloud SQL environment variables" before reaching the model. Adds the secrets binding (matching wikiLlm et al.) and a regression test asserting the endpoint manifest carries all four secret bindings. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
First message after idle hit the 5s WS connect timeout while Cloud Run cold-started (~7.5s observed), so every fresh session stalled 5s and fell back to HTTP. Raise the connect timeout to 10s and add a 60s circuit breaker after transport-level failures so WS-blocked networks pay the connect wait once per cooldown window instead of on every message. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot review on #557: authTimeout guarded WS open/connect (WS_CONNECT_TIMEOUT_MS), not the separate auth-timeout path ('WebSocket auth timeout' on close code 4001). Renamed to connectTimeout throughout. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
fix: summarizeText Cloud SQL secrets + WS cold-start timeout
Adopt expo-llm-wiki 4.21.0 runOntologyBackfill: dep bump plus post-sync trigger in syncWikiForCloud (covers syncAllToCloud and restoreFromCloud). Single batch per character per sync; WikiBusyError swallowed; other errors reported as wiki:<id>:ontology:backfill. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ion spec Review round: report scanned>0/typed==0 batches via existing reportError pathway (tag wiki:<id>:ontology:backfill:stalled) so an unclassifiable backlog looping on the 7-day cooldown is visible in Crashlytics; log full counters in dev builds. Note that sync triggers are foreground-only, so OS background-fetch kill limits do not apply; mid-loop suspension loses at most the in-flight batch. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…kfill-adoption feat: run ontology backfill per cloud character after wiki sync
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe PR adds ontology backfill after successful wiki synchronization, hardens WebSocket timeout and retry fallback behavior, wires Cloud SQL secrets into ChangesOntology backfill adoption
WebSocket fallback controls
Callable secret configuration
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant SyncWikiForCloud
participant WikiOrchestrator
participant Wiki
participant CrashReporting
SyncWikiForCloud->>WikiOrchestrator: syncAll
WikiOrchestrator-->>SyncWikiForCloud: successful sync
loop cloud-linked characters
SyncWikiForCloud->>Wiki: runOntologyBackfill(characterId)
Wiki-->>SyncWikiForCloud: backfill result
SyncWikiForCloud->>CrashReporting: report stalled or failed result
end
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Pull request overview
This staging PR bundles a set of production-hardening fixes across the client and Cloud Functions: improving Cloud Agent WebSocket reliability (cold starts + circuit breaker), ensuring summarizeText has required Cloud SQL secret bindings, and adopting ontology backfill after wiki cloud syncs (with docs + tests).
Changes:
- Client: increase WS connect timeout to 10s and add a 60s cooldown after transport-level WS failures to avoid repeated slow fallbacks.
- Client: after successful wiki cloud sync, run one best-effort
runOntologyBackfillbatch per cloud character with stalled-batch + error reporting. - Functions: bind Cloud SQL secrets for
summarizeTextand add a regression test asserting secret bindings are present in the endpoint manifest; bump wiki packages to^4.21.0.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/services/cloudAgentService.ts | Adds WS connect timeout + transport-failure cooldown to reduce first-message timeouts and repeated slow WS attempts. |
| tests/cloudAgentService.test.ts | Adds coverage for WS cooldown behavior and the 10s connect-timeout fallback path. |
| src/services/characterSyncService.ts | Runs best-effort ontology backfill after a successful wiki sync; reports stalled batches and non-busy failures without failing the sync. |
| tests/characterSyncWiki.test.ts | Updates mocks and adds a comprehensive ontology-backfill-after-sync test suite. |
| functions/src/summarizeText.ts | Declares Cloud SQL secret bindings for summarizeText callable configuration. |
| functions/src/summarizeText.test.ts | Adds regression test that asserts Cloud SQL secret bindings appear in the callable’s endpoint manifest. |
| package.json | Bumps @equationalapplications/*-llm-wiki dependencies to ^4.21.0. |
| package-lock.json | Lockfile updates reflecting the wiki dependency bump. |
| docs/superpowers/specs/2026-07-14-ontology-backfill-adoption-design.md | Design spec documenting the backfill adoption decisions and testing matrix. |
| docs/superpowers/plans/2026-07-14-ontology-backfill-adoption.md | Implementation plan for the ontology backfill adoption work. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
__tests__/cloudAgentService.test.ts (1)
421-476: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winSolid coverage for the cooldown-skip and connect-timeout paths; consider also testing cooldown expiry.
Both new tests correctly validate: (1) WS is skipped for subsequent calls after a transport failure, and (2) HTTP fallback only triggers after the full 10s connect timeout. Neither test asserts that WebSocket is retried again once
WS_RETRY_COOLDOWN_MS(60s) elapses — a regression where the cooldown never expires (e.g., an off-by-something inwsDisabledUntilcomputation) would go undetected.Consider extending test 1 (or adding a new case) with fake timers: after the first failure, advance time past 60s, then call
callCloudAgentagain and assertwsConstructionsincrements to 2.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@__tests__/cloudAgentService.test.ts` around lines 421 - 476, Extend the “skips WebSocket entirely for the cooldown window after a transport failure” test to use fake timers, advance beyond WS_RETRY_COOLDOWN_MS after the initial failure, then make another call and assert wsConstructions increments to 2. Preserve the existing assertion that the immediate second call skips WebSocket, and restore real timers and the original WebSocket afterward.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@__tests__/cloudAgentService.test.ts`:
- Around line 421-476: Extend the “skips WebSocket entirely for the cooldown
window after a transport failure” test to use fake timers, advance beyond
WS_RETRY_COOLDOWN_MS after the initial failure, then make another call and
assert wsConstructions increments to 2. Preserve the existing assertion that the
immediate second call skips WebSocket, and restore real timers and the original
WebSocket afterward.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bfabe5dd-d7fd-460e-95f6-7ef79116784b
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (9)
__tests__/characterSyncWiki.test.ts__tests__/cloudAgentService.test.tsdocs/superpowers/plans/2026-07-14-ontology-backfill-adoption.mddocs/superpowers/specs/2026-07-14-ontology-backfill-adoption-design.mdfunctions/src/summarizeText.test.tsfunctions/src/summarizeText.tspackage.jsonsrc/services/characterSyncService.tssrc/services/cloudAgentService.ts
PR 556
Summary
Test plan
🤖 Generated with Claude Code
PR 557
Summary
Two production fixes found while investigating chat-screen errors (2026-07-13):
1.
summarizeText500s — missing Cloud SQL secret bindingsEvery prod
summarizeTextcall has been failing withMissing required Cloud SQL environment variables: CLOUD_SQL_CONNECTION_NAME, CLOUD_SQL_DB_USER, CLOUD_SQL_DB_PASS, CLOUD_SQL_DB_NAMEsince the July credit repricing added
userRepository/creditService(Cloud SQL) to the handler without declaringsecrets: [...CLOUD_SQL_SECRETS]in itsonCalloptions — the deployed revision has zeroCLOUD_SQL_*env vars. Client surfaces this asFailed to summarize conversation context: FirebaseError: INTERNAL.wikiLlmet al.)summarizeTexthad the gap2. Chat WebSocket first-message timeouts
First message after idle hit the 5s WS connect timeout while the cloud-agent Cloud Run instance cold-started (~7.5s observed; server logs show the 101 upgrade succeeding after the client gave up). Every fresh session stalled 5s then fell back to HTTP.
Test plan
summarizeTextreturns 200 and first chat message of a fresh session streams over WS🤖 Generated with Claude Code
PR 558
Summary
@equationalapplications/core-llm-wiki+expo-llm-wikito^4.21.0forrunOntologyBackfillrunOntologyBackfillbatch per cloud character so cloud-agent-written and pre-ontology facts getokf_typeand join the knowledge graphWikiBusyErrorswallowed silently; other errors and stalled batches (scanned > 0 && typed === 0) reported to Crashlytics via existingreportWikiOpForCharactertag familyTest Plan
npm test— 992/992 passing (121 suites)npm run typecheck— cleannpm run lint:check— clean