Repository navigation
HERD v0.4.0
Release gate: a clean make everything at the tagged commit.
[0.4.0] - 2026-09-05
- Shipped lab purpose classification end to end (ADR 0013, issue #646, phases 1
to 3): a closed taxonomy per reservation, an AI-suggested category the owner
or an admin confirms on the new Administration > Purpose Review page, a
background reconciler that classifies reservations as they end, and device-
and user-level purpose reporting that counts transit gear on a reservation's
paths, with CSV downloads for every purpose section. - Ran a full multi-pass code review of the codebase (the 2026-09-04 review
sweep) and closed all 21 resulting issues (#701 to #721). The headline fixes:
fork saves and activation snapshots now refuse a canvas endpoint device
outside the reservation's membership (cross-tenant provisioning was reachable
before), port claims across forks are serialized with transaction-scoped
advisory locks at both fork write paths, scheduled config-apply jobs re-check
the creator's authority at fire time, and three read surfaces are gated (group
member emails are admin-only, device config-version reads follow device
visibility, the connections list is filtered to the caller's visible devices). - Made the transactional outbox wake on write (issue #682) through Postgres
NOTIFY/LISTEN, so a staged event publishes within milliseconds instead of
waiting for the relay tick; hardened the listener for reconnects, TLS and
pooler DSNs, and saturated batches (#707). NATS pull consumers now fetch one
message per pull, which fixed the first-run notification flake at its source
(#648). - Moved the purpose-classification reconciler onto its own background task with
a transient outcome class, so a slow orchestrator no longer delays the
expiration sweep and a rate limit no longer burns a row's attempts (#702,
#706). - Added AI-proposed network elements (#632): the topology generator can place
the four element types and the commit path keeps them. - Closed the fork restore-versus-save race with a row lock (#626), indexed the
ACTIVE fork listing and preloaded the wiring ledger (#710), and stopped device
lists from truncating at 500 rows (#703). - Hardening batch from the sweep: Traefik's dashboard bound to loopback,
superadmin deactivation refused, user-profile preference validation, bounded
upload buffering that rejects an over-cap request before it is fully read,
provider error text kept out of responses, and a fail-closed AI commit path
for network elements.
Delivery detail
Purpose classification and reporting
- Reliability fix: the purpose-classification reconciler now runs on its own
background task instead of riding the reservations expiration sweep (issue
#702, 2026-09-04 review sweep finding). The reconciler awaits one
orchestrator LLM call per eligible row, serially, up to
purpose_classify_batch_sizerows (default 20) each bounded by
purpose_classify_timeout_seconds(default 30s); a single tick could
therefore run for minutes, delaying every other reconciler that shared the
loop (scheduled activation, auto-completion, both provisioning-timeout
backstops, fork archiving, wiring heal, and pending prune) behind a slow or
hung orchestrator.services/reservations/app/main.pynow starts a second
task,purpose_classify_loop, at its own interval
(PURPOSE_CLASSIFY_INTERVAL_SECONDS, default 60s), cancelled alongside the
expiration task at shutdown; the reconciler's body stays sequential (no
concurrent LLM calls).expiration_loopno longer calls the reconciler. - Bug fix: the purpose-classification reconciler gains a
transientoutcome
class and stops misreading an internal-token failure as the feature being
off (issue #706, 2026-09-04 review sweep finding). Previously every
non-403/404 failure, a 429 rate limit, a 502/503/504, a timeout, or a
transport error, incremented a row'spurpose_classify_attemptsexactly
like a genuine per-row rejection; a quota 429 lasts until UTC midnight
(hundreds of sweep ticks), so a rate-limited owner's rows deterministically
capped out, invisible in aggregate metrics. A newtransientoutcome for
those cases ends the tick without touching any row's attempts, the same
treatmentfeature_offalready had. Separately,POST /internal/classify-purposecan 403 for two unrelated reasons
(AI_PURPOSE_CLASSIFICATION_ENABLEDoff, or an internal-token mismatch),
and the reconciler read either as "the feature is off", silently stalling
the backlog after a token rotation while logging the wrong cause. The
orchestrator's flag-off refusal now carries a structured detail,
{"error": "purpose_classification_disabled", "message": "Purpose classification is disabled"}; the reconciler treats a 403 as feature-off
only when that marker is present (falling back to the exact legacy
plain-string detail for a pre-fix orchestrator image during a rolling
upgrade), and logs any other 403 at WARNING as a likely internal-token
problem instead. See the ADR 0013 amendment for the full outcome taxonomy. - Added Download CSV buttons for the four purpose reporting sections (issue
#696):purpose,user_purpose,device_purpose, andpurpose_suggested
joinUtilizationCsvSectionon the frontend, andReportingPagegets a
button on the purpose bar chart (confirmed data), a second button next to
it for the AI-suggested bucket (shown only onceby_purpose_suggestedis
in the report payload), and one on each purpose mix table (By User, By
Device), all calling the existingdownloadUtilizationCsvwith the
page's current window. The server has served these sections since #646
phases 1-2; only the frontend wiring was missing. - Added lab purpose classification, phase 3 (issue #646): device-level
utilization reporting now inherits transit gear from cabling's fork
wiring. Cabling gainsPOST /internal/forks/devices/batch
(X-Internal-Token, 1 to 500 reservation ids) returning, per reservation
with a fork (ACTIVE or ARCHIVED), the sorted distinct device ids across
itsfork_connectionsrows. Reservations' utilization report calls it in
chunks of 500 and folds each reservation's fork-connected devices minus
its own reserveddevice_idsintoby_deviceandby_device_purpose: a
transit device inherits the reservation's confirmed category (or
unclassified) exactly as a reserved device does, and a device both
reserved and on a path counts once, as reserved.reservation_count/
hoursandreservations/device_hoursare now INCLUSIVE of transit
gear; both buckets gaintransit_reservationsand a transit-hours field
(transit_hoursonDeviceBucket,transit_device_hourson
DevicePurposeBucket) reporting the transit share alone. A new
include_transitquery parameter (default true) on both
GET /reports/utilizationand its CSV twin skips the cabling call
entirely when false, reproducing phase-1 semantics;UtilizationReport
gainstransit_includedechoing the effective value. Cabling being
unreachable, or returning a non-200, fails CLOSED with 503
{"error": "transit_gear_unavailable"}on both routes rather than
silently reporting zero transit devices. Thedevice/device_purpose
CSV sections gain trailingtransit_reservations/transit-hours columns.
The reporting page's by-device Purpose Mix table gains a Transit column
(hours plus a percentage for a mixed row, a small tag for a transit-only
row) and a helper line naming which semantics are in effect. - Added lab purpose classification, phase 2 (issue #646): the AI orchestrator
gainsPOST /api/ai/classify-purpose/preview(user JWT, creation pass) and
POST /api/ai/internal/classify-purpose(X-Internal-Token, end-of-
reservation pass), both behindAI_PURPOSE_CLASSIFICATION_ENABLED
(default off, enforced at the route boundary like recipe authoring). Each
makes one forcedclassify_purposetool call against a caller-supplied
category list, assembling a prompt from purpose text, topology device/
template/wiring signals, dynamic template names, config-apply job names
and counts, fork version count, duration/status, and, when
AI_PURPOSE_INCLUDE_TRANSCRIPTSis set (default on), the reservation
assistant's own transcripts; a signal-fetch failure is logged and dropped
rather than failing the request, reflected in the response's
signals_used.GET /api/ai/statusgainspurpose_classification.
Inventory gains one small additive internal endpoint,
GET /devices/{device_id}/apply-jobs/internal, to feed the config-apply
signal without a user JWT. Seedocs/AI_PURPOSE_CLASSIFICATION.md. - Added lab purpose classification, phase 1 (issue #646): reservations gain an
optionalpurpose_categoryvalidated against a configured taxonomy
(PURPOSE_CATEGORIES), settable by the owner or an admin in any status
including terminal viaPATCH /{id}/purpose-category, listed via
GET /purpose-categories, and carried additively on every
reservation.*lifecycle event and the/api/v1facade. The utilization
report and its CSV export gainby_purpose,by_user_purpose, and
by_device_purposebreakdowns, with an explicitunclassifiedbucket for
reservations with no category. Device-level classification counts reserved
devices only; transit-gear inheritance is deferred to phase 3. - Added lab purpose classification, phase 2 reservations-side pieces (issue
#646, ADR 0013 points 8-11): a reservation transitioning into COMPLETED,
CANCELLED, or FAILED now stampspurpose_classify_requested_at, the sole
trigger for a new expiration-sweep reconciler that calls the AI
orchestrator's internal classify-purpose endpoint in bounded batches
(PURPOSE_CLASSIFY_BATCH_SIZE, capped atPURPOSE_CLASSIFY_MAX_ATTEMPTS
retries per row) and stores the result verbatim aspurpose_suggestion. New
admin endpoints:GET /admin/purpose-review(paginated, filterable by
suggested category) lists undismissed suggestions still worth a look,
POST /admin/purpose-review/{id}/acceptwrites a suggestion (or a chosen
override) into the confirmedpurpose_category,POST /admin/purpose-review/{id}/dismissdrops a suggestion from the queue
without touching the confirmed value, andPOST /admin/purpose/backfill
marks every terminal reservation with no suggestion yet as eligible
(idempotent). The utilization report gainsby_purpose_suggested(and a
matching CSV section) for reservations with a suggestion but no confirmed
category;unclassifiednow means neither a category nor a suggestion.
Suggestions are internal review state, not exposed on the/api/v1facade.
Reservations and provisioning
- Pinned
PURPOSE_CLASSIFY_INTERVAL_SECONDSto 5 in the dev/test compose
override besideEXPIRATION_INTERVAL_SECONDS(release-gate catch): the
purpose-review integration test, which only runs where an AI provider is
configured, waits under the 30-second suite cap for the classifier loop
that issue #702 moved onto its own 60-second default interval. - Fixed reservations' cancel/release inventory cleanup treating a 404 from
inventory as a hard failure (issue #716). Since #682 execution's terminal
teardown starts roughly a millisecond after a cancel or release commits,
and for a dynamic-only booking it deletes the materialized device; if that
landed first,_update_device_statusesraised on the resulting 404,
triggering retries and an ERROR log for a device that was correctly gone,
and_fetch_devices_best_effortturned that same 404 into "assume
exclusive", so the retry loop re-POSTed a status update against a device
reservations had just been told did not exist. A 404 on the AVAILABLE
(release) direction of_update_device_statusesnow counts as success
with no retry and no ERROR log; the RESERVED (booking) direction is
unchanged and still raises, since inventory not recognizing a device being
booked is a real failure._fetch_devices_best_effortnow surfaces a 404
as the distinct_DeviceGoneFromInventoryrather than a generic
exception, and_release_exclusive_devices_best_effortdrops that id from
the release set with an INFO log instead of assuming it is exclusive and
re-releasing it. - Fixed the purpose-classify reconciler treating a per-call timeout as
provider-wide evidence (issue #706 follow-up, release-gate catch, proven
live on the dev stack): a timeout ended the whole sweep tick without
bumping the row's attempt count, so one reservation whose classification
call ran pastpurpose_classify_timeout_secondsblocked every older-queued
row behind it forever, since the reconciler orders oldest-requested-first.
Observed: the same reservation timed out on seven consecutive ticks with
purpose_classify_attemptsstill 0 while 45 eligible rows waited behind
it. A timeout now counts as its own outcome, bumps that row's own attempt
count, and lets the tick continue to the next row, since a timeout is
evidence about that row's call, not the whole provider; any other
transport error (a connection error, for example) is unchanged and still
ends the tick.
Cabling and forks
- Performance fix: the expiration sweep's per-tick ACTIVE fork reconcile no
longer scans or reads without an index (issue #710, 2026-09-04 review sweep
finding, medium and low severity).reservation_forkcarried indexes only
onreservation_id; nothing coveredstatusorcreated_at, yet fork rows
are never deleted by design (archived forks are the as-built record the
transit report reads), soGET /internal/forks's unconditionalCOUNT(*)
plus filteredORDER BY created_at OFFSET, drained fully every tick (60s in
prod, 5s in dev), ran two unindexed passes over a table that grows forever.
Cabling migration 0010 adds a partial index,
ix_reservation_fork_active_created_aton(created_at, id) WHERE status = 'ACTIVE', mirrored inReservationFork.__table_args__so the SQLite
unit-test schema matches; no retention added,totalstays in the listing
response. Reservations'_fetch_active_forksnow also stops paging on a
page shorter than the requested limit, not only on reachingtotal, which
is cheaper and does not depend ontotalstaying consistent across pages
against a live set. Separately, an ACTIVE fork whose reservation is unknown
to reservations used to log a WARNING and re-warn every tick forever with no
path to resolution; it now warns once per reservation id per process,
pruned against each tick's known-fork-id set the same way the fork-backstop
give-up counter is pruned. Finally, the wiring-staging heal's ledger read
(onedb.get(ForkWiringLedger, id)per ACTIVE fork per tick) is now a
single column-only preload of(reservation_id, last_staged_fork_version)
in chunks of 500, with the fresh per-rowdb.getkept only for forks that
actually need healing so the read-to-write window for those rows is
unchanged. - Fixed a race where a fork restore committing between a save's read and its
commit could have its restore-to-draft marker silently dropped by the
save's stale in-memory copy: every fork-mutating route (restore, the loose
canvas PUT, save, and prune-devices) now loads the fork row under
SELECT ... FOR UPDATE, held through its own commit or rollback, so the
writers serialize instead of racing (issue #626).
Outbox and events
- Fixed outbox LISTEN task hardening (2026-09-04 review sweep, four confirmed
findings inherd_common/outbox.py's_listen_for_wakeupsand
run_outbox_relay): (1) the lost-connection branch (the registered
termination callback firing) now sleepsretry_secondsbefore
reconnecting, exactly like the connect/registration-failure branch, so a
pooler,idle_session_timeout, or reaper that terminates the idle LISTEN
session cannot turn into a tight reconnect loop; every iteration also
closes the connection it opened (if any) in afinally, guarded by a 5s
asyncio.wait_for, before the next one is opened, so a flapping session
cannot leak a backend per cycle, andwakeis set only after a
registration actually succeeds (a failedadd_listenerno longer falsely
claims a catch-up). (2) The listener now connects with kwargs from
engine.dialect.create_connect_args(engine.url)instead of a rendered DSN
string: the SQLAlchemy URL's query-string spellings (ssl,
prepared_statement_cache_size) are not the spellings asyncpg's own DSN
parser accepts, so a?ssl=requireor?prepared_statement_cache_size=0
deployment previously lost wake-on-write silently (a WARNING every tick,
no health signal); this was proven live against the gate Postgres before
the fix. (3)run_outbox_relaynow loops immediately, without waiting any
part of a tick, when a drain comes back exactlyOUTBOX_BATCH_SIZErows:
Postgres collapses one committing transaction into a single NOTIFY
regardless of how many outbox rows it staged, so a commit that staged more
than one batch's worth (the expiration sweep's per-expired-reservation
reservation.completedevents are a real example) previously got one
wake and then waited a full tick for the remainder. (4) Added direct test
coverage for the termination-then-backoff path and the registration-failure
path, neither of which any existing test exercised. Every existing outbox
behavior (clear-before-drain, wake honored only on a healthy tick, backoff
math, cancellation propagation,wake_on_write=falseas the tick-only
escape hatch, listener cancelled in the relay'sfinally) is unchanged and
still pinned by the existing tests. - Changed the transactional outbox relay to wake on write instead of only
polling a fixed tick (issue #682):enqueue_eventnow issues
SELECT pg_notify(channel, '')on the committing session (a no-op on
SQLite), on a per-service-schema channel namedherd_outbox_<schema>
(herd_outbox_reservations,herd_outbox_execution);run_outbox_relay
(started by both the reservations and execution services, the only two
outbox producers) starts a supervised Postgres LISTEN task and drains
immediately on a notification instead of waiting out the rest of the
tick, live-measured at low single-digit milliseconds from commit to
publish. The tick remains the fallback cadence, unchanged outage
backoff: a missed notification, a not-yet-reconnected listener, or any
non-Postgres dialect still drains on the next tick exactly as before.
NewOUTBOX_WAKE_ON_WRITEsetting (default true, both services) is the
ops escape hatch back to tick-only behavior; execution also gains the
three existing outbox tick/batch/retention overrides reservations
already had, closing the gap where execution exposed none of them. - Fixed the notifications, execution, and integration NATS pull consumers to
fetch one message per pull instead of a batch of 10, so nats-py can no
longer hold an already-delivered message for up to the fetch timeout while
waiting for the rest of a batch that never fills (issue #648).
AI orchestrator
- Fixed the AI commit path silently dropping an approved network-element
attachment when inventory's ports fetch failed (issue #717):
_fetch_device_portsnow raisesCommitError(503)on a transport failure
or a 5xx from inventory instead of treating it the same as a genuinely
portless device (a 404 is still "no ports"). The fetch already runs before
the topology is created, so the commit fails closed with nothing to roll
back rather than silently omitting the user's approved attachment. - Stopped four ai-orchestrator routes from returning raw provider or
internal exception text in their HTTPdetail(issue #713). Topology
generation (POST /generate) now answers a providerAIErrorwith the
fixedAI returned no usable responseand any other exception with
AI call failed; purpose classification answersAI classification failed; the admin-only template identity suggestion answers
AI suggestion failedand recipe draftingAI recipe drafting failed.
Each site logs the real exception with its traceback server-side
(logger.exception) so nothing is lost for operators, matching the rule
the reservation assistant already applied. - Indexed
assistant_conversationson(reservation_id, created_at)in
ai-orchestrator (issue #712, migration 0005) and bounded the transcript
read that purpose classification uses. The read is now two steps: the
reservation's conversation ids ordered bycreated_at, then only the
newest 200 message rows across those conversations (ordered by
conversationcreated_atandposition, never a bareposition, which
resets per conversation), selecting just(role, content_blocks, position)and reversed in Python before the existing role filter and
12000-character trim. The old(user_id, reservation_id)composite index
is kept for now; dropping it is a follow-up. - Hardened the purpose-classification request path in ai-orchestrator
(issue #709). BothPOST /classify-purpose/previewand
POST /internal/classify-purposenow bound their bodies:purposeat
2000 characters,device_idsat 200,dynamic_requestsat 50 (the caps
reservations' ownReservationCreatealready enforces) andcategories
at 64, each rejected with 422. The provider-configured (503) and daily
quota (429) gates now run BEFORE the signal gather in both handlers, so an
unconfigured provider or an over-quota caller can no longer drive the
inventory and cabling fan-out.dynamic_requestsare deduped by template
id before fetching (counts for a repeated template are summed, matching
reservations' N-entries-means-N-instances semantic), and the internal
pass's per-device inventory reads (device detail and config-apply job
summaries) plus the per-template reads run concurrently under a
semaphore of 8 instead of strictly one after another; results keep
request order and the per-item drop-on-failure contract is unchanged. - Added AI-proposed network elements (issue #632): the topology generator's
propose_topologytool gains an optionalelementsarray (role,
element_typefrom the ADR 0012 vocabulary, label, and an allowlisted
attrsobject), and the model may attach a device to an element with one
edge from the device role to the element role; an element-to-element edge
or a role reused across a device and an element is rejected by the
existing validate-and-repair loop. The committer, not the model, picks
the device-side attachment port on commit, in natural port-name order,
skipping ports already claimed by another attachment of the same device
in the proposal.GenerateResponse/CommitRequestgain the matching
additiveelementsfield; a device-only proposal is unaffected. See
docs/AI_GENERATE.md.
Security
- Security:
GET /api/cabling/connectionsno longer hands every authenticated
user the whole fleet's cabling graph (issue #719, surfaced by the 2026-09-04
review sweep while verifying the fork-membership finding, #701; the
fleet-wide dump was the reconnaissance step that made that exploit
turnkey). A non-admin caller is now filtered in SQL to connections where at
least one endpoint device is visible to them, resolved by forwarding the
caller's own JWT to inventory'sGET /device-groups/visible-devices
self-service lookup;totaland pagination reflect the filtered set, not a
post-filtered page, and an empty visible set short-circuits to an empty page
with no query at all. Admin and superadmin callers stay unfiltered and never
trigger the inventory lookup. Fails closed for non-admins: an unreachable or
non-2xx inventory answer returns 503 with nothing, rather than falling back
to an unfiltered list.docs/ROLES.mddocuments the filter and the admin
passthrough. - Security: inventory's device config-version reads (
GET /devices/{id}/config-versions,.../config-versions/diff,.../config- versions/{version_id}) now enforce the same non-admin group-visibility
gate asGET /devices/{id}andGET /devices/{id}/ports(issue #718, a
2026-09-04 review sweep decision item). Previously the three reads
required only authentication, so any authenticated user could read
another group's config history (IPs, hostnames, VLAN maps, routes, author
attribution, and any free-form driver config) for a device outside their
own visibility, even though the sibling device and port reads already
404 a non-visible device. A non-admin caller outside the device's groups
now gets 404 with the identical detail as the device read, so the
endpoint cannot be used to tell "hidden" from "absent"; admins remain
unfiltered. The write endpoints (create, restore, apply, schedule) are
unchanged, since they already run themanage-or-active-reservation
guard._resolve_visible_device_idsmoved out ofapp/routers/devices.py
intoapp/services/device_visibility.pyso device_configs.py can share it
without a router-to-router import; ports.py now imports it from the same
place. Documented indocs/ROLES.md. - Security:
GET /api/auth/groups/{group_id}is now admin/superadmin only
(issue #711, 2026-09-04 review sweep finding). The route returned every
member's email to any authenticated user, and since open self-registration
underAUTH_METHOD=localputs a fresh account in "Not Grouped" and
GET /groups?limit=500lists every group, one registration plus one
detail call per group let a caller enumerate emails wholesale, which is
exactly what/api/auth/register's generic 409 exists to prevent.GET /groups,GET /groups/user/{id}, andPOST /groups/users/groupsare
unchanged: they carry no member payload and gating them would break ACL
checks and device-group visibility for plain users.docs/ROLES.mdis
corrected to stop claiming a user can read group member details. - Security fix: the cross-reservation port-claim check (ADR 0006 Decision 4)
is now an actual invariant instead of a save-boundary guard (2026-09-04
review sweep finding, issue #721). Two gaps:save_fork's claim check was a
plain SELECT against other ACTIVE forks' committed rows, and the engine
runs at Postgres default READ COMMITTED, so two concurrent saves on two
different forks each ran that SELECT against the other's still-uncommitted
insert, textbook write skew, withuq_fork_connections_endpointsscoped
per-fork so nothing failed at commit either; the version-allocation retry
loop named as the mitigation only ever serializes a same-fork version
collision, which the claim check excludes by construction, so it never
closed this window. Separately,fork_service.create_fork's activation
snapshot never ran the claim check at all, so two reservations forking the
same topology, or two topologies sharing a trunk, could both materialize
the same physical hops with zero concurrency involved.save_forkand
create_forknow both call the newfork_save_service.lock_port_claims
immediately before the claim check: a transaction-scoped Postgres advisory
lock (herd_common.advisory_lock.xact_lock) over the sorted, canonical
forkport:{device_id}:{port}keys of every claimed endpoint, keyed via
advisory_key_from_stringexactly like reservations'
_acquire_device_locks. The second writer blocks until the first's
transaction commits or rolls back, so its own claim check then reads the
winner's committed rows and 409s correctly; the lock self-gates to a no-op
on SQLite. Reservations'ForkMembershipRefusedis generalized from the
endpoint-membership 409 shape alone to any 409 cabling's fork-create route
returns, so a port-claim conflict at activation gets the same definitive,
not-retried treatment (WARNING logged, reservation stays ACTIVE unwired,
expiration-sweep backstop skips it) that a foreign-device refusal already
got. Documented in the ADR 0006 amendment; proved live against Postgres in
services/cabling/tests/test_fork_port_claim_race_live_pg.py
(_gate-pg-live-tests), confirmed to fail on main without the lock. - Security fix: fork saves and activation snapshots now check the canvas's
endpoint devices against the reservation's membership (2026-09-04 review
sweep finding, security/HIGH). Since ADR 0009 phase 7 made the fork the sole
driver of provisioning, nothing compared a fork canvas's endpoint device ids
to the reservation's device set, so a user could name a foreign device as a
canvas node and drive real provisioning onto it. Cabling'sForkCreateand
the fork-save request now carry a requiredmember_device_ids;save_fork
andcreate_fork's activation snapshot both refuse (409
fork_device_not_member, naming the offending device ids) any canvas node
outside that set, checking endpoint devices only, never a resolved path's
transit devices or network element nodes. Reservations forwards its own
device set (materialized dynamic instances included) on every fork
create/save call and fails closed if that set cannot be read. Admins are not
exempt: PATCH-add is the way to bring a device into a reservation. A 409 on
activation is treated as definitive, not retried, and the expiration sweep's
missing-fork backstop stops re-attempting a reservation once refused. An
existing fork whose canvas already carries a non-member endpoint will 409 on
its next save; the detail names the offending devices so the owner can
PATCH-add or remove them.
Phase 2 (issue #701) moves the same check to the front door: cabling's
POST /topologies/{id}/validate/internalgains an additivedevice_ids
field (the canvas's device nodes), riding reservations' existing single call
to that endpoint at create/update time. Creating a reservation with a
topology_idwhose canvas names a device outsidedevice_idsnow fails
fast with422(topology_device_not_member, naming the offending device
ids) before any row is written, and a PATCH that changesdevice_idson a
topology-bound reservation re-runs the same check (400, same detail
shape), instead of the mismatch only surfacing later as a fork 409 on
activation. - Security: scheduled device-config apply jobs re-check the creator's
authority at fire time instead of relying solely on the schedule-time
gate (issue #704). A job with noreservation_idfired straight into
execution's internal-token path with no further check, and a caller-
suppliedreservation_idwas never validated as active, owned, or
containing the device; nothing revoked a queued job when its creator's
ACL grant was removed or their reservation ended. Adds two internal-token
routes (auth'sGET /internal/users/{id}/groups, acl's
POST /internal/check) andherd_common.acl.user_has_manage_internal/
user_has_manage_or_owns_active_reservation_internalso the same
schedule-time authorization (explicitmanagegrant, or reservation-
owner of an active reservation containing the device) can be re-evaluated
with only the job creator's user_id, no user JWT.fire_jobnow runs this
check unconditionally before dispatching to execution and resolves
skippedwithcreator no longer authorized for this deviceon failure.
schedule_apply_jobalso now validates an optionalreservation_id
up front (422 if it is not an active reservation the caller owns that
contains the device) and boundsscheduled_forwith a new
apply_job_max_horizon_dayssetting (default 30 days, 422 beyond it).
Documented indocs/ROLES.mdanddocs/ENV_VARS.md. - Fixed the base compose file publishing the unauthenticated Traefik
dashboard and API (api.insecure: true) on all interfaces, somake prod
exposed/api/rawdata(every router rule, backend container address,
middleware chain) to anyone who could reach port 8080 (issue #708).
docker-compose.ymlnow binds it127.0.0.1:8080:8080; the dev override
deliberately adds no second binding, since compose merges port lists and
nothing in dev, CI, or QA reaches the dashboard off-host.FRESH_SETUP.md
describes the SSH tunnel for remote viewing, and a repo-root unit test
(tests/unit/test_compose_ports.py) yaml-parses both compose files and
pins the loopback-only publish. - Security:
/api/ai/generateno longer buffers a whole multipart upload
into memory before its file-count and size caps run (issue #705):
_read_uploadsrejects a too-many-files request before reading a single
byte, then reads each remaining part in 64 KiB chunks with a running
per-file and aggregate total, aborting with 400 the instant either cap is
crossed instead of after the whole part is buffered.UploadFile.sizeis
treated as an untrusted hint only, never load-bearing for the check.
extract_files's own caps are unchanged and still re-run as defense in
depth on the now-bounded upload. - Fixed
PATCH /preferencesin the user-profile service validating only the
incoming dict, never the merged result, so repeated patches could grow one
JSONB row past every cap (issue #714). The service now validates each
merged dict (the 200-key and 64 KB caps onsaved_filtersandextras,
the key cap and page-size range onpage_sizes) before assigning anything
and answers 422 with amerged <field> ...detail; a rejected PATCH
leaves the row exactly as it was.PUTandDELETEremain the shrink
paths.
Inventory and auth
- Changed inventory's
apply_schedulerto record a config-apply run whose
execution response carries nostatusasfailedinstead ofsuccess
(issue #720); unreachable today, since the contract requiresstatus. - Fixed an admin being able to deactivate the superadmin through
POST /users/{id}/deactivate(issue #715). The endpoint now refuses a
superadmin target with 400Cannot deactivate the superadmin, mirroring
the role-change carve-out;POST /users/{id}/activateis deliberately
unchanged, since it is the recovery direction. A deactivated superadmin
could not log in or refresh, was not re-seeded at startup, and the LDAP
sync never reactivates a local user.
Frontend
- Fixed device lists silently truncating at the inventory service's 500-row
page cap (issue #703).fetchDevicesfetched page 0 of 500 and dropped
total, so with more than 500 devices the reporting page's device index
missed the oldest ones and attributed their hours to the "Unknown"
template bucket (and the client-built by-template CSV exported that),
while the device-group and topology-template pickers, the equipment
browser, and the calendar showed partial lists.ReportingPagenow
resolves exactly the devices the report mentions through the batch
endpoint via the new chunkedfetchDevicesByIdsanduseDevicesByIds
(hoisted fromhydrateCanvasNodes), and the other four consumers use the
newfetchAllDevices/useAllDevicespage walker (server-side filters
honored;fetchAllDeviceNamesis a map over it). The server cap is
unchanged; the page-0-of-500 idiom in the other API modules is left for a
follow-up.
Developer platform, CI, and tests
- Added a
classify_sweep_firstpytest marker (issue #706 follow-up), read
by a newpytest_collection_modifyitemshook in
tests/integration/conftest.pythat moves any item carrying it to the
front of collection. The purpose-classify sweep classifies its backlog
oldest-first and serially at model speed, sotest_purpose_review_flow.py's
AI-gated test now runs before the rest oftests/integration/has a
chance to queue its own cancelled/completed reservations ahead of it and
push it past its poll budget on ordering alone, not a reconciler defect.