Skip to main content

Layer 8 · place

resource

blocks/8-place/resource.yaml

layer 8place
2entities
8commands
8events
3views
41refusals
5KPIs

What agents share and wait for: a pool of a fixed capacity (build slots, a rate limit, a cache, seats, a work queue) and the claims on it. A claim is for one or more units of the pool. It waits in the queue until the pool grants it, or until its wait limit, if it names one, has passed; holds for at most its time limit, and ends released, expired or killed; its holder may withdraw it while it is queued. A claim over capacity, or of more units than are free, waits; it is never refused for that. The queue publishes when each claim joined it (queued_at). A pool grants in its order: Fifo (the default) in queue order, so a grant while an earlier claim of the pool still waits is refused, and a claim on it names no priority; Priority by the claim's priority, highest first, equal priorities in queue order and a claim without a priority behind every claim with one, so a grant while a claim that comes before it still waits is refused.

Depends on​

  • channel · layer 7 · 7 references
  • work · layer 5 · 5 references
  • shared · layer 0 · 3 references

Used by​

No block depends on this one.

Entities​

Claim​

One party's claim on one or more units of a pool, for at most its time limit, waiting for at most its wait limit if it names one.

Identified by claim_id (ClaimId).

fieldtypemeaning
pool_idPoolId
holderPartyId
time_limit_secondsinteger
unitsintegerThe units of the pool the claim holds once granted; one unless the request names more.
queued_attimestampWhen the claim joined the queue; the pool grants queued claims in this order, after priority on a pool of order Priority.
priorityoptional integerThe claim's priority on a pool of order Priority, higher first; a claim without one waits behind every claim with one. A pool of order Fifo takes none.
held_untiloptional timestamp
wait_untiloptional timestampThe instant the claim gives up waiting if it is still queued: the request time plus the claimant's wait limit. Absent, the claim waits until it is granted or withdrawn.
run_idoptional RunIdThe run the claim was made for; absent for a claim of no run.
step_idoptional StepIdThe step of that run that holds the claim. A step (agentic.work, a lower layer) names no claim, so the claim names the step it was held for.

Relations:

  • pool references Pool (one, by pool_id)
  • run references Run of work (one, by run_id)
  • step references Step of work (one, by step_id)

Always holds: time_limit_seconds > 0, units > 0.

Lifecycle of Claim

ExpiredHeldKilledQueuedReleasedWaitExpiredWithdrawngrantreleaseexpirekillwithdrawgive_upExpiredHeldKilledQueuedReleasedWaitExpiredWithdrawngrantreleaseexpirekillwithdrawgive_up
Ends in Expired, Killed, Released, WaitExpired, Withdrawn.

Pool​

A shared resource with a fixed number of units, each held by one claim at a time.

Identified by pool_id (PoolId).

fieldtypemeaning
nameName
kindPoolKind
capacityinteger
heldintegerThe units the claims hold now.
freeintegerThe units no claim holds now.
orderoptional PoolOrderThe order the pool grants waiting claims in; without it, Fifo.

Always holds: capacity > 0, held >= 0, held <= capacity, free >= 0, free <= capacity.

Lifecycle: one state, Open; a recorded Pool does not change.

Commands​

CreatePool​

Create a pool.

Called by: Scheduler.

fieldtype
nameName
kindPoolKind
capacityinteger
orderoptional PoolOrder
outcomewhenresult
zero-capacity refusedcapacity <= 0ZeroCapacity: A pool has at least one unit.
createdotherwisecreates a Pool in Open; emits PoolCreated

ExpireClaim​

Expire a claim. The pool ends a held claim whose time limit has passed.

Called by: Scheduler.

fieldtypemeaning
pool_idPoolId
claim_idClaimId
unitsintegerThe claim's units.
outcomewhenresult
unknown-pool refusedno such PoolUnknownPool: No pool has this identity.
unknown-claim refusedno Claim for claim_idUnknownClaim: No claim has this identity.
other-pool refusedthe Claim of claim_id has pool_id != input.pool_idOtherPool: The claim was made on another pool.
not-held refusedthe Claim of claim_id has state != HeldClaimNotHeld: The claim does not hold a unit.
limit-not-reached refusedthe Claim of claim_id has held_until > nowLimitNotReached: The claim's time limit has not passed.
units-mismatch refusedthe Claim of claim_id has units != input.unitsUnitsMismatch: The units named are not the claim's units.
expiredotherwiseupdates the Pool; moves each Claim with claim_id == input.claim_id and state == Held to Expired; emits ClaimExpired

ExpireWait​

End a claim's wait. The pool ends a queued claim whose wait limit has passed.

Called by: Scheduler.

fieldtype
claim_idClaimId
outcomewhenresult
unknown-claim refusedno such ClaimUnknownClaim: No claim has this identity.
no-wait-limit refusednot (defined(wait_until))NoWaitLimit: The claim names no wait limit; it waits until it is granted or withdrawn.
wait-not-over refuseddefined(wait_until) and wait_until > nowWaitNotOver: The claim's wait limit has not passed.
wait-expiredotherwisemoves the Claim Queued → WaitExpired; emits ClaimWaitExpired
wrong-state refusedthe Claim is in a state that does not allow itClaimStateConflict: The claim is not in a state this command acts from.

GrantClaim​

Grant a claim. A queued claim takes its units of its pool, when that many are free.

Called by: Scheduler.

fieldtypemeaning
pool_idPoolId
claim_idClaimId
held_untiltimestamp
unitsintegerThe claim's units.
outcomewhenresult
unknown-pool refusedno such PoolUnknownPool: No pool has this identity.
missing-pool refusedno Pool for pool_idUnknownPool: No pool has this identity.
unknown-claim refusedno Claim for claim_idUnknownClaim: No claim has this identity.
pool-full refusedthe Pool of pool_id has held >= capacityPoolFull: Every unit is held; the claim stays queued.
other-pool refusedthe Claim of claim_id has pool_id != input.pool_idOtherPool: The claim was made on another pool.
not-queued refusedthe Claim of claim_id has state != QueuedClaimNotQueued: The claim is not waiting in the queue.
units-mismatch refusedthe Claim of claim_id has units != input.unitsUnitsMismatch: The units named are not the claim's units.
too-few-free-units refusedthe Pool of pool_id has free < input.unitsTooFewFreeUnits: Fewer units are free than the claim holds; the claim stays queued.
out-of-order refuseda Claim with claim_id == input.claim_id and not (defined(priority)) and some earlier in each Claim with earlier.pool_id == pool_id and earlier.state == Queued and not (defined(earlier.priority)) and earlier.queued_at < queued_atNotFirstInQueue: A claim of the same pool that joined the queue earlier is still waiting; the pool grants in queue order.
out-of-priority refuseda Claim with claim_id == input.claim_id and some ahead in each Claim with ahead.pool_id == pool_id and ahead.state == Queued and defined(ahead.priority) and (not (defined(priority)) or defined(priority) and ahead.priority > priority or defined(priority) and ahead.priority == priority and ahead.queued_at < queued_at)NotFirstByPriority: A claim of the same pool that comes first by priority is still waiting: one of a higher priority, one of the same priority that joined the queue earlier, or, for a claim without a priority, one with a priority. The pool grants by priority.
grantedotherwiseupdates the Pool; moves each Claim with claim_id == input.claim_id and state == Queued to Held; emits ClaimGranted

KillClaim​

Kill a claim. The pool ends a held claim by force.

Called by: Scheduler.

fieldtypemeaning
pool_idPoolId
claim_idClaimId
unitsintegerThe claim's units.
outcomewhenresult
unknown-pool refusedno such PoolUnknownPool: No pool has this identity.
unknown-claim refusedno Claim for claim_idUnknownClaim: No claim has this identity.
other-pool refusedthe Claim of claim_id has pool_id != input.pool_idOtherPool: The claim was made on another pool.
not-held refusedthe Claim of claim_id has state != HeldClaimNotHeld: The claim does not hold a unit.
units-mismatch refusedthe Claim of claim_id has units != input.unitsUnitsMismatch: The units named are not the claim's units.
killedotherwiseupdates the Pool; moves each Claim with claim_id == input.claim_id and state == Held to Killed; emits ClaimKilled

ReleaseClaim​

Release a claim.

Called by: Claimant.

fieldtypemeaning
pool_idPoolId
claim_idClaimId
holderPartyId
unitsintegerThe claim's units.
outcomewhenresult
holder-not-the-caller refusedholder != caller.partyNotTheHolder: Only the claim's holder releases it.
unknown-pool refusedno such PoolUnknownPool: No pool has this identity.
unknown-claim refusedno Claim for claim_idUnknownClaim: No claim has this identity.
other-pool refusedthe Claim of claim_id has pool_id != input.pool_idOtherPool: The claim was made on another pool.
not-the-holder refusedthe Claim of claim_id has holder != input.holderNotTheHolder: Only the claim's holder releases it.
not-held refusedthe Claim of claim_id has state != HeldClaimNotHeld: The claim does not hold a unit.
units-mismatch refusedthe Claim of claim_id has units != input.unitsUnitsMismatch: The units named are not the claim's units.
releasedotherwiseupdates the Pool; moves each Claim with claim_id == input.claim_id and state == Held to Released; emits ClaimReleased

RequestClaim​

Request a claim. The caller joins the queue of a pool for the units it names (one, if it names none), for at most the time limit, with a priority if it names one, for the run and step it names, if any, and until the wait deadline it names, if any.

Called by: Claimant.

fieldtypemeaning
pool_idPoolId
time_limit_secondsinteger
unitsoptional integerThe units of the pool the claim is for; one if absent.
wait_untiloptional timestampThe instant the claim gives up waiting; the request time plus the wait limit.
priorityoptional integer
run_idoptional RunIdThe run the claim is made for.
step_idoptional StepIdThe step of that run that will hold the claim.
outcomewhenresult
no-time-limit refusedtime_limit_seconds <= 0NoTimeLimit: A claim names a time limit of at least one second.
no-units refuseddefined(units) and units < 1NoUnits: A claim names at least one unit.
unknown-pool refusedno Pool for pool_idUnknownPool: No pool has this identity.
priority-on-fifo refusedthe Pool of pool_id has defined(input.priority) and (not (defined(order)) or order == Fifo)PriorityNotTaken: The pool grants in queue order (Fifo) and takes no priority; only a pool of order Priority does.
queuedotherwisecreates a Claim in Queued; emits ClaimQueued

WithdrawClaim​

Withdraw a queued claim. The holder takes a claim back before the pool grants it; the pool is not touched.

Called by: Claimant.

fieldtype
claim_idClaimId
holderPartyId
outcomewhenresult
holder-not-the-caller refusedholder != caller.partyNotTheHolder: Only the claim's holder releases it.
unknown-claim refusedno such ClaimUnknownClaim: No claim has this identity.
not-the-holder refusedholder != input.holderNotTheHolder: Only the claim's holder releases it.
withdrawnotherwisemoves the Claim Queued → Withdrawn; emits ClaimWithdrawn
wrong-state refusedthe Claim is in a state that does not allow itClaimStateConflict: The claim is not in a state this command acts from.

Events​

eventfieldsemitted by
ClaimExpiredclaim_id ClaimId, pool_id PoolIdExpireClaim
ClaimGrantedclaim_id ClaimId, pool_id PoolId, held_until timestampGrantClaim
ClaimKilledclaim_id ClaimId, pool_id PoolIdKillClaim
ClaimQueuedclaim_id ClaimId, pool_id PoolId, holder PartyId, time_limit_seconds integerRequestClaim
ClaimReleasedclaim_id ClaimId, pool_id PoolIdReleaseClaim
ClaimWaitExpiredclaim_id ClaimId, pool_id PoolIdExpireWait
ClaimWithdrawnclaim_id ClaimIdWithdrawClaim
PoolCreatedpool_id PoolId, kind PoolKind, capacity integerCreatePool

Views​

viewrowsfields
Claims
Claims
each Claimclaim_id ClaimId, pool_id PoolId, holder PartyId, time_limit_seconds integer, units integer, held_until optional timestamp, wait_until optional timestamp, queued_at timestamp, run_id optional RunId, step_id optional StepId, state State
Pools
Pools
each Poolpool_id PoolId, name Name, kind PoolKind, capacity integer, held integer, free integer, state State
Queue
Queue of a pool
each Claim with pool_id == param.pool_id and state == Queued
asked with pool_id PoolId
claim_id ClaimId, holder PartyId, time_limit_seconds integer, queued_at timestamp

Types​

typeisvalues or fields
PoolKind
What a pool hands out: build slots, calls under a rate limit, cache entries, seats of a licence, or the places of a work queue whose claims are the items waiting to be taken.
one ofBuildSlots, RateLimit, Cache, Seats, Queue
PoolOrder
The order a pool grants waiting claims in: the order they joined the queue (Fifo), or the claim's priority, highest first, then the order they joined (Priority).
one ofFifo, Priority

KPIs​

5 KPIs from the KPI catalogue. A gate must be zero for a variant of an architecture to count.

Quality​

KPIunitbettergatestatus
queue_wait_p50_seconds
Median time a claim waited in the queue.
How: Seconds between ClaimQueued and ClaimGranted, median over a pool.
secondslower–simulated
source: design
queue_wait_p90_seconds
90th percentile of the time a claim waited in the queue.
How: Seconds between ClaimQueued and ClaimGranted, 90th percentile over a pool.
secondslower–simulated
source: design
pool_utilization
Share of pool slot-seconds that were held.
How: Slot-seconds between ClaimGranted and ClaimReleased, ClaimExpired or ClaimKilled, divided by slot-seconds the pool offered, capacity drops included.
sharehigher–simulated
source: design
jobs_killed
Claims killed at their time limit.
How: ClaimKilled events in the window. Each is a job that ran past its limit.
countlower–simulated
source: design
slot_wait_share
Share of agent time spent waiting for a pool slot.
How: Seconds agents wait between ClaimQueued and ClaimGranted, divided by instance seconds.
sharelower–simulated
source: design

Settings​

The settings a part of this block carries in an architecture document. agenticspec sim check refuses any other setting (setting_unknown) and a value outside its type (setting_invalid), and a part that lacks a setting marked required in the default column; the contract copies a setting into the ports it narrows. The last rows of each table are the settings every part takes. What no setting here types (a file, a path, an audience, the use of a model) goes into the part's notes, a map with free keys and values that the check takes as written and nothing reads.

A part pool:

settingtypeunitdefaultcontractwhat
kindenum PoolKind: build_slots, rate_limit, cache, seats, queueresource.claimWhat the pool hands out.
capacityinteger of at least 1slotsrequiredresource.claimHow many claims the pool holds at once; a claim over it waits in the queue until the pool grants it, in the pool's order.
job_limitduration of at least 1srequired unless kind is queueresource.claimHow long one claim may hold a slot, the time limit of every claim on the pool; a claim held longer ends expired. A work queue (kind queue) may leave it out: the pool then sets no hold limit of its own.
orderenum PoolOrder: fifo, priorityfiforesource.claimThe order the pool grants waiting claims in: the order they joined the queue (fifo; a claim names no priority), or the claim's priority, highest first, then the order they joined (priority).
countinteger of at least 11How many copies of the part run.
perpartOne copy of the part for each copy of the named part.
notesnotesFree notes on the part, a map with keys and values of any kind: what no setting of its block types. The check takes any map; the simulator, the search and the contract never read it.