archied, archie-ui and the tool gateway re-read the stored policies on a 30s ticker, so a forbid written seconds earlier did not stop a run. One instance-wide revision now moves inside the transaction of every policy write, and a decision reads it first and rebuilds the engine only when it moved. A version read that fails, or a policy list that fails after a bump, refuses with ErrChainUnavailable instead of standing on the last chain, so three call sites now treat unavailable as availability rather than denial: dispatch leaves the capture for the next cycle, a task start parks transient, and the tool gateway reports the tool as unavailable.
19 lines
808 B
SQL
19 lines
808 B
SQL
-- One instance-wide policy version, bumped inside the transaction of every
|
|
-- policy write, so a process that authorizes can tell before each decision
|
|
-- whether its engine is current. Per-level counters cannot carry that: an edit
|
|
-- outside the level that currently holds the highest version is invisible, a
|
|
-- delete can move the highest version down, and an instance reset writes no
|
|
-- version at all. A singleton row, because access_policy_versions.level only
|
|
-- admits the real levels.
|
|
|
|
-- +goose Up
|
|
CREATE TABLE access_policy_revision (
|
|
only_row boolean PRIMARY KEY DEFAULT true CHECK (only_row),
|
|
version bigint NOT NULL DEFAULT 1,
|
|
updated_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
INSERT INTO access_policy_revision (only_row) VALUES (true);
|
|
|
|
-- +goose Down
|
|
DROP TABLE access_policy_revision;
|