Repository navigation
refactor(hitl): one device-id derivation, in schema.py - #6212
mybelovedstar123 wants to merge 3 commits into
Conversation
renotify.seat_key, manager._device_id and events._device_id each spelled
str((req.device or {}).get("id") or "") on their own. The seat a
reminder is planned for and the card a create dedupes against must agree
on which device is which, so three copies were three places to drift.
schema.device_id(req) is now the one definition; renotify, manager and
events import it (renotify cannot import from manager, which imports
renotify). Behaviour is unchanged. A test pins seat_key to it and fails
if a module under src/hitl/ derives the id itself again. The vendored
packages/ag2-sparrow/ag2_sparrow/hitl copies are updated byte-identical.
Fixes sonichi#5376
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inserted at the same spot as sonichi#5377's new test, the two branches would conflict in tests/hitl-renotify.test.py; the test itself is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coverage Gate✅ Diff coverage PASSES the 95% bar. Whole-tree (informational): 92%. Diff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
|
sonichi
left a comment
There was a problem hiding this comment.
Approving at b22f9f9.
schema.device_id(req) is the one definition, and renotify, manager and events now import it, so the reminder seat and the create-dedupe can't name a device two ways. Behaviour is unchanged: it's the same str((req.device or {}).get("id") or "") expression. schema.py is the right home given the manager → renotify import. The vendored renotify, manager and schema are byte-identical to src.
Ran in a clean env: tests/hitl-renotify.test.py OK and tests/ag2-sparrow-drift.test.py PASS.
Nit, not for this PR: hitl/projector.py:280 still reads device.get("id") or "" inline. It reads a device dict rather than a requirement, so it doesn't fit device_id(req), but it's the same rule if it ever matters.
(agent-assisted, Blue for Chi's seat)
liususan091219
left a comment
There was a problem hiding this comment.
Requesting changes at b22f9f9 — one more copy of the same derivation is left, and the new guard cannot see it.
What is right: schema.device_id(req) (src/hitl/schema.py:245) is the same str((req.device or {}).get("id") or "") expression; renotify, manager and events now import it; the vendored renotify/manager/schema are byte-identical (tests/ag2-sparrow-drift.test.py PASS). tests/hitl-renotify.test.py passes at this head. The source scan in the new test is the structural kind REVIEW.md #14 allows, paired with a behavioural check.
What is missing (bandaid_generalize): src/hitl/replies.py:76-78, write_driver_action:
device = req.device or {}
body = {
"session": str(device.get("id") or ""),That is device_id(req) for a HumanRequirement, spelled across two lines, so the new guard (substring (req.device or {}).get("id")) does not match it. The vendored packages/ag2-sparrow/ag2_sparrow/hitl/replies.py:78 has the same line. The PR's claim is "one device-id derivation", so this is the fourth copy the sweep missed. It matters: the driver action's session decides which terminal a card's answer goes to, and it should name the device the same way the seat and the create-dedupe do.
Asks:
- Route
replies.py'ssessionthroughdevice_id(req)(src + vendored copy). - Make the guard catch a split spelling, e.g. scan for
.get("id")on a name bound fromreq.device, or simply assert"req.device" not inanysrc/hitl/*.pyexceptschema.pyonce the derivations are gone. Say in the body if some read ofreq.devicelegitimately stays.
projector.py:280 reads n.req.wire_device(), a different dict (adds host), so leaving it is fine, as Chi's nit already says.
CI green, license/cla success, no unresolved threads. Chi's approval stands as the expert half; this only needs the sweep finished.
— Sutando (susans-MacBook-Pro)
…ice_id too (review)
write_driver_action derived its `session` as str(device.get("id") or "") on a
name bound from req.device: the same derivation spelled across two lines, so
the substring guard missed it. It now calls schema.device_id(req), in src and
the vendored copy. The guard is an AST scan for .get("id") on a .device
expression or a name bound from one, and it would have caught this copy. A
test checks the driver action's session equals device_id(req). renotify's
seat name (.get("name")) and the action's socket are other fields and stay.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Both asks are done in 6ab02d9 (@liususan091219's review at b22f9f9):
Also added: These reads of
Results:
(agent-assisted, Claude for slovertop) |
|
@cla-assistant check |
|
The red CI at 6ab02d9 is the filed flake, not this change:
This commit touches only (agent-assisted, Claude for slovertop) |
Priority
Level: low
Reason: a refactor flagged in the #5375 review, so the reminder seat and the create-dedupe can't drift on which device is which.
Closes
Fixes #5376
Summary
renotify.seat_key,manager._device_idandevents._device_ideach spelled outstr((req.device or {}).get("id") or ""). The issue names the first two;events.pyhad a third copy.schema.device_id(req)is now the one definition, andrenotify,managerandeventsimport it. I choseschema.pybecauserenotifycan't import frommanager, which already importsrenotify, andschemais whereHumanRequirementlives. Behaviour is unchanged. The vendoredpackages/ag2-sparrow/ag2_sparrow/hitl/{renotify,manager,schema}.pyare updated byte-identical (events.pyisn't vendored).tests/fixtures/old_main/hitl_pre_local/still has the old copies. Those are frozen snapshots of past code, so I left them alone.Checklist
upstream/main(the structural check below names all three files)test_the_seat_and_the_create_dedupe_name_a_device_one_way)Before / after evidence
The new test against the parent
src/hitl(and vendored copies):This branch:
tests/hitl-renotify.test.py→ OK.Test plan
Linux (WSL2, Python 3.14): all 15
tests/hitl-*,tests/ag2-sparrow-hitl-vendored*andtests/core-input-watch-chat-escalation.test.py(which comparesseat_keyacross a requirement and its event) exit 0.python3 packages/ag2-sparrow/tools/sync_from_src.py --checkreports in sync.ruff checkis clean, andbash scripts/review-checks.sh --diff <(git diff upstream/main...HEAD)PASS.Author: discord username :: slovertop :: agent-assisted (Claude)