refactor(execution_trace): Phase B language-advantage pass — dichotomy wave
CI Pipeline / best-practices (push) Successful in 9s
CI Pipeline / documentation (push) Successful in 4s
CI Pipeline / rust-surface (push) Failing after 17s
CI Pipeline / go-surface (push) Failing after 20s
CI Pipeline / required-checks (push) Canceled after 0s
CI Pipeline / CI Pipeline / notify-event-bridge (push) Canceled after 0s
CI Pipeline / gitea-offline (push) Canceled after 22s
Auto-version and Release / release (push) Canceled after 49s
CI Pipeline / canary (push) Canceled after 40s
CI Pipeline / type-check (push) Canceled after 26s
deploy / deploy (push) Canceled after 51s
CI Pipeline / lint (push) Canceled after 46s
CI Pipeline / unit-tests (push) Canceled after 46s
CI Pipeline / best-practices (push) Successful in 9s
CI Pipeline / documentation (push) Successful in 4s
CI Pipeline / rust-surface (push) Failing after 17s
CI Pipeline / go-surface (push) Failing after 20s
CI Pipeline / required-checks (push) Canceled after 0s
CI Pipeline / CI Pipeline / notify-event-bridge (push) Canceled after 0s
CI Pipeline / gitea-offline (push) Canceled after 22s
Auto-version and Release / release (push) Canceled after 49s
CI Pipeline / canary (push) Canceled after 40s
CI Pipeline / type-check (push) Canceled after 26s
deploy / deploy (push) Canceled after 51s
CI Pipeline / lint (push) Canceled after 46s
CI Pipeline / unit-tests (push) Canceled after 46s
Hash-indexed outcome map: the duplicate task_id dict-assignment law now resolves through one O(N) pass (Vec + insertion-order HashMap index) instead of the O(N²) find-then-scan — deterministic, allocation-light, semantics identical (insertion order preserved). Battery 3/3 replays frozen truth verbatim; live parity 820/820; clippy -D warnings clean.
This commit is contained in:
1 parent
4bda61cdc5
commit
f67f51e73c
1 file changed
+12
-4
@@ -70,6 +70,12 @@ fn s(v: &str) -> Json {
|
||||
/// exact exception, so both core modes crash identically.
|
||||
pub fn read_outcome_events(lines: &[Json]) -> Result<Json, (String, String)> {
|
||||
let mut pairs: Vec<(String, Json)> = Vec::new();
|
||||
// Phase B (language advantage): a hash index replaces the linear
|
||||
// find-then-scan for duplicate task_ids — one pass over a journal of
|
||||
// N lines is O(N) instead of O(N²), with insertion order preserved
|
||||
// (the dict-assignment law needs first-seen ordering, not sorted).
|
||||
let mut index: std::collections::HashMap<String, usize> =
|
||||
std::collections::HashMap::new();
|
||||
for line in lines {
|
||||
let Json::Str(raw) = line else { continue }; // TypeError branch
|
||||
let rec = match pyjson::parse(raw) {
|
||||
@@ -97,10 +103,12 @@ pub fn read_outcome_events(lines: &[Json]) -> Result<Json, (String, String)> {
|
||||
continue; // falsy task_id branch
|
||||
}
|
||||
// dict assignment: a later duplicate REPLACES the earlier payload
|
||||
if let Some(slot) = pairs.iter_mut().find(|(k, _)| *k == tid) {
|
||||
slot.1 = payload;
|
||||
} else {
|
||||
pairs.push((tid, payload));
|
||||
match index.get(&tid) {
|
||||
Some(&slot) => pairs[slot].1 = payload,
|
||||
None => {
|
||||
index.insert(tid.clone(), pairs.len());
|
||||
pairs.push((tid, payload));
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Json::Obj(pairs))
|
||||
|
||||
Reference in new issue
Block a user