Skip to content

feat(roadmap): keep plan records and record locks in Valkey #4564

Open

Description

@dan-petty

Problem or Motivation

The stage plan records and refused replies are files (src/devops_cli/roadmap/stage/stage_plan_record.py:1-9; 29 files, 2.5 MB). "A rerun or --confirm with the same key reads the file and sends the planner no request" (stage_plan_record.py:6-7). In a stage Job the file lives in an emptyDir and goes with the pod, so a rerun plans again and spends tokens.

The job record lock is a threading.Lock (src/devops_cli/roadmap/stores/github_store.py:97), so it does not order writers in different pods.

Proposed Solution & Architectural Design

Keys from RepoRef:

  • roadmap:v1:plan:<owner>/<name>:<n>: zstd JSON with its input key, TTL 30 days.
  • roadmap:v1:plan:refused:<owner>/<name>:<n>: list, LPUSH and LTRIM 0 19, TTL 30 days.
  • roadmap:v1:lock:record:<owner>/<name>:<n>: valkey-py Lock, timeout=60, renewed from a thread while held (valkey-py has no renew thread). The writer admits its GET and PATCH in the request window before it takes the lock, and checks owned() just before the PATCH. The read-back repair stays.
  • A writer refuses a value that would take the instance over 70 % of maxmemory.
  • No import code. A plan that is already pushed is on its branch.

Removes: the file reads and writes of stage_plan_record.py (and the path part of plan_record_path, stage_plan_record.py:188-194), _JOB_RECORD_LOCK.

Target Subsystem

Workstation Caching & Valkey (roadmap stage and job records).

Existing Tool Considered

valkey-py Lock (https://valkey-py.readthedocs.io/en/latest/lock.html) plus a renew thread of about 30 lines. A Kubernetes Lease needs an API write for each renew and an API token in the pod. Cost: about 90,000 tokens and 4 hours to build, about 5,000 tokens a month to keep, about 10,000 tokens to fix.

Acceptance Criteria

  • Two processes that write the record of one item take turns; no mark is lost.
  • A lock held longer than its timeout stays held while the writer lives; a lost lock (the key deleted) stops the write before the PATCH.
  • A stage Job rerun with the same input key skips the planner and uses the Valkey record.
  • A full request window does not hold the lock: the admit comes first.
  • Measure: read-back repairs a week drop against the week before; reruns with an unchanged key skip the planner (log line).

Dependencies

  • "fix(roadmap): repair a job record mark that a parallel write lost".
  • "feat(service): share the GitHub budget and holds in Valkey".

Source: #4517

Owner decision 2026-11-13

D5 (approved, tracker #5482): the record stays the hidden block in the issue body, with one writer for each item, the updated_at check and the outside-text compare (#4555). The Valkey lock makes the window smaller. The record moves to an App comment only if the lost-edit counter is above 0 after Phase 3. Valkey holds copies only, never a due mark.

  • Live proof: after the merge and the release, two writers of one live item run as the App, and the second waits for the lock. A comment gives the lock times and 0 lost edits.

Alternatives check of 2026-11-27: in-use.
The repository already uses this tool.
Tool: valkey (https://pypi.org/project/valkey), MIT License, last activity 2026-10-12, maintained.
Reason: Searches and the client's own pages show valkey-py already gives the shared key store with TTL, list commands and a cross-pod Lock with extend, owned and reacquire; the issue names it and the project already pins it.

Covers:

  • Plan record as one key with a TTL
  • List key for the 20 newest refused records
  • Distributed lock shared across pods, with extend and owned
  • Base64 text values through the existing text pool

Lacks:

  • No renewal thread; extend must be called by a watchdog
  • No guard against the instance maxmemory bound
  • No request-window admission before the lock
  • Lock is not fenced; GitHub gives no fence either

Proposed design

Problem statement

A stage plan record and the refused replies are files in a stage pod's emptyDir, which goes with the pod, so a rerun plans again and spends tokens. The job record lock is a threading.Lock, so it does not order writers in different pods. This change keeps the plan record, the refused replies and the record lock in the roadmap Valkey instance valkey-roadmap, and removes the file store and the process lock.

Acceptance criteria

Requirement: Valkey plan record

The stage job SHALL store each plan record with its input key in Valkey under roadmap:v1:plan:<owner>/<name>:<n> as base64-encoded zstd JSON with a 30-day TTL.

Scenario: A record is stored and read back

  • WHEN The stage job stores the record of item 4564 through the Valkey fake, and a second run reads it with the same input key
  • THEN The second run gets the same proposal, request and trace facts, the stored value decodes as zstd JSON, and TTL on the key is 30 days

Requirement: Rerun skips the planner

A stage run with an input key that a Valkey record holds MUST read the record and send the planner no request.

Scenario: A stage Job reruns with an unchanged key

  • WHEN A stage Job reruns with an input key that a Valkey record already holds
  • THEN The run sends no planner request, emits devops_cli_roadmap_stage_plan_record_total with result=hit, and logs the skip

Requirement: Refused replies list

The stage job SHALL keep the 20 newest refused records in a Valkey list under roadmap:v1:plan:refused:<owner>/<name>:<n> with a 30-day TTL.

Scenario: More than 20 records are refused

  • WHEN The gates refuse 25 plan runs for one item
  • THEN LLEN gives 20, the head holds the newest RefusedRecord with its input key, replies and schema failure, and the key has a 30-day TTL

Requirement: One writer for each record

A writer MUST hold roadmap:v1:lock:record:<owner>/<name>:<n> from the GET to the PATCH of the job record of an item.

Scenario: Two processes write one record

  • WHEN Two processes write the record of one item at the same time against one Valkey
  • THEN The writes take turns and the record holds every mark of both writes

Requirement: Lock renewal

The writer MUST renew its 60-second record lock every 20 seconds while it holds the lock.

Scenario: A writer holds the lock past its timeout

  • WHEN A writer holds the lock for 90 seconds of the fake clock, longer than its 60-second timeout
  • THEN The lock stays held until the writer releases it, and a second writer cannot take it

Requirement: Lost lock stops the write

The writer MUST check owned() just before the PATCH and MUST send no PATCH after it loses the lock.

Scenario: The lock key is deleted

  • WHEN The lock key is deleted while a writer prepares a PATCH
  • THEN The writer sends no PATCH, raises the lost-lock error, and reports it

Requirement: Admit before the lock

The writer MUST admit its GET and PATCH in the request window before it takes the record lock.

Scenario: A full request window

  • WHEN The request window is full and a writer waits for an admit
  • THEN The writer holds no record lock while it waits

Requirement: Valkey outage stops the round

A stage job that cannot reach valkey-roadmap MUST wait 60 seconds, exit with code 75, and write no file record.

Scenario: The roadmap Valkey does not answer

  • WHEN The stage job cannot reach valkey-roadmap for its plan record or record lock
  • THEN The record store raises, the run writes no file record, and the job's failure path waits 60 seconds and exits with 75

Requirement: Instance memory guard

A writer MUST refuse a value that would take the instance over 70 % of maxmemory when maxmemory is not zero.

Scenario: A record would pass 70 % of maxmemory

  • WHEN INFO memory reports a used_memory and maxmemory where the encoded record would pass 70 % of maxmemory
  • THEN The writer stores no value, reports the refusal, and the next run plans again

Requirement: No file record and no process lock

The stage plan record module MUST NOT read or write a file, build a filesystem path for a plan record or a refused record, or import an existing file record, and github_store MUST NOT hold _JOB_RECORD_LOCK.

Scenario: The file store and the process lock are gone

  • WHEN The tests search stage_plan_record.py for open(, write_json_file, read_text, write_text, plan_record_path and refused_record_path, and github_store.py for _JOB_RECORD_LOCK
  • THEN Neither is found, and the plan record and refused records are read and written only through ValkeyClient

Requirement: Record stays in the issue body

The change SHALL keep the job record as the hidden block of the issue body and SHALL NOT store a due mark in Valkey.

Scenario: A job record is written

  • WHEN A writer updates the job record of item 4564
  • THEN The hidden &lt;!-- devops-roadmap-record {...} --> block of the issue body holds the record, and the Valkey keys of item 4564 are only its plan record, its refused list and its record lock

Requirement: Pending a person after the merge

A person SHALL run two writers of one live item as the App after the merge and the release, and SHALL compare the read-back repair count with the week before.

Scenario: Two live writers use one item

  • WHEN After the merge and the release, a person runs two writers of one live item as the App and reads devops_cli_roadmap_record_repairs_total
  • THEN The second writer waits for the lock, a comment gives the lock times and 0 lost edits, and the repair count is lower than the week before

Existing Tool Considered

valkey (https://pypi.org/project/valkey), the open, maintained client the repository already uses; the alternatives block of 2026-11-21 in this issue states what the tool lacks, and this change writes that remainder. Written cost of the remainder: about 90,000 tokens and 4 hours to build, about 5,000 tokens a month to keep, and about 10,000 tokens to fix.

Key questions

  • Which client library sends the Valkey commands?: valkey-py 6.2.0. The project pins valkey==6.2.0 in pyproject.toml, and ValkeyClient imports valkey and wraps valkey.Valkey. [sources: pyproject.toml:77, src/devops_cli/valkey/client.py:26, src/devops_cli/valkey/client.py:208]
  • Which lock orders the job record writes today, and where?: _JOB_RECORD_LOCK = threading.Lock() in src/devops_cli/roadmap/stores/github_store.py. set_field, set_fields, set_marks and write_issue_body take it from the GET to the PATCH. A thread lock orders one process, not pods. [sources: src/devops_cli/roadmap/stores/github_store.py:126, src/devops_cli/roadmap/stores/github_store.py:1034, src/devops_cli/roadmap/stores/github_store.py:1065, src/devops_cli/roadmap/stores/github_store.py:1099, src/devops_cli/roadmap/stores/github_store.py:1192]
  • How does the record lock reach the Valkey connection?: Add a lock(name, *, timeout, thread_local=False) method to ValkeyClient that builds a valkey.lock.Lock over the same valkey.Valkey client. The pool and the client are private (self._valkey) and set takes no nx flag, so the record store cannot build the lock today; the new method keeps the one pool, the ACL user, the vetted connection class and the timeout. (best practice) [sources: src/devops_cli/valkey/client.py:196, src/devops_cli/valkey/client.py:208, src/devops_cli/valkey/client.py:244, tests/support/valkey_scenarios.py:133]
    • Chosen: A lock() factory on ValkeyClient. It keeps one pool, one ACL user, the vetted connection class and the timeout of the client, and the fake's contract suite already exercises valkey-py's Lock.
    • Rejected: Expose the raw valkey.Valkey. It hands the store a client that skips the wrapper's egress check and exception types.
    • Rejected: Hand-rolled Lua lock. It duplicates a maintained library and the contract suite that already covers it.
  • Which Valkey key names one item's plan record?: RepoRef.valkey_key('plan', str(n)) gives roadmap:v1:plan:<owner>/<name>:<n>, with the casefolded owner/name. The refused list uses kind plan:refused, and the lock uses kind lock:record. (best practice) [sources: src/devops_cli/github/repo_ref.py:139, src/devops_cli/github/repo_ref.py:203, src/devops_cli/github/repo_ref.py:211, tests/github/test_repo_ref.py:226, docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md]
    • Chosen: roadmap:v1:plan:<owner>/<name>:<n>. It follows ADR 0022 and keeps item numbers apart across repositories.
    • Rejected: plan:<n>. An item number alone collides across repositories.
    • Rejected: A hash for each repository. It adds a lookup and gives no gain.
  • Which Valkey instance holds the plan records, the refused list and the lock?: valkey-roadmap. ADR 0021 makes it the new instance with AOF and noeviction and moves the job record lock and the stage plan records there. valkey-devops stays the cache that evicts keys: it keeps at most 256 MiB and runs --maxmemory-policy allkeys-lru, so a record could vanish before its 30-day TTL. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:76, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:87, k8s/llm/valkey-devops.yaml:86, k8s/README.md:285]
    • Chosen: valkey-roadmap. AOF and noeviction keep a record until its TTL, and ADR 0021 moves the plan records and the record lock there.
    • Rejected: valkey-devops. It evicts the least recently used key at its 256 MiB bound with allkeys-lru, so a record can vanish before its TTL.
    • Rejected: A new instance for this change. The parent already plans one, and a second adds a deployment and credentials.
  • How does the record hold its JSON in Valkey?: Compress the record JSON with compression.zstd and base64-encode the compressed bytes into the ASCII text that ValkeyClient.set accepts. The pool opens with decode_responses=True and encoding_errors='replace', so raw zstd bytes would be decoded as UTF-8 on the way back and corrupted. Python 3.14 provides compression.zstd, and the project requires 3.14 or newer. (best practice) [sources: pyproject.toml:10, src/devops_cli/valkey/client.py:204, src/devops_cli/valkey/client.py:239, src/devops_cli/valkey/client.py:244]
    • Chosen: compression.zstd plus base64. Python 3.14 provides zstd, and base64 keeps the existing text-only client.
    • Rejected: Raw zstd bytes over a binary pool. It adds a second pool or a binary method and a separate decode path.
    • Rejected: Plain JSON. The record holds a proposal, a request and trace facts, and zstd keeps the value small.
  • What does each element of the refused list hold?: Each element holds the JSON of a RefusedRecord: the input key, the refused replies and the schema failure. Compress and base64-encode it like the plan record. LPUSH adds the newest and LTRIM 0 19 keeps the 20 newest. (best practice) [sources: src/devops_cli/roadmap/stage/stage_plan_record.py:133, src/devops_cli/roadmap/stage/stage_plan_record.py:139, src/devops_cli/roadmap/stage/stage_plan_record.py:141]
    • Chosen: A RefusedRecord for each element. It keeps the input key and the schema failure that RefusedRecord.of writes today.
    • Rejected: A bare RefusedReply for each element. It drops the input key and the schema failure, so a schema failure leaves no trace of why.
  • How does the writer keep the lock past its timeout?: Create the valkey-py Lock with timeout=60 and thread_local=False. A daemon thread calls extend(60, replace_ttl=True) every 20 seconds and stops when the writer releases the lock, and the writer checks owned() just before the PATCH. The lock page (fetched 2026-11-25) gives the constructor Lock(valkey, name, timeout=None, sleep=0.1, blocking=True, blocking_timeout=None, thread_local=True), extend(additional_time, replace_ttl=False), owned(), reacquire() ('Resets a TTL of an already acquired lock back to a timeout value'), locked() and release(), and no automatic renewal. (best practice) [sources: https://valkey-py.readthedocs.io/en/stable/lock.html, tests/support/valkey_scenarios.py:133, tests/support/valkey_scenarios.py:141, tests/support/valkey_scenarios.py:143, tests/support/valkey_scenarios.py:175]
    • Chosen: A watchdog thread with thread_local=False. The docs give extend() and owned() but no renew thread; 20 seconds leaves two renewals before the 60-second timeout, and thread_local=False lets the watchdog see the token.
    • Rejected: thread_local=True with a watchdog. A token scoped to the acquiring thread cannot be extended from the watchdog.
    • Rejected: A Kubernetes Lease. It needs an API write for each renew and an API token in the pod.
    • Rejected: No renewal. A slow planner or a slow PATCH would lose the lock.
  • What does the writer do when Valkey does not answer?: Propagate the error and stop the round. ADR 0021 records the result when valkey-roadmap does not answer: no round starts, a pod waits 60 seconds, then exits with 75, and the engine tries it again. The record store must not swallow the error, and it must not fall back to a file. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:89]
    • Chosen: Propagate the error and fail closed. ADR 0021 records the 60-second wait and exit 75 for valkey-roadmap; the record is coordination state, not a cache.
    • Rejected: Continue without the record. The stage job would write a job record with no lock and plan again, against ADR 0021.
    • Rejected: Fall back to the file. The file lives in an emptyDir and goes with the pod.
  • How does the writer measure the instance memory?: Read used_memory and maxmemory from INFO memory through ValkeyClient.info('memory'). Refuse a value whose encoded length would take used_memory past 70 % of maxmemory, and skip the guard when maxmemory is 0. The 70 % line stays 10 points below the project's ValkeyMemoryNearBound alert at 80 %, which also excludes a maxmemory of 0. (best practice) [sources: src/devops_cli/valkey/client.py:235, k8s/monitoring/prometheus-values.yaml:704, openspec/specs/llm-valkey/spec.md:52]
    • Chosen: INFO memory with a 70 % guard. It is a read command that a managed instance allows, and 70 % leaves headroom below the 80 % alert and the noeviction bound.
    • Rejected: CONFIG GET maxmemory. A managed instance may refuse CONFIG.
    • Rejected: No guard. A large record would fill the instance and make noeviction refuse the keys that the service shares.
  • In which order does the writer admit its requests and take the lock?: Admit the GET and the PATCH in the request window first (RequestBudget.admit), and take the record lock second. ADR 0021 says a pod checks the window before it takes a slot or a lock. The writer holds the lock from the GET to the PATCH, so a full window must not hold it. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:93, src/devops_cli/server/service.py:222, src/devops_cli/roadmap/stores/github_store.py:1034]
    • Chosen: Admit first, lock second. A full request window can wait for minutes, and a lock held in that wait would expire or block other writers.
    • Rejected: Lock first, admit second. The lock would be held for the whole wait.
  • Does the change import the file records that exist now, and does it keep a file path?: No. A stage Job's home is an emptyDir that ends with the pod, so its plan file is gone, and a plan that passed the gates is on its staged branch. The Service leaves its old files unread rather than importing them. Remove the file reads and writes and the path functions plan_record_path and refused_record_path. (best practice) [sources: src/devops_cli/roadmap/stage/stage_plan_record.py:224, src/devops_cli/roadmap/stage/stage_plan_record.py:233, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:103, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:109]
    • Chosen: No import. No stage Job's file record survives a pod, so there is nothing to import.
    • Rejected: Import from a mounted directory. No such directory exists, and the code adds a path that no one keeps.
  • Which items must be delivered before this one?: feat(service): share the GitHub budget and holds in Valkey #4563 only. fix(roadmap): repair a job record mark that a parallel write lost #4555, test(valkey): add a contract suite for the Valkey fake #4557 and feat(roadmap): run each stage item in its own Job #4559 are already delivered at this commit: the read-back repair and its counter are in the store, the Valkey fake's contract suite has the Lock scenarios and fakeredis[lua,valkey], and the stage Job template and its admission rules are in the cluster docs and policy. The Valkey-backed request window of feat(service): share the GitHub budget and holds in Valkey #4563 is not: the budget is still the Service's in-process class, and the contract suite does not cover limits yet. (best practice) [sources: src/devops_cli/roadmap/stores/github_store.py:1511, tests/support/valkey_scenarios.py:133, pyproject.toml:131, docs/CLUSTER.md:100, k8s/devops/roadmap-service/admissionpolicy.yaml:61, docs/TESTING.md:287, src/devops_cli/server/service.py:222, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:113]
  • Where does the job record live?: D5 (owner decision 2026-11-13) keeps the job record as the hidden block of the issue body. ADR 0016 makes the block &lt;!-- devops-roadmap-record {...} --> at the end of the body, and ADR 0021 keeps the GitHub job record the source of truth. One writer for each item uses the updated_at check and the outside-text compare (fix(roadmap): repair a job record mark that a parallel write lost #4555), and the Valkey lock makes the window smaller. Valkey holds copies, locks and counters, never the only copy of a decision. Move the record to an App comment only if the lost-edit counter is above 0 after Phase 3. The live proof after the merge and release is an acceptance criterion named Pending a person after the merge. (best practice) [sources: docs/adr/0016-labels-hold-the-roadmap-items-fields.md:19, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:78, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:126, docs/ROADMAP_WORKFLOW.md:105]
    • Chosen: Hidden block in the issue body. The owner decision D5 keeps the record there, with one writer for each item and the fix(roadmap): repair a job record mark that a parallel write lost #4555 checks.
    • Rejected: App comment now. The owner decision moves the record to an App comment only if the lost-edit counter is above 0 after Phase 3.
    • Rejected: Valkey as the only copy. Valkey holds copies, locks and counters, never the only copy of a decision.
  • Does the read-back repair counter already exist?: Yes. ROADMAP_RECORD_REPAIRS_TOTAL (devops_cli_roadmap_record_repairs_total) is emitted by github_store with method and mark on each repair, from fix(roadmap): repair a job record mark that a parallel write lost #4555. This change adds no counter and no criterion for it; the measurement reads the existing counter. [sources: src/devops_cli/roadmap/stores/github_store.py:1511, src/devops_cli/telemetry/instruments.py:314, openspec/specs/roadmap-record-repair/spec.md:23]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4563, #4555

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. Saves tokens on reruns and fixes cross-pod lock ordering, but is not a critical defect.
    • Value: Medium. Reduces wasted planner calls and prevents lost marks across pods.
    • Effort: Medium. Requires Valkey keys, a distributed lock with renew thread, and removal of file I/O.
    • Related: feat(roadmap): keep the gated stage plan as a file #4064, which asks for a different change. Both deal with stage plan records, but #4064 keeps the plan as a file while this moves records to Valkey for cross-pod sharing.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 1db29f7 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: src/devops_cli/roadmap/stores/github_store.py, src/devops_cli/server/service.py.

  6. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 4330ee4 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: src/devops_cli/roadmap/stores/github_store.py, tests/support/fakes/valkey.py, pyproject.toml, src/devops_cli/server/service.py.

  7. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 79eb893 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

  8. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: valkey-py is already the project's pinned Valkey client and its Lock gives the shared, cross-process/cross-pod mutual exclusion the issue needs, with timeout, extend(additional_time, replace_ttl), owned() and reacquire() for renewal and lost-lock checks, plus the key/value and TTL commands that hold the plan records and the 20-element refused lists. What remains is thin application glue the issue already plans (a ~30-line watchdog, the 70 % maxmemory guard from INFO memory, and admitting the request window before the lock), not a gap that needs another tool.

    The repository already uses this tool.

    Tool: valkey (https://pypi.org/project/valkey)

    • License: MIT License
    • Last activity: 2026-10-12
    • Maintained: yes

    Covers:

    • A distributed Lock shared across processes and machines, with timeout, blocking and blocking_timeout
    • extend(additional_time, replace_ttl=True), owned() and reacquire() to renew a held lock and to detect a lost one
    • thread_local constructor flag, so a watchdog thread other than the acquiring one can see and extend the token
    • Key/value writes with TTL and list commands (LPUSH/LTRIM/EXPIRE) for the plan record and the refused list
    • INFO memory read (used_memory, maxmemory) through the client, which the 70 % guard needs

    Lacks:

    • No automatic renewal thread; the watchdog of about 30 lines that calls extend() every 20 s is still to be written
    • No instance memory guard; the writer must compare encoded length against 70 % of maxmemory itself
    • No request-window admission ordering; the writer must admit its GET and PATCH before taking the lock
    • A lock is no fence for the job record (ADR 0021), so the updated_at check and read-back repair must stay
    • No record schema or compression; the zstd + base64 encoding of the record JSON is application code

    Tools considered:

    Searches run:

    • python-redis-lock automatic lock renewal thread redis, results: 5
    • valkey-py Lock auto extend renewal thread distributed lock, results: 5
    • "valkey-py" lock documentation extend owned reacquire, results: 5
    • python-redis-lock pypi RedisLock thread extend expires, results: 5
    • python-redis-lock documentation RedisLock extend thread_local automatic extension, results: 5
    • "python-redis-lock" RedisLock, results: 5

    Sources:

    Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.

  9. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/roadmapsource/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions