Skip to content

Commit 6d31349

Browse files
layer4downclaude
andcommitted
fix(acp): adapt A1/A6 port + tests to 0.5.23 structures
0.5.23 port follow-ups forced by upstream's SessionScope / standing-context / semantic-framing refactor, made during fork-sync validation: - A1 state maps (core_sections, baked_core_sections) keyed by SessionScope (upstream invalidated the channel-Uuid keying); invalidate_scope/_channel and has_channel_state cover the baked baseline alongside core_sections. - A6 gate-drop counters/WARN + intake receipt live inside InboundAuthorGate::authorize_listener_event (the new single gate chokepoint, covering both listener paths) — WARN level with event_id and per-mode freeze-surviving counters, upgraded from upstream's debug log. - SECTION_LABEL restored to the fleet-proven '[Agent Memory — core]' bracket header rather than upstream <core-memory> semantic framing — port preserves fork prompt bytes and the A1 dedup machinery; header canonicalization is an open drift axis for the Lens review window. - Tests migrated: scope keys, FlushBatch.scope field, channel_info args for the delta tests (upstream emits <context> hints conditionally and under semantic framing); delta-order assertions preserved via <context> marker. buzz-acp: 962 passed / 1 failed (acp keepalive deadline — pre-existing known fail at 9067f1d, unchanged shape). Co-Authored-By: Claude <[email protected]>
1 parent 1e65607 commit 6d31349

3 files changed

Lines changed: 31 additions & 13 deletions

File tree

‎crates/buzz-acp/src/engram_fetch.rs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,12 @@ pub enum CoreFetch {
7070
}
7171

7272
/// Section header used by the A1 core-section rendering (and stripped again
73-
/// by `section_profile` for hashing). Matches the label upstream's
74-
/// `prompt_framing::semantic_section("core-memory", ..)` renders.
75-
const SECTION_LABEL: &str = "core-memory";
73+
/// by `section_profile` for hashing). Deliberately the fleet-proven legacy
74+
/// bracket label, NOT upstream's `<core-memory>` semantic framing — the 0.5.23
75+
/// port preserves fork prompt bytes (header canonicalization is an open drift
76+
/// axis for the Lens review window; see prompt_framing::normalize_semantic_section
77+
/// for the upstream migration helper).
78+
const SECTION_LABEL: &str = "Agent Memory — core";
7679

7780
/// Monotonic per-reason refresh-failure counters (the PR-1 `drops_total`
7881
/// discipline): a silently-failing refresh is MEM-FREEZE rebuilt via the

‎crates/buzz-acp/src/pool.rs‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7550,16 +7550,17 @@ printf '%s\n' '{{"jsonrpc":"2.0","id":0,"result":{{"stopReason":"end_turn"}}}}'"
75507550
// session invalidation.
75517551
let mut s = SessionState::default();
75527552
let ch = Uuid::new_v4();
7553-
s.sessions.insert(ch, "s1".into());
7554-
s.core_sections.insert(ch, "core-a".into());
7555-
s.baked_core_sections.insert(ch, "core-a".into());
7553+
let scope = SessionScope::Conversation { channel_id: ch };
7554+
s.sessions.insert(scope.clone(), "s1".into());
7555+
s.core_sections.insert(scope.clone(), "core-a".into());
7556+
s.baked_core_sections.insert(scope.clone(), "core-a".into());
75567557
assert!(s.has_channel_state(&ch));
7557-
assert!(s.invalidate_channel(&ch));
7558+
assert_eq!(s.invalidate_channel(&ch), 1);
75587559
assert!(!s.has_channel_state(&ch));
7559-
assert!(!s.baked_core_sections.contains_key(&ch));
7560-
assert!(!s.core_sections.contains_key(&ch));
7560+
assert!(!s.baked_core_sections.contains_key(&scope));
7561+
assert!(!s.core_sections.contains_key(&scope));
75617562

7562-
s.baked_core_sections.insert(ch, "stale-baseline".into());
7563+
s.baked_core_sections.insert(scope, "stale-baseline".into());
75637564
s.invalidate_all();
75647565
assert!(s.baked_core_sections.is_empty());
75657566
}

‎crates/buzz-acp/src/queue.rs‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3146,6 +3146,7 @@ mod tests {
31463146
let event = make_event("hi");
31473147
let batch = FlushBatch {
31483148
channel_id: ch,
3149+
scope: crate::scope::SessionScope::Conversation { channel_id: ch },
31493150
events: vec![BatchEvent {
31503151
event,
31513152
prompt_tag: "test".into(),
@@ -3159,6 +3160,12 @@ mod tests {
31593160
&FormatPromptArgs {
31603161
agent_core_delta: Some("[Agent Memory — core]\nbe v2"),
31613162
has_system_prompt_support: true,
3163+
channel_info: Some(&PromptChannelInfo {
3164+
name: "delta-test".into(),
3165+
channel_type: "stream".into(),
3166+
description: None,
3167+
project: None,
3168+
}),
31623169
..Default::default()
31633170
},
31643171
)
@@ -3170,10 +3177,10 @@ mod tests {
31703177
let core_pos = prompt
31713178
.find("[Agent Memory")
31723179
.expect("[Agent Memory] missing");
3173-
let context_pos = prompt.find("[Context]").expect("[Context] missing");
3180+
let context_pos = prompt.find("<context>").expect("<context> missing");
31743181
assert!(
31753182
core_pos < context_pos,
3176-
"delta core section must precede [Context]"
3183+
"delta core section must precede <context>"
31773184
);
31783185
}
31793186

@@ -3186,6 +3193,7 @@ mod tests {
31863193
let event = make_event("hi");
31873194
let batch = FlushBatch {
31883195
channel_id: ch,
3196+
scope: crate::scope::SessionScope::Conversation { channel_id: ch },
31893197
events: vec![BatchEvent {
31903198
event,
31913199
prompt_tag: "test".into(),
@@ -3198,6 +3206,12 @@ mod tests {
31983206
&batch,
31993207
&FormatPromptArgs {
32003208
has_system_prompt_support: true,
3209+
channel_info: Some(&PromptChannelInfo {
3210+
name: "delta-test".into(),
3211+
channel_type: "stream".into(),
3212+
description: None,
3213+
project: None,
3214+
}),
32013215
..Default::default()
32023216
},
32033217
)
@@ -3206,7 +3220,7 @@ mod tests {
32063220
!prompt.contains("[Agent Memory"),
32073221
"no delta means no core section in the user message; got: {prompt}"
32083222
);
3209-
assert!(prompt.starts_with("[Context]"));
3223+
assert!(prompt.starts_with("<context>"));
32103224
}
32113225

32123226
#[test]

0 commit comments

Comments
 (0)