Skip to content

Locking Mechanism#335

Open
RiSKeD wants to merge 6 commits into
mainfrom
feat/locking-mechanics
Open

Locking Mechanism#335
RiSKeD wants to merge 6 commits into
mainfrom
feat/locking-mechanics

Conversation

@RiSKeD
Copy link
Copy Markdown
Contributor

@RiSKeD RiSKeD commented May 19, 2026

resolves #319

@RiSKeD RiSKeD force-pushed the feat/locking-mechanics branch 4 times, most recently from c6a5266 to cb8bc7d Compare May 21, 2026 13:50
RiSKeD added 6 commits May 21, 2026 15:54
Add an in-memory Locker tracking two independent slots per device: an
explicit slot (Lock/ClearLock, requires a positive expiry) and an auto
slot (AutoLock/ClearAutoLock, command-scoped, no expiry). ClearLock and
ClearAutoLock share the same signature and error contract so callers can
reason about them as one pattern. ForceClearLock wipes both slots as an
admin escape hatch. Lock rejects non-positive durations with
ErrInvalidDuration. Add the shared OwnerHeader const used to carry owner
identity over HTTP.

Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
The "lock" and "unlock" command names are now reserved for the per-device
locking RPCs. decodeCmds rejects them with a new ErrReservedCommand sentinel.

Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
Add Lock/Unlock to the DeviceService proto and implement them on the
dutagent: Lock acquires or extends a per-device lock, Unlock releases it
(with a force option that releases regardless of owner). Owner identity
is read from the OwnerHeader. Non-positive lock durations are rejected
with InvalidArgument. dutserver embeds the Unimplemented handler since
it does not forward these RPCs.

Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
Add three FSM states for per-device locking on Run: checkDeviceAccess
rejects Runs by non-owners with FailedPrecondition; acquireAutoLock
takes a command-scoped auto-lock; releaseAutoLock clears it once the
command finishes. The Run RPC handler also delegates to releaseAutoLock
as a safety net so auto-locks are not leaked on FSM error paths.
dutserver forwards the owner header to the upstream agent.

Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
ListResponse now carries structured DeviceInfo with per-device lock state
instead of bare device names. The dutctl client renders locked devices with
a "[locked by ...]" annotation and adds a lock-result output type for the
upcoming lock/unlock commands.

Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
Add "dutctl <device> lock [duration]" and "dutctl <device> unlock
[--force]" subcommands, plus a -u flag to set the lock owner identity
(defaults to user@host). The owner is sent on Run, Lock and Unlock via
the OwnerHeader. Lock duration defaults to 30m and must be positive.

Signed-off-by: Fabian Wienand <fabian.wienand@blindspot.software>
@RiSKeD RiSKeD force-pushed the feat/locking-mechanics branch from cb8bc7d to 8f3f686 Compare May 21, 2026 14:15
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.

Add lock/unlock mechansim

1 participant