Skip to content

fix(tts): preserve unread preferences during updates - #175847

Merged
steipete merged 2 commits into
mainfrom
deslop/z20-78-tts-pref-errors-20261015
Oct 17, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/z20-78-tts-pref-errors-20261015

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

An unreadable or malformed TTS preference file is silently treated as empty. Preference-changing commands can then replace that existing file with defaults plus one changed setting.

User Impact

Read-only TTS operations warn with repair guidance and continue using configured defaults. Preference updates refuse before writing when the existing file cannot be read, preserving it for repair. Slash-command setters return a terminal repair reply instead of letting that refusal escape without a response. A genuinely missing file remains a quiet first-run default and can still be created by a setting command.

Why This Change Was Made

Keep one file-read owner with an internal update context, rather than a competing reader or a blanket throw on normal reply paths. The existing mutation owner requests refusal before its unchanged private atomic write. Public setter signatures, valid-file updates, preference JSON shapes, config keys, permissions and durability remain unchanged.

This is a real silent-failure/data-preservation fix, not cleanup-floor credit: 36 net production lines added,55 net test lines added,5 documentation lines added. The lightweight config module uses a generic warning without logging preference contents or adding a heavy logger import. The existing command adapter shares one error-to-reply boundary across its six setter sites and logs through its existing subsystem logger plus the canonical error formatter.

Best-effort tradeoffs accepted

  • Optional reads still use configured defaults after a non-missing read/parse failure, now visibly. They do not block unrelated text replies. Mutations do not accept that fallback because it would overwrite unread settings.
  • Valid JSON shape coercion is unchanged; this fix handles read failures and malformed JSON, not a new schema or migration. No new retry, race fence or warning cache.
  • Existing quiet read behavior predates the shared-reader consolidation in refactor(runtime): deslop core subsystems #157982 and the lightweight extraction776c8e. No human incident or original-regression attribution is claimed; the concrete defect is the present read-default→mutate→atomic-write path.

Evidence

  • Fresh independent complete six-file review with determining read/write/command/private-file/errno/authorization/temp-directory owners: scoped-clean P0-P2,0.97; final source verification passed. Root and frozen review candidate match on all six files. Hosted P2 finding4304553893 was accepted: the initial setter refusal could escape slash-command dispatch without a reply. This repair handles the failure at the actual command boundary; original-head CI does not qualify the repaired head.
  • Three real-filesystem regression cases in the existing config fixture cover quiet missing vs visible malformed optional reads; actual setTtsMaxLength refusal with byte-identical malformed contents; and missing/valid-file successful updates preserving settings. Only console output is spied on.
  • A distinct command-boundary regression invokes actual handleTtsCommands('/tts limit 2000') with the real settings writer through the fixture's one-call setter implementation, asserting a terminal repair reply and byte-identical malformed contents. Shared temporary-directory cleanup and a static narrow writer import keep lifecycle/compilation at collection; no production test seam or new module mock.
  • Baseline and fixed runtime tests have not been executed locally. The same TTS/settings dependency graph reached actual cold-worker compilation during the immediately preceding focused run; that task-owned attempt was stopped before assertions and all descendants drained. No equivalent cold retry, runtime pass, measured test cost, or reproduced red/green claim. Exact-head CI must execute the changed owner suite before landing; record its cost when available.
  • Canonical original four-file formatting passed256ms; the two command repair files passed14ms; whitespace passed. Focused docs MDX check passed1file/589ms; docs-list completed. The documentation skill kept recovery guidance beside the existing per-user preferences reference, with no navigation, headings, links, generated locales or governance changes.
  • Repaired five-root core-test types (actual owning allowJs config plus ambient declarations) exited2 with36 unchanged parse5/MCP declaration and implicit-any diagnostics; no diagnostic names the changed files. This is not a qualified type pass. Original canonical core three-file type-aware lint and14-test suppression guard passed; repaired command two-file type-aware lint passed. Current pre-push suppression guard14PASS/106.28s Vitest/133.88s wrapper (git enumeration42.08s). No broad local build/check-changed/whole-graph types/E2E. The new errno/error-format imports use existing canonical owners and no public SDK surface is changed.

Release-note context: TTS preference commands no longer overwrite an existing file after a read/JSON parse failure; optional reads report fallback with repair guidance. No live channel/provider or operator-state proof claimed.

Exact repaired-head CI39071870338 completed successfully. Both changed suites actually executed: tts-config9PASS/6.76s (new filesystem cases3ms/1ms/5ms) in job117511300621; commands-tts12PASS/4.03s (repair-reply regression4ms) in job117511300666. All126 exact-head check runs accounted:66success/59skip/1neutral, no failed/cancelled/unfinished suite; all three commit statuses success. This closes the hosted runtime/test-cost gap, not the disclosed local dependency-declaration gap. No CI rerun, confirmation push or freshness rebase.

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 17, 2026 21:17
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T21:42:03.914986Z 4ff1e9f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: tts-local-cli plugin: azure-speech Azure Speech plugin extensions: fish-audio Extension: fish-audio size: S labels Oct 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c546df99e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

update: (tts: TtsUserPrefs["tts"]) => TtsUserPrefs["tts"],
): void {
const prefs = readTtsPrefs(prefsPath);
const prefs = readTtsPrefs(prefsPath, { forUpdate: true });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Surface unread-pref failures to slash-command users

When the preference file is malformed or unreadable, this new { forUpdate: true } path throws from every setter. The text-command path invokes these setters directly (for example, handleTtsCommands at commands-tts.ts:300), and handleCommands awaits handlers without translating exceptions (commands-core.ts:72-75); the dispatch layer then rethrows a pre-agent-run failure before sending any reply. Consequently, /tts on, /tts provider, /tts persona, /tts limit, and /tts summary provide no repair instruction to the user. Catch this expected refusal at the TTS command boundary and return its guidance as a command reply.

AGENTS.md reference: AGENTS.md:L82-L82

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in signed4ff1e9faaf3bcb2c5902280aaee21e6ea6964184: all six preference setter sites now use one TTS command-boundary adapter that logs the actual failure and returns a terminal repair reply. Validation, authorization and success replies are unchanged. A real-file /tts limit 2000 regression invokes the actual writer, checks that the command replies with repair guidance, and confirms the malformed bytes remain untouched. Fresh independent complete six-file review found no actionable P0–P2 defects; runtime proof and file timing remain for the repaired exact-head CI. The previous green head does not qualify this repair.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR prevents TTS preference updates from overwriting unreadable settings and returns repair guidance to slash-command users.

Example: Run /tts limit 2000 with tts.json containing {"tts":{"provider":"custom",.

  • Before: The malformed file is replaced with preferences containing only maxLength 2000.
  • After: The malformed bytes remain intact and the command returns repair guidance.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation resolves the earlier finding, but required persisted-preference upgrade proof is missing.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Changing one TTS preference can silently overwrite existing preferences after a read or JSON parse failure.
Reason: Preserving unread settings prevents concrete data loss, and the maintainer-authored direction explicitly keeps unrelated reply paths available.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR fixes a current preference-preservation bug, and the previous command-reply finding is resolved with no further concrete defects found.

Priority: P2
Reviewed head: 4ff1e9faaf3bcb2c5902280aaee21e6ea6964184

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: No executed red/green regression or latest-stable upgrade run is supplied for preference preservation and the repaired command reply.
Agent review details

How this fits together

TTS commands, Gateway methods, and CLI operations share a preference writer that reads local overrides before atomically saving a changed setting.

flowchart TD
  A[TTS command] --> B[Authorized command handler]
  B --> C[Preference mutation owner]
  C --> D[Shared preference reader]
  D --> E[Local preference file]
  D --> F[Refusal on unread settings]
  F --> G[Terminal repair reply]
  C --> E
Loading

Technical review

Best possible solution:

Retain the shared-reader refusal and command reply adapter, with verified preservation of existing preferences across upgrade.

Do we have a high-confidence way to reproduce the issue?

Current-main source directly establishes malformed-file fallback followed by destructive replacement; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is the smallest complete repair: distinguish missing files in the existing reader, refuse unsafe mutations in the existing writer, and translate refusal at the command boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f0abcb4213ae.

Provenance checked

  • Optional preference reads changes intended behavior with a stated reason (776c8e0: The lightweight extraction avoided heavy reply-runtime imports while allowing preference failures to fall back; the later shared-reader consolidation preserved that behavior.)
  • Preference mutation owner keeps the original intent (6d20432: The settings split kept mutations off the agent prompt's read-only import path; the package was subsequently absorbed into src/tts.)
  • Slash-command replies keeps the original intent (ca91522: Command consolidation retained authorization and terminal replies; the new adapter preserves those contracts when the writer refuses an update.)

Testing

Proof path: none.

Security

None.

Evidence

What I checked:

  • Current-main defect: At fetched main, readTtsPrefs catches read and JSON failures and returns an empty object; updateTtsPrefs then writes the changed setting over the existing file. (src/tts/tts-settings-writes.ts:12, f0abcb4213ae)
  • Preservation before write: The introduced diff keeps missing files as first-run defaults and makes the existing mutation owner reject other read or parse failures before reaching the unchanged atomic writer. (src/tts/tts-config.ts:132, 4ff1e9faaf3b)
  • Prior finding resolved: All six slash-command setter sites now use the shared catch-and-reply adapter, addressing the failure identified in the previous review and discussion_r4304553893. (src/auto-reply/reply/commands-tts.ts:86, 4ff1e9faaf3b)
  • Existing ownership and accepted behavior: refactor(runtime): deslop core subsystems #157982 consolidated preference reading while preserving fallback behavior; this maintainer-authored PR expressly retains optional-read fallback and accepts mutation refusal to preserve unread settings. (src/tts/tts-config.ts:132, 297c2b3db102)
  • Sibling consumers and public contract: Gateway setters already translate thrown failures into responses, CLI setters propagate errors, and the same setters are exported through plugin-sdk/tts-runtime; valid-file signatures and serialization remain unchanged. (src/gateway/server-methods/tts.ts:65, 4ff1e9faaf3b)
  • Validation evidence: The full current body reports no executed baseline/fixed behavioral tests or upgrade run; exact-head CI remains pending, with no failing check established by the inspected check results. (src/tts/tts-config.test.ts:64, 4ff1e9faaf3b)

Likely related people:

  • Peter Steinberger: Raw commit 35d4d8c adds src/tts/tts-settings-writes.ts:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 35d4d8c0726b; files: src/tts/tts-settings-writes.ts)
  • Vincent Koc: Raw commit 70c90c2 adds docs/tools/tts/commands.md:93 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 70c90c2ae4b3; files: docs/tools/tts/commands.md)

PR surface

Source +36, Tests +55, Docs +5. Total +96 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 51 15 +36
Tests 2 57 2 +55
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 113 17 +96

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: SDK-exported setters now reject unread existing preferences instead of replacing them; the maintainer-authored PR explicitly accepts this narrow behavior change.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status no longer selects a status label.

Label justifications:

  • P2: This focused repair prevents preference loss when a TTS settings file cannot be read or parsed.
  • merge-risk: 🚨 compatibility: SDK-exported setters now reject unread existing preferences instead of replacing them; the maintainer-authored PR explicitly accepts this narrow behavior change.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-17T21:33:53.867Z sha c546df9 :: blocked before merge. :: [P2] Return preference-read refusal as a TTS command reply

Reviewed October 17, 2026, 5:44 PM ET / 21:44 UTC (Revision 2).

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The signed preference-file preservation repair now also returns terminal repair guidance from every slash-command setter. Complete six-file review and focused static proof are current in the PR body; runtime proof awaits exact4ff1e9faaf3bcb2c5902280aaee21e6ea6964184 CI.

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 17, 2026
@steipete
steipete merged commit bcd6ab3 into main Oct 17, 2026
139 checks passed
@steipete
steipete deleted the deslop/z20-78-tts-pref-errors-20261015 branch October 17, 2026 21:51
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
Prevent TTS preference setters from replacing unread or malformed existing preferences. Optional reads warn and retain configured defaults; mutations refuse before the unchanged atomic write, and all six slash-command setter sites translate that refusal into a terminal repair reply. Quiet missing-file first-run behavior and valid updates remain.

Fresh independent complete six-file review scoped-clean P0-P2/0.97. The initial hosted P2 was accepted and repaired at the real command boundary, with actual-file preservation proof. Exact repaired-head CI39071870338 succeeded: tts-config9PASS/6.76s (new cases3ms/1ms/5ms), commands-tts12PASS/4.03s (new repair reply4ms). All126 checks accounted66success/59skip/1neutral; all three statuses success, no failed/cancelled/missing suite. Focused lint, formatting, docs and14 suppression checks passed. Local dependency-declaration gap remains disclosed.36 net production lines added for the real data-preservation fix, not cleanup credit. No rerun, rebase or confirmation push.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. docs Improvements or additions to documentation extensions: fish-audio Extension: fish-audio extensions: tts-local-cli P2 Normal backlog priority with limited blast radius. plugin: azure-speech Azure Speech plugin rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant