Skip to content

TD-5445: Code feed: a problem reason never echoes a value - #304

Merged
captcrock merged 3 commits into
mainfrom
td/5445-code-feed-reasons-echo-no-values
Dec 3, 2026
Merged

captcrock merged 3 commits into
mainfrom
td/5445-code-feed-reasons-echo-no-values

Conversation

@captcrock

Copy link
Copy Markdown
Contributor

When a card or events line in the Code feed folder can't be read, the feed lists it under "Couldn't read" with a reason. Until now that reason could quote the bad value itself. A private key put in ts or updated then showed its body to every viewer: Python's repr writes the key's newlines as \n, and the scrubber doesn't recognise a key in that shape without its END line.

What changes

  • A reason says which field and what's wrong, never the value. Examples: "ts: isn't an ISO-8601 time" and "id does not match the file name". The text comes only from:
    • TST Desk's own fixed words (FeedError);
    • fixed words for each pydantic error type, replacing pydantic's own messages;
    • the OS's strerror;
    • json's fixed messages, with line and column.
  • The card-id mismatch no longer quotes the id or the file name.
  • A card that isn't JSON keeps json's own words and the position ("Expecting ':' delimiter: line 1 column 6"), never the rest of json's message. Those words come from a fixed list, so a message that quotes characters can't get through.
  • A number too long to read gives "holds a number too long to read" instead of Python's own message.
  • An events line that isn't JSON gives "isn't valid JSON".
  • A whole-file or whole-line error no longer gets a misleading "file:" label.

Docs: docs/code-feed.md and the TD-5445 backlog entry. The sample problem in the protocol fixtures (generator, protocol-fixtures.json and one UI test) now uses the new wording.

Before / after

For each test secret (a private key in two shapes, an API key, a bearer token), each one placed in every card and events-line field that can fail: 56 cases in all.

main 3837191 this branch
Reasons showing part of a secret 4 of 56 (a private key in updated or ts) 0 of 56
Reasons showing [REDACTED] (a value was echoed, then scrubbed) 8 of 56 0 of 56
Bad ts 1 line: ts: Value error, Invalid isoformat string: '[REDACTED]\\nMIIE… 1 line: ts: isn't an ISO-8601 time
Card id mismatch id 'other' does not match the file name 'c.json' id does not match the file name
5,000-digit order Exceeds the limit (4300 digits) for integer string conversion: … holds a number too long to read
Events line that isn't JSON 1 line: file: Invalid JSON: EOF while parsing an object at line 1 column 73 1 line: isn't valid JSON

Against main's code_feed.py, the new tests fail: 89 failed, 55 passed in tests/test_code_feed.py and tests/test_code_feed_hub.py, plus all 4 cases of the later UTF-8 test. On this branch all of them pass.

Tests

  • Every way a card can fail (12 cases) and every way an events line can fail (8 cases), each tried with all 4 secrets. Each reason is checked exactly.
  • The window's and a phone's code_feed frames, from a folder holding every failing case. The frames must show no part of a secret and no [REDACTED].
  • The hub's frame: the other computer's problems reach this computer's viewers as they are, with no part of a secret and no [REDACTED].
  • A card that isn't UTF-8 gives "isn't UTF-8 text". On main the reason quoted the bad byte.
  • One existing test's expectation changed, from pydantic's own id wording to "id: must be …", because the reason now carries TST Desk's own words.

Not changed here (reported separately)

  • The scrubber's own gap. scrub_wire_json / redact_secrets don't recognise a private key written with literal \n and no END line. This PR keeps feed values out of reasons, so the gap no longer reaches them. The scrubber itself is left as it is.

  • Two crashes read_feed already had on main, not fixed here:

    • a time in year 1 with a positive offset raises OverflowError;
    • a card nested 60,000 levels deep raises RecursionError.

    Whether these should become listed problems is an open question.

Full suite

On 55f6ea2f (the branch before its last, test-and-fixture-only commit), on a heavily loaded shared machine (load average 38 to 49): 15 failed, 10,407 passed, 13 skipped, 4 deselected. None of the 15 is in the Code feed.

I reran the 15 on their own, three times on this branch and three times with main's code_feed.py in its place. That file is the only source file this PR changes besides the fixture generator.

Test branch, alone (3 runs) main's code, alone (3 runs)
test_benchmarks.py::test_no_regression[daemon_cold_start] (a timing ceiling) failed 3 of 3 failed 3 of 3
test_ws.py::TestWebSocketServer::test_health_fields_in_daemon failed 3 of 3 failed 2 of 3
test_session_title.py::…::test_title_survives_a_daemon_restart failed 1 of 3 passed 3 of 3
test_mcp_peer.py::test_a_phone_can_add_one_after_the_computer_grants failed 1 of 3 passed 3 of 3
test_session_preset.py::…::test_catalog_slug_edit_does_not_rewrite_an_open_session passed 3 of 3 failed 1 of 3
the other 10 passed 3 of 3 passed 3 of 3

These tests fail under load with and without this change; CI on a clean runner is the reference. After the last commit: the Code feed and protocol-fixture tests passed (277), and so did the UI's code-feed and fixture tests (694 in 27 files).

Checks

  • ruff, ruff format and mypy: clean.
  • release_scan --git: 0 hits.

Independent review

Two rounds, each by a fresh reviewer agent with read-only access and no access to my conclusions. I reproduced each finding before fixing it.

Round 1, on the first commit. Fixed:

  • json's message was cut at the wrong colon ("Expecting ': line 1 column 6");
  • a 5,000-digit number read only "ValueError";
  • an events line that isn't JSON read "1 line: file: isn't valid JSON";
  • the tests checked only the first bad events line and didn't cover title;
  • the frame tests didn't fail on [REDACTED];
  • two docstrings and a hub test comment were inaccurate.

Round 2, on the fixes. It found no way for a value from the folder to reach a reason, checked on Python 3.11, 3.12 and 3.14, and nothing that worked on main is broken. Fixed: a missing test for a card that isn't UTF-8, and the old-style sample reason in the fixtures.

Noted, unchanged:

  • an events line holding a number too long to read gives "isn't valid JSON", because pydantic's own parser rejects it first;
  • the frame tests see only the first bad events line's reason (the per-line tests cover all 8);
  • the two crashes main already had, listed above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SPdoY5jgXgTw6gUHBMBngR

captcrock and others added 3 commits December 3, 2026 03:54
A card or events line that can't be read is listed with which field and what's
wrong, in words TST Desk wrote itself (FeedError, and fixed words per pydantic
error type), never the value or an exception's own text. A private key in a bad
ts showed its body: repr writes newlines as \n, a shape the scrubber misses
without the END line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SPdoY5jgXgTw6gUHBMBngR
…tests

json's messages by their fixed start, never the quoted rest; a whole-file
or whole-line error carries no field label; each card and events-line case
checked exactly with a private key (both shapes), an API key and a bearer
token; frames also fail on any [REDACTED].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SPdoY5jgXgTw6gUHBMBngR
…in today's words

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SPdoY5jgXgTw6gUHBMBngR
@captcrock
captcrock merged commit 558cc47 into main Dec 3, 2026
10 checks passed
captcrock pushed a commit that referenced this pull request Dec 3, 2026
…er change

Text over its cap (a card's 4,000/200-character fields, an event's 2,000-
character text and 200-character source) is scrubbed before it is cut: a
secret split by the cut, or a private key that lost its END line to it, was
no longer one the scrubber knew, and part of it showed.

The watcher keeps the current feed's scrubbed frames, one for a window and
one for a phone or another computer, emptied when its fingerprint changes;
the push and get_code_feed share them. Every reply still goes through the
reply funnel's scrub.

Rebased onto TD-5445 (#304) as one commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SPdoY5jgXgTw6gUHBMBngR
captcrock added a commit that referenced this pull request Dec 3, 2026
…ames are cached per change (#305)

* TD-5444: Code feed: scrub before the cut; scrubbed frames made once per change

Text over its cap (a card's 4,000/200-character fields, an event's 2,000-
character text and 200-character source) is scrubbed before it is cut: a
secret split by the cut, or a private key that lost its END line to it, was
no longer one the scrubber knew, and part of it showed.

The watcher keeps the current feed's scrubbed frames, one for a window and
one for a phone or another computer, emptied when its fingerprint changes;
the push and get_code_feed share them. Every reply still goes through the
reply funnel's scrub.

Rebased onto TD-5445 (#304) as one commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SPdoY5jgXgTw6gUHBMBngR

* TD-5444: review: a secret registered at run time empties the cached frames

The watcher noted nothing about register_secret_value, so a value registered
after the frames were made went out raw in the next push (main scrubs at push
time). The frames are now kept with the number of registered secrets, emptied
when it grows, and a frame scrubbed while one was being registered isn't kept.
The backlog names every cut: 4,000, 2,000, 200 and 64 characters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SPdoY5jgXgTw6gUHBMBngR

---------

Co-authored-by: R&D12 <rd12@ezer.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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