Skip to content

Commit 7b4fdc6

Browse files
authored
chore(context7): drop the stale planning/ exclusion (#68)
* chore: migrate off the planning/ convention Replaces the two-axis planning/ + architecture/ convention with PR-body-as-spec, CONTEXT.md for vocabulary, and docs/adr/ for rejected alternatives, per modern-python/.github#67. - planning/ deleted in full (22 files). changes/ is git history's job; the three release notes are byte-identical to the published Release bodies (spot-checked 0.4.1 and 0.4.0 with `gh release view` — the only difference is a trailing newline GitHub adds), so the Releases are the record. deferred.md was empty. - planning/decisions/ held two records, now docs/adr/0001 (the fake broker keeps immediate delivery; no InMemoryTimerStore) and docs/adr/0002 (keep the publisher/subscriber construction factories). Frontmatter stripped; each opens with **Decision:** and closes with **Revisit trigger:**. Two more rejected alternatives were rescued from change files: 0003, dropping the per-call middlewares= kwarg that FastStream 0.7 removed upstream rather than routing it to broker scope or re-implementing it locally; and 0004, backporting @OverRide via typing_extensions unconditionally rather than gating on sys.version_info. - architecture/ held seven pages. Nearly every enforceable claim they made was already covered by a named test — the activation model (test_publish_api), the lease/at-least-once guarantee (test_at_least_once), the self-heal paths (test_isolation), the immediate-delivery fake (test_fake), the legacy envelope read fallback (test_envelope), and every TimerStore method (test_unit). Two claims were not, and become INVARIANT tests: - tests/test_store_seam.py::test_the_redis_timer_protocol_is_issued_only_from_the_store — timer-store.md's central claim that no caller touches the sorted set, hash or Lua directly. An AST scan for protocol-command call sites; `ping` is excluded because it is connection health, not the protocol. - tests/test_tuning_defaults.py::test_every_declaration_of_a_subscriber_tuning_knob_carries_the_published_default — delivery.md's Tuning table. The four poll-loop defaults are repeated in four signatures (TimerSub, create_subscriber, TimersRegistrator.subscriber, TimersRoute) and published in two docs tables, and nothing kept them in sync. Both were verified by breaking them: making has_pending ZSCORE the timeline directly fails the first (the exact violation its docstring names); raising lease_ttl to 60 in the registrator only fails the second. Both stay green under an allowed change — a new protocol command issued from inside store.py, and a further ping() call outside it, for the first; a new non-tuning kwarg added to one site only, for the second. Every source file was restored byte-identically (md5-checked) and the suite is green. The rest of the pages was prose about mechanism, deleted rather than relocated; nothing was invented to justify the directory. - CONTEXT.md is seeded from architecture/glossary.md and cut against real usage. Of the glossary's eleven _Avoid_ lines, ten rejected synonyms that appear nowhere in *.py/*.md outside the deleted trees: job/alarm, repository/backend, fire-time, enqueue, ready/ripe, acquire/reserve/reservation, finish, abort and revoke are all zero-hit, and the hits for task, deadline, TTL, expired, lock, delete, complete and stream are unrelated senses (asyncio tasks, the *lease* deadline, redis_client.delete, FastStream's own Channel/List/Stream subscriber types). TimerStore and Cancel lost their listings entirely — they mean what they say. The one surviving rejection is queue, which had ten real stragglers, now fixed to the winning spelling: README.md, docs/introduction/how-it-works.md, docs/usage/{basic,router,subscriber}.md and a schemas.py comment said "when the queue has work", "previously-idle queue", "wipe a topic's queue" and "queue resets". Seven of those are user-visible documentation prose; none is a code identifier, error message or other user-visible string. `channel` keeps a documented carve-out rather than a rejection: it survives only where FastStream owns the spelling, in the raw_message field and the log-context key. - AGENTS.md gains Workflow and Where-a-fact-goes, loses the planning lanes, and sheds the `just test` and `just lint` descriptions the justfile already states. - No docs/agents/domain.md. origin/main has a docs/ tree, but it is the mkdocs site — there was no docs/agents/ and AGENTS.md has no Agent skills section to link one from, so authoring it alone would be a half-rollout of a separate convention. - justfile and lint-ci drop index/check-planning; the offline lychee gate is a new links job in _checks.yml (modern-python/.github#66). It reports 0 errors over every .md, down from 2 — both were relative links to a plan.md that never existed, inside planning/changes/, so deleting the directory is what fixed them. - mkdocs.yml excludes /adr/ from the published site, matching modern-di. Without it the new pages are files-not-in-nav, and `just docs-build` runs mkdocs --strict, so the docs job would have gone red. Beyond the recipe, and the reason this is chore: and not docs: release.yml sourced the Release body from planning/releases/<tag>.md and hard-required one for every stable tag, so deleting planning/ would have failed every future stable release. It now uses GitHub's generated notes, copied verbatim from modern-di's post-migration workflow, which dropped the same gate in 1ea74ee (modern-python/modern-di#449). This retires the mandatory-curated-notes policy; that is the precedent's call, not a new one. * chore(context7): drop the stale planning/ exclusion The sibling commit on this branch deletes planning/, so the exclusion now names a directory that does not exist. Dropping the key rather than leaving an empty list: Context7's schema (https://context7.com/schema/context7.json) declares no required properties and gives excludeFolders a default of [], so an absent key and an empty list are equivalent. Absent matches the repos that never carried the line.
1 parent 43aeb2d commit 7b4fdc6

48 files changed

Lines changed: 415 additions & 2437 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/_checks.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,17 @@ jobs:
6060
PYTHONDONTWRITEBYTECODE: 1
6161
PYTHONUNBUFFERED: 1
6262
REDIS_URL: redis://127.0.0.1:6379/0
63+
64+
links:
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/checkout@v6
68+
# --offline blocks network requests and excludes every external URL, so this gate
69+
# is deterministic: it fails only on a relative link or file path a diff broke.
70+
- name: Check local links
71+
uses: lycheeverse/lychee-action@v2
72+
with:
73+
args: >-
74+
--offline
75+
--no-progress
76+
'**/*.md'

‎.github/workflows/release.yml‎

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,22 @@ jobs:
2525
- uses: extractions/setup-just@v4
2626
- uses: astral-sh/setup-uv@v7
2727

28-
# Curated release notes are MANDATORY for a stable tag. This runs BEFORE
29-
# `just publish` (which is irreversible) so a missing notes file aborts
30-
# the release before anything reaches PyPI — rather than silently shipping
31-
# with GitHub's auto-generated notes. Pre-release tags (a letter in the
32-
# name, e.g. 2.0.0rc1) are exempt and keep the auto-generated fallback.
33-
- name: Require curated release notes (stable tags)
34-
run: |
35-
set -euo pipefail
36-
if [[ "$GITHUB_REF_NAME" =~ [a-z] ]]; then
37-
echo "Pre-release ${GITHUB_REF_NAME}: curated notes not required."
38-
exit 0
39-
fi
40-
notes="planning/releases/${GITHUB_REF_NAME}.md"
41-
if [ ! -f "$notes" ]; then
42-
echo "::error::Stable tag ${GITHUB_REF_NAME} has no curated release notes at ${notes}. Write the notes, commit to main, and re-tag." >&2
43-
exit 1
44-
fi
45-
echo "Found curated release notes: ${notes}"
46-
4728
# PyPI is irreversible, so it runs FIRST: if it fails the job stops and no
4829
# GitHub Release is created advertising a version that never reached PyPI.
4930
# `just publish` derives the version from $GITHUB_REF_NAME (the tag name).
5031
# Auth via PyPI Trusted Publishing (OIDC); no PYPI_TOKEN. Needs a Trusted
5132
# Publisher on the faststream-redis-timers PyPI project (env: pypi, workflow: release.yml).
5233
- run: just publish
5334

54-
# Description source: planning/releases/<tag>.md if present (verbatim, no
55-
# auto-changelog appended); otherwise GitHub's generated notes. A tag with
56-
# a letter (2.0.0rc1) is a pre-release -> flagged so GitHub won't mark it
57-
# "Latest".
35+
# The Release body is GitHub's generated notes, rendered from the squashed
36+
# PR titles since the previous tag — so a conventional-commit title is what
37+
# a reader gets. A release wanting prose is edited after the fact with
38+
# `gh release edit <tag> --notes-file`. A tag with a letter (2.0.0rc1) is a
39+
# pre-release -> flagged so GitHub won't mark it "Latest".
5840
- name: Resolve release metadata
5941
id: meta
6042
run: |
6143
set -euo pipefail
62-
notes="planning/releases/${GITHUB_REF_NAME}.md"
63-
if [ -f "$notes" ]; then
64-
echo "body_path=$notes" >> "$GITHUB_OUTPUT"
65-
echo "generate_notes=false" >> "$GITHUB_OUTPUT"
66-
else
67-
echo "generate_notes=true" >> "$GITHUB_OUTPUT"
68-
fi
6944
if [[ "$GITHUB_REF_NAME" =~ [a-z] ]]; then
7045
echo "prerelease=true" >> "$GITHUB_OUTPUT"
7146
else
@@ -75,7 +50,6 @@ jobs:
7550
- name: Publish GitHub Release
7651
uses: softprops/action-gh-release@v3
7752
with:
78-
body_path: ${{ steps.meta.outputs.body_path }}
79-
generate_release_notes: ${{ steps.meta.outputs.generate_notes }}
53+
generate_release_notes: true
8054
prerelease: ${{ steps.meta.outputs.prerelease }}
8155
draft: false

‎AGENTS.md‎

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,61 @@
11
# faststream-redis-timers
22

33
FastStream broker integration for Redis-backed distributed timer scheduling.
4+
[`CONTEXT.md`](CONTEXT.md) opens with what it does and owns the vocabulary — read it before naming
5+
a concept in code, a test name, or an issue title.
46

57
## Commands
68

7-
`just` (task runner) + `uv` (package manager); the [`justfile`](justfile) is the
8-
source of truth for recipes — run `just --list` or read it. The non-obvious bits:
9+
`just` (task runner) + `uv` (package manager); the [`justfile`](justfile) is the source of truth
10+
for recipes — run `just --list` or read it. The things it does not say:
911

10-
- `just test [args]` — full suite in docker compose (spins up Redis). Args
11-
forward to pytest. `tests/test_unit.py` + `tests/test_fake.py` need no Redis;
12-
the rest (the integration suites) do.
13-
- `just lint` / `just lint-ci` — autofix vs non-mutating; `lint-ci` also runs the
14-
planning-change validator (`planning/index.py --check`).
15-
- Verifying a Python-version / interpreter-compat change: run the **full** suite
16-
on the target interpreter (the CI matrix, or `just test` in docker), not just
17-
the no-Redis subset. An integration-only failure — e.g. a broker-shutdown hang
18-
that only bites under a specific interpreter's async timing — won't surface in
19-
`test_unit.py` / `test_fake.py` alone.
12+
- A `ty` suppression is written `# ty: ignore`, never `# type: ignore`.
13+
- `tests/test_unit.py`, `tests/test_fake.py`, `tests/test_store_seam.py` and
14+
`tests/test_tuning_defaults.py` need no Redis; the rest (the integration suites) do.
15+
- Verifying a Python-version / interpreter-compat change: run the **full** suite on the target
16+
interpreter (the CI matrix, or `just test` in docker), not just the no-Redis subset. An
17+
integration-only failure — e.g. a broker-shutdown hang that only bites under a specific
18+
interpreter's async timing — won't surface in the no-Redis subset alone.
2019

2120
## Workflow
2221

23-
Planning uses a portable convention — `architecture/` (repo root) is the living
24-
**truth home** and promotion target; `planning/changes/` holds the flat
25-
change files. Start at the
26-
[Quick path](planning/README.md#quick-path-start-here) in
27-
[`planning/README.md`](planning/README.md) (the authoritative spec) to pick a
28-
lane — **Full** (design template), **Lightweight** (change template),
29-
or **Tiny** (just a commit) — and ship. `just check-planning` validates
30-
change files; `just index` prints the change + decision listing;
31-
`planning/_templates/` are copy-and-fill starting points.
32-
33-
## Architecture
34-
35-
[`architecture/`](architecture/) is the living per-capability truth home.
36-
**When a change alters a capability's behavior, update the matching
37-
`architecture/<capability>.md` in the same PR** — that promotion keeps
38-
`architecture/` true. Capability pages are authored over time; see
39-
[`architecture/README.md`](architecture/README.md).
22+
**The spec for a change is its PR body**, not a committed file: why, design, non-goals,
23+
verification, reviewed with the diff. There is no change file and no lane to choose. A trivial PR
24+
(typo, dep bump, formatter, CI tweak) ships a conventional-commit title with no body ceremony.
25+
26+
Two things outlive the PR, and there are exactly two places to put them: an alternative **rejected**
27+
with reasoning becomes an ADR in [`docs/adr/`](docs/adr/) (`NNNN-slug.md`, sequential, with a
28+
revisit trigger), and real work **not scheduled** becomes a GitHub issue. There is no third state,
29+
and no separate truth-home directory — a behaviour change is reviewed with the diff, not promoted
30+
to a page.
31+
32+
### Where a fact goes
33+
34+
Four homes, one owner each:
35+
36+
| Home | Holds |
37+
|---|---|
38+
| `faststream_redis_timers/` | anything readable from the module — the default |
39+
| a named test | an **invariant**: must stay true, and a change could silently break it |
40+
| `docs/adr/` | a rejected alternative, with the reasoning that would otherwise be re-litigated |
41+
| `docs/` | anything a user needs; `README.md` is the short version of the same |
42+
43+
Before writing a line anywhere:
44+
45+
> Can an agent get this by reading `faststream_redis_timers/`? → **don't write it.**
46+
> Would a wrong change here fail a test? → it belongs **in the test**, not in prose.
47+
> Does a user need it? → **`docs/`**.
48+
> Otherwise it does not get written.
49+
50+
**Prose about mechanism has no home. There is no file to add a paragraph to.** This file included:
51+
it is always loaded, so a line that restates a docstring, a justfile comment, or `pyproject.toml`
52+
costs every turn and rots in two places at once. This package mirrors FastStream's own Redis broker
53+
layout closely enough to tempt a page re-deriving that structure; that is the failure mode to watch
54+
for here.
55+
56+
An invariant is a test whose name is the claim, with a docstring opening `INVARIANT:` and a second
57+
paragraph naming **what breaks it** — design rationale, not a report of what this one test catches.
58+
Nothing enforces that docstring shape; it is read at review time. A relative link to an ADR *is*
59+
checked — CI runs lychee `--offline` over every `.md` — but a path named in a docstring or a
60+
comment is not. Both ADRs and `INVARIANT:` docstrings ratchet: nothing prunes a record once its
61+
call is settled. Keeping them lean is a standing habit.

‎CONTEXT.md‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# faststream-redis-timers
2+
3+
A [FastStream](https://faststream.airt.ai) broker integration for Redis-backed distributed timer
4+
scheduling: publish a message now, have it delivered to a subscriber at a future instant, with
5+
at-least-once delivery across a fleet of workers sharing one Redis.
6+
7+
## Language
8+
9+
A term is listed only when there is a synonym to reject, or a meaning subtle enough that code and
10+
docs must agree on it. General programming vocabulary does not belong here, however heavily this
11+
package uses it. Class and method names that mean what they say (`TimerStore`, `cancel_timer`) are
12+
not listed — read the module.
13+
14+
FastStream owns the framing vocabulary this package plugs into — broker, subscriber, publisher,
15+
router, message, handler, `ack`/`nack`/`reject`. Nothing here redefines one of those.
16+
17+
**Timer**:
18+
A scheduled future delivery: a message bound to a Topic that becomes deliverable at its Activation
19+
time, identified by a `timer_id`. The Timer is the *record*, not the message it carries — a Timer
20+
has a lifecycle (Scheduled → Due → Claimed → Committed) that its payload does not.
21+
22+
**Topic**:
23+
The named channel a Timer is Scheduled on and that a subscriber consumes from. Two Redis keys are
24+
derived per Topic; a Timer only ever exists on one.
25+
_Avoid_: queue — a Topic is not a work queue, and the difference matters: Timers on a Topic are
26+
ordered by Activation time, not arrival, and a Claimed Timer stays on the Topic rather than leaving
27+
it. `channel` survives only where FastStream owns the spelling: the `raw_message` field and the
28+
log-context key. In our own prose it is Topic.
29+
30+
**Activation time**:
31+
The single absolute UTC instant at which a Timer becomes Due. Exactly one of `activate_in` (a
32+
`timedelta` from now) or `activate_at` (a timezone-aware `datetime`) sets it; passing both, or a
33+
naive `datetime`, is a `ValueError`. This one number is also the Lease marker: Claiming a Timer
34+
advances its Activation time rather than moving the Timer anywhere, so "Activation time" reads
35+
differently before and after a Claim.
36+
37+
**Schedule**:
38+
To register a new Timer to become Due at its Activation time. The method is `publish()` — FastStream
39+
names every producer entry point that way and this package keeps the parity — but the domain verb is
40+
Schedule, and prose should use it. There is no separate publish concept.
41+
42+
**Due**:
43+
Describes a Timer whose Activation time has passed, and which is therefore eligible to be Claimed.
44+
Due is derived, never stored: it is a comparison against the current time, which is why the same
45+
Timer is Due to a poll one moment and not the next.
46+
47+
**Pending**:
48+
Describes a Timer that has been Scheduled and neither Committed nor cancelled — *including* one
49+
currently Claimed, whose Activation time sits in the future under its Lease. `has_pending` is
50+
therefore true for a Timer whose handler is already running; `get_pending_timers(before=now)`
51+
excludes those.
52+
53+
**Claim**:
54+
To take a Due Timer for processing by advancing its Activation time by the Lease, in one atomic
55+
step, so no other worker sees it as Due. A Claim is not a lock: there is no lock key, no owner
56+
recorded, and nothing to release. A contested Claim returns nothing and is simply skipped.
57+
58+
**Lease**:
59+
The time window a Claim buys, `lease_ttl` seconds wide. It expires on its own; a worker that dies
60+
mid-handler releases nothing, the Timer simply becomes Due again. A handler that outruns its Lease
61+
can be redelivered while still running — that is what makes delivery at-least-once rather than
62+
exactly-once.
63+
64+
**Commit**:
65+
To remove a Timer permanently once a handler has accounted for it, via `ack` or `reject`. `nack` is
66+
not a Commit: it does nothing, and the Lease expiring is what causes redelivery. Cancellation
67+
performs the identical removal, which is why the store exposes one `remove` and not two.

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ Per-subscriber knobs (passed to `@broker.subscriber("topic", ...)`):
139139
- `lease_ttl` (default `30` seconds) — how long a worker holds the lease while
140140
processing. Handlers must complete within this window or another worker may
141141
re-deliver the timer (duplicate). Increase if your handlers are slow.
142-
- `polling_interval` (default `0.05` s) — base poll interval used when the queue
143-
has work or just transitioned from idle. Doubles on each consecutive empty
142+
- `polling_interval` (default `0.05` s) — base poll interval used when the topic
143+
has due timers or just transitioned from idle. Doubles on each consecutive empty
144144
cycle, capped at `max_polling_interval`, with ±50% jitter applied each sleep.
145145
- `max_polling_interval` (default `5.0` s) — ceiling for the adaptive idle
146-
backoff. Lower it for tighter delivery latency on idle queues; raise it to
146+
backoff. Lower it for tighter delivery latency on idle topics; raise it to
147147
reduce Redis load on workloads with long idle stretches.
148148
- `max_concurrent` (default `5`) — maximum number of handlers running in
149149
parallel per subscriber. Also caps the fetch batch size per poll cycle.

‎architecture/README.md‎

Lines changed: 0 additions & 38 deletions
This file was deleted.

‎architecture/delivery.md‎

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)