Repository navigation
Codex app-server: envelope transcript source (mapper + forward buffer) #591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
273228b
WIP AI-1762 PR2: Codex usage delta converter (§2.4 usage semantics)
realtonyyoung 2d2007b
WIP AI-1762 PR2: Codex ephemeral accumulator (§2.4 cumulative-snapsho…
realtonyyoung 5f607dd
WIP AI-1762 PR2: Ephemeral/ItemId envelope fields + Plan kind (§2.4)
realtonyyoung b0f9776
WIP AI-1762 PR2: token_usage envelope kind + additive bucket fields (…
realtonyyoung 97921dc
WIP AI-1762 PR2: capture the cache-write token bucket end-to-end
realtonyyoung d4e6278
WIP AI-1762 PR2: codex notification→envelope mapper (§2.4)
realtonyyoung fa3495e
WIP AI-1762 PR2: IAcpTranscriptSource + forward buffer/watchdog (§2.4)
realtonyyoung 7e52e05
AI-1762 PR2: address Copilot review (mcp error precedence, shutdown d…
realtonyyoung cea919d
AI-1762 PR2: drop Linear IDs from C# comments (CI guard)
realtonyyoung 0423aee
AI-1762 PR2: address qodo review (reasoning strings, delta opt-out, e…
realtonyyoung 456c3c8
AI-1762 PR2: address Kiro review — pair fileChange tool call with a r…
realtonyyoung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Capacitor.Cli.Daemon/Harness/Codex/CodexEphemeralAccumulator.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| using System.Text; | ||
|
|
||
| namespace Capacitor.Cli.Daemon.Harness.Codex; | ||
|
|
||
| /// <summary> | ||
| /// Accumulates codex app-server per-item deltas (<c>item/agentMessage/delta</c>, reasoning deltas, | ||
| /// <c>item/commandExecution/outputDelta</c>, …) into the CUMULATIVE content-so-far that each ephemeral | ||
| /// envelope carries. §2.4 fixes the contract: ephemeral payloads are the item's whole accumulated | ||
| /// content (idempotent replacement at the viewer), never an increment — so a dropped or duplicated | ||
| /// ephemeral is harmless, and the canonical <c>item/completed</c> snapshot supersedes it. There is no | ||
| /// increment reassembly anywhere; <see cref="Complete"/> drops the item's transient state once its | ||
| /// authoritative snapshot has been mapped. | ||
| /// | ||
| /// <para>Not thread-safe: driven from the single notification-handling path.</para> | ||
| /// </summary> | ||
| internal sealed class CodexEphemeralAccumulator { | ||
| readonly Dictionary<string, StringBuilder> _byItem = new(StringComparer.Ordinal); | ||
|
|
||
| /// <summary>Appends a delta to the item's buffer and returns the accumulated content so far — the | ||
| /// payload of the ephemeral envelope for this item.</summary> | ||
| public string Accumulate(string itemId, string chunk) { | ||
| if (!_byItem.TryGetValue(itemId, out var sb)) { | ||
| sb = new StringBuilder(); | ||
| _byItem[itemId] = sb; | ||
| } | ||
| sb.Append(chunk); | ||
| return sb.ToString(); | ||
| } | ||
|
|
||
| /// <summary>Drops the item's transient buffer — called once the canonical completed envelope for it | ||
| /// has been produced (that snapshot finalizes the viewer's state for the item).</summary> | ||
| public void Complete(string itemId) => _byItem.Remove(itemId); | ||
|
|
||
| /// <summary>Number of items with live transient state (for the forward buffer's eviction bookkeeping | ||
| /// and tests).</summary> | ||
| public int ActiveItems => _byItem.Count; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.