Skip to content

fix(server): record historical thread creators with a narrow event and an offline provenance repair - #749

Merged
lastobelus merged 7 commits into
lastcode/mainfrom
lastcode/fix-historical-thread-creator-repair
Nov 19, 2026
Merged

lastobelus merged 7 commits into
lastcode/mainfrom
lastcode/fix-historical-thread-creator-repair

Conversation

@lastobelus

@lastobelus lastobelus commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

🐛 Problem

The earlier startup repair for historical MCP-launched threads had three flaws:

  • Local evidence only. It could only link a thread to a creator in the same environment. Threads launched from another environment, or by a scheduled task, stayed unlinked.
  • Full payload rewrite. It wrote a thread.metadata-updated event carrying the whole thread payload and had no check that the current row still matched the one it read.
  • Changed placement. It set creatorGrouping to "grouped", which could move threads in the sidebar.

🔧 What changed

  • New event. thread.creator-repaired carries only creator provenance. A local repair sets creatorThreadId and creatorOrigin. A scoped repair sets creatorOrigin (thread_launch or scheduled_task, with environment and thread IDs, plus the scheduled task ID for the latter).
    • The server and client projections apply it. The agent-awareness relay ignores it.
    • Projection maintenance keeps it, so the evidence digest survives later metadata writes.
  • Startup repair. It now writes the new event. An ordinary launch is proven by its exact initial message, and create_threads by its keyed creation record. Other histories stay as recorded.
    • Guard. The new onlyIf option on EventSink.write runs a check inside the event transaction. The write is skipped if the row changed since it was read.
    • Extra skips. It also skips deleted threads, threads with delegatedFrom set, and threads that already have a creatorOrigin.
    • Parent check. It skips any thread where the repair would change getInteractiveThreadParentThreadId.
  • Operator command. repair-thread-creators is an unlisted offline command taking --manifest <file> and --apply. Use --base-dir and, where applicable, --state-dir to select the database.
    • Manifest. It lists each target thread, its creation event ID, three SHA-256 digests (creation payload, expected current payload, and the operator's evidence), and the origin to record.
    • Dry run (default). The database opens read-only and each entry gets a status.
    • --apply. It acquires both server ownership locks in server order and checks the recorded process. Apply requires a stopped server. It then writes through the event sink.

✅ Checks per manifest entry

  • The manifest's environment matches this one, and target thread IDs are unique.
  • The target thread exists, decodes, and is still an eligible MCP-created root thread.
  • The current row's payload hash matches expectedPayloadSha256.
  • One retained version 2 thread.created event binds the manifest to the target’s creation. Its payload hash must match, and contradictory retained local evidence blocks the write.
  • For thread_launch, the origin is a different environment, and the creation command ID equals the thread ID.
  • For scheduled_task, the origin is a different thread in this environment. The creation command must bind the task through a recognized timer, manual, or webhook fire ID. The creator thread needs a retained row, which may be a tombstone.

An entry that fails any check reports a named status (for example stale-target or missing-creation-evidence) and writes nothing. Re-running an applied manifest reports already-repaired and writes nothing. If a thread has a different origin recorded, the entry reports conflicting-origin.

🧪 Testing

  • 117 focused tests passed, including new cases in repairHistoricalThreadCreators.test.ts.
  • Quick CI passed.
  • The CLI rehearsal used isolated database copies from two environments. Both runs verified that the only thread metadata changes were the repaired origins, with no new runs or queued effects.

Local review: 6 rounds with Astra (xhigh) and Fable (xhigh), not clean. Both approved the final cut. Additional test coverage for conflicting exact-message evidence and unpruned keyed creation records is deferred.

Implemented with GPT-6.2 Sol in Codex. PR writing pass by Claude Sonnet in Claude Code.

@lastobelus lastobelus changed the title Repair historical thread origins without regrouping fix(server): record historical thread creators with a narrow event and an offline provenance repair Nov 19, 2026
@lastobelus
lastobelus marked this pull request as ready for review November 19, 2026 07:37
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T08:21:27.631096Z b556800 Manual request
ℹ️ 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.

lastobelus added a commit that referenced this pull request Nov 19, 2026
The parent thread initiated this prerequisite fix for #749.

## Problem

On the base branch, `vp run i18n:check` reports three missing desktop catalog keys and one stale key.

## What changed

- Ran `vp run i18n:generate` to add the three missing keys.
- Supplied translations for them in all nine non-English desktop locales.
- Removed the obsolete key from every catalog.

The desktop checker and runtime share the upstream-owned JSON catalogs.

## Verification

- `vp run i18n:check` now passes.
- Local Quick CI passes.
- A smoke test of the desktop resolver passes in all nine non-English locales.

## Upstream provenance

[T3 Code pingdotgg#37893](https://redirect.github.com/pingdotgg/t3code/pull/37893) at `055b44919ee`.

Implemented with GPT-6.2 Sol in Codex. Claude Sonnet polished this description.

Local review: 1 round with GPT-6.1 Terra (xhigh), approved.

Carry-Source-Ref: refs/lastcode/carry-sources/pr-750/85f9c4012deb26ea72abcd4c5098b12395ead984
Carry-Source-Base: db8411e
Carry-Source-Head: 85f9c40
Historical creator recovery could regroup threads and could only use evidence on the target environment. Accept a guarded manifest for scoped launch and schedule origins, and apply a provenance event without rewriting thread metadata or queuing work.

Carry-Group: incubator

Implemented with GPT-6.2 Sol in Codex.
Use the inspection config and full server ownership checks. Bind retries to the committed evidence, refuse conflicting local launch records and creator cycles, and keep repaired origin data isolated from forks and subagents.

Carry-Group: incubator

Implemented with GPT-6.2 Sol in Codex.
…hip locks

Reject reused creation identities and compare pruned launch receipts against the scoped evidence. Bind retries to the applied precondition, validate scheduled edges before checking cycles, and hold both server locks for offline repair.

Carry-Group: incubator

Implemented with GPT-6.2 Sol in Codex.
Use creatorOrigin and ThreadCreatorOrigin for shared thread provenance. Keep the repair event and manifest origin kinds independent of that field name.

Carry-Group: incubator

Implemented with GPT-6.2 Sol in Codex.
Recognize atomic launch commands and recover recorded thread creation after pruning. Match webhook task identities exactly and remove rejected cycle edges before assessing other schedule repairs.

Carry-Group: incubator

Implemented with GPT-6.2 Sol in Codex.
Match creation and timeline records through the exact launch identifiers. Validate scheduled origins against the retained initial run, and apply the same cycle handling to both repair paths.

Carry-Group: incubator

Implemented with GPT-6.2 Sol in Codex.
Remove the prompted create_threads inference and fixtures that used a command shape the historical writer did not emit. Use the exact initial message for ordinary launches and the keyed creation record for create_threads.

Carry-Group: incubator

Implemented with GPT-6.2 Sol in Codex.
@lastobelus
lastobelus force-pushed the lastcode/fix-historical-thread-creator-repair branch from efba61b to b556800 Compare November 19, 2026 08:18
@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: b55680011d

ℹ️ 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".

@lastobelus
lastobelus merged commit 175ac36 into lastcode/main Nov 19, 2026
21 checks passed
@lastobelus
lastobelus deleted the lastcode/fix-historical-thread-creator-repair branch November 19, 2026 08:34
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