Skip to content

Edge model: Atom track (ATOM-01, 02, 03, 04, 06) - #69

Open
ianmuchyri wants to merge 6 commits into
mainfrom
edge
Open

Edge model: Atom track (ATOM-01, 02, 03, 04, 06)#69
ianmuchyri wants to merge 6 commits into
mainfrom
edge

Conversation

@ianmuchyri

Copy link
Copy Markdown
Contributor

Summary

Consolidates the Atom-side work for the edge model plan — the entity model (Device, is_gateway, gateways[], groups, sharing) needs five generic, non-IoT-specific capabilities from Atom, all now merged to edge:

Each PR has its own description with full test plan and design notes; linked above. ATOM-05 (a proposed gateway entity kind) was withdrawn during design — gateway is a capability (is_gateway), not a distinct kind — so it never shipped.

This is a checkpoint before the Magistrala-side work (pkg/atom client, device/gateway API) begins, which depends on all five of these being available.

Test plan

Each of the five PRs was independently verified (cargo clippy -- -D warnings, cargo fmt --check, full DB-gated integration suite) before merging to edge. Two of the five (#65, #68) merged with real diff conflicts against work already on edge, hand-resolved and re-verified against a fresh database before pushing — see their PR descriptions for specifics. After all five landed, the complete edge HEAD was independently re-checked out and the full suite re-run clean (only the two pre-existing AMQP-broker-dependent test files fail, unrelated to this work — they require TEST_AMQP_URL and a live broker, not part of make db).

* Keep a blank externalId filter distinct from an omitted one

normalize_external_id collapsed both "filter omitted" and "filter
explicitly blank/whitespace" to None. The SQL callers bind that as
`col IS NULL OR col = $n`, so a caller who passed a blank externalId
filter (a mistake, or an attempt to match nothing) got back the full
unfiltered authorized/listed set instead of zero rows.

Every Some(_) input now stays Some(_): blank, NUL-bearing, and
over-cap values normalize to a sentinel longer than
MAX_EXTERNAL_ID_LEN, which the length CHECK constraint guarantees no
stored row can equal. Only a genuinely omitted None still means "no
filter".

Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com>

* Suppress object-group membership events on no-op removals

remove_entity_from_object_group, clear_entity_object_groups, and
their resource counterparts discarded the DELETE's affected-row
count and always published entity.object_group.remove /
entity.object_groups.clear (and the resource equivalents), even when
zero rows were deleted — e.g. removing a membership that never
existed, or clearing an already-empty set. Event consumers were told
a change happened when nothing changed.

delete_entity_object_groups_in_tx and
delete_resource_object_groups_in_tx now return the deleted row
count, and the four *_with_audit callers skip the event publish (but
still commit) when it's zero — the same shape already used by
add_entity_to_object_group_with_audit / add_resource_to_object_group_with_audit
for the additive side, and by remove_group_member_with_audit for
principal-group membership.

Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com>

---------

Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com>
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