Skip to content

Commit db21a40

Browse files
committed
Change signature of on_close hook (queue by val)
1 parent e65dccb commit db21a40

27 files changed

Lines changed: 3467 additions & 5085 deletions

design/secondary/lang/c/ctk-proposal.md

Lines changed: 1442 additions & 0 deletions
Large diffs are not rendered by default.

design/secondary/lang/c3/3tk-deviations-001.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ The stack's was the sharper case, and the deletion rested on two grounds.
415415
**The first is `R15`: `push_slot`'s only caller was ever `pool.c3:451`,
416416
`put_all`'s refusal path**, and 002 dropped `put_all` — §5.1's row says so, and
417417
the queue's `push_front_slot` went with it for the same reason. The second, from
418-
`3tk-port-findings-003.md`, was that no application could reach an `InnerStack`
418+
`3tk-port-findings-004.md`, was that no application could reach an `InnerStack`
419419
at all. **3tk-only, and it was two lines plus one test.**
420420

421421
**CLARIFIED 2026-08-26.** The owner's ruling that the stack is available to a

design/secondary/lang/c3/3tk-log.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,57 @@ Current state is in [3tk-status.md](3tk-status.md).
77

88
---
99

10+
## 2026-08-30 — 3TK-56: the close hook takes the queue by value, in code
11+
12+
**Built [3tk-on-close-handoff-001.md](3tk-on-close-handoff-001.md), the
13+
2026-08-28 ruling.** `P6` closes: `on_close` receives `InnerQueue`, not
14+
`InnerQueue*`, and the pool holds nothing back.
15+
16+
**`InnerQueue.take()`**`3tk/src/queue.c3` — hands over everything the queue
17+
holds and empties the source, O(1), cannot fail. Both call sites in
18+
`pool.c3` — the straggler path (`:494`) and the main close (`:564`) — became
19+
`self._hooks.on_close(stragglers.take())` and
20+
`self._hooks.on_close(remaining.take())`.
21+
22+
**The six implementers followed**: `negative/common.c3`,
23+
`negative/release_with_straggler_put.c3`, `negative/release_during_on_put.c3`,
24+
`negative/release_during_on_close.c3`, `test/t_concurrency.c3` (two hooks),
25+
`test/t_pool.c3`. Only the signature line changed in every one — a by-value
26+
struct parameter is an lvalue, so `&self` methods (`pop_front`, `is_empty`,
27+
`len`) bind to it exactly as they did through the pointer, and no body needed
28+
touching. The three `release_during_*` tier 1 negatives still abort in every
29+
build mode, unweakened.
30+
31+
**One positive test, no negative.** `t_queue.c3:take_empties_the_source`
32+
proves the source is empty after `take()`. No negative is possible: a hook
33+
that keeps items dereferences nothing, so no build could ever notice a leak
34+
however the parameter is spelled — that is the ruling working as intended, not
35+
a gap in coverage.
36+
37+
**Wording, not just code.** `PoolHooks.on_close`'s doc block in `pool.c3` now
38+
carries *the pool does not verify it and never will*, and the same sentence
39+
went to `ref/3tk-reference-004.md` — named directly by the charter, and edited
40+
in place rather than versioned. `ref/3tk-decisions-004.md` gained the `P6`
41+
entry under `pool.c3` and a `take()` entry under `queue.c3`; `-003` moved to
42+
`backup/`. `3tk-port-findings-004.md` gained §4a, the argument for dtk and otk
43+
to read: no shared-specification change, because Part 12.2 already says the
44+
hook is handed the items and not through what; ztk's `on_close` was read at
45+
`pool.zig:127-130` and is still by pointer, an open divergence and not a
46+
recommendation. `-003` moved to `backup/`. `3tk-open-defects.md`'s `P6` row and
47+
section are marked ruled and built.
48+
49+
**Verified**: `run-builds.sh` four builds green, 87 checks, 92 tests per build
50+
(the new `take()` test), 0 failures. `check-doc-loop.sh` 0 differing blocks,
51+
457 sentences, 456 found — the one miss is the pre-existing `inner.c3` module
52+
summary — 0 banned words. `run-sanitizers.sh` 3 passed, 0 failed, the hook path
53+
exercised on every run.
54+
55+
**`grep -roiwE 'items?'` moved 365 to 366 in `ref`**, from `take()`'s two new
56+
sentences in the decisions entry; `3tk/src` is unchanged at 125, because
57+
`take()`'s doc block never says *item*.
58+
59+
**3TK-50 is the only stage left** — the examples tree, independent of the fix.
60+
1061
## 2026-08-28 — the owner rules `P6`: the close hook takes the queue by value
1162

1263
**A ruling, not a stage. No code changed.** Recorded here because the ruling and

design/secondary/lang/c3/3tk-open-defects.md

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 3tk — open defects
22

3-
**The working list for fixing the port.** Ten items — **seven fixed, one open,
3+
**The working list for fixing the port.** Ten items — **eight fixed, zero open,
44
two closed**. One table, one section each: where it is, what is wrong, what the
55
fix is, how to know it worked, and what state it is in.
66

@@ -33,7 +33,7 @@ are the good ones. Re-print before trusting them again — every fix moves them.
3333

3434
| # | Where | What | Fix is | State |
3535
|---|---|---|---|---|
36-
| **P6** | `pool.c3:493`, `:563` | The pool can lose items and never know | **Ruled 2026-08-28: option 3.** `on_close` takes the queue **by value***I do not care what you did* — plus the wording | **ruled, built by 3TK-56.** [3tk-on-close-handoff-001.md](3tk-on-close-handoff-001.md) |
36+
| **P6** | `pool.c3:494`, `:564` | The pool can lose items and never know | **Ruled 2026-08-28: option 3.** `on_close` takes the queue **by value***I do not care what you did* — plus the wording | **ruled, built by 3TK-56.** [3tk-on-close-handoff-001.md](3tk-on-close-handoff-001.md) |
3737
| **Q5** | `mailbox.c3:124`, `pool.c3:253` | A release racing a call still in flight | Ruled 2026-08-28: stated, and checked | **fixed 2026-08-28, 3TK-53 + 3TK-54, closed by 3TK-55** |
3838

3939
**Six of the ten are done, on 2026-08-27, in one stage.** Every mechanical and
@@ -47,8 +47,9 @@ and they have been overtaken** — the live ones are in
4747
pool, both 2026-08-28; 3TK-55 closed this row against the built code on the same
4848
day, after re-running all three scripts.
4949

50-
**One remains open, and it is waiting on you.** `P6` needs one small ruling
51-
before code can be written. The ruling is stated in the section.
50+
**`P6` is the eighth, and it is done.** Ruled 2026-08-28, built 2026-08-30 by
51+
3TK-56 — [3tk-on-close-handoff-001.md](3tk-on-close-handoff-001.md) is its
52+
charter. Nothing remains open.
5253

5354
**`P7` no longer needs one.** Reading `std::thread` showed the fault it warned
5455
about cannot occur. The branch is dead, it stays, and a plain `//` comment at
@@ -70,10 +71,11 @@ Only the open and deferred items have an order. The fixed ones are done.
7071

7172
**Waiting on you.**
7273

73-
- `P6` — one ruling, three answers, written out in its section. INTR 1 ranked it
74-
High, and it is the last of the three it put there.
74+
- Nothing. `P6` was the last one, ruled 2026-08-28 and built 2026-08-30 by
75+
3TK-56.
7576

76-
**Nothing is waiting on a stage any more.** `Q5` was the last one, and it ran.
77+
**Nothing is waiting on a stage any more.** `Q5` and `P6` were the last two,
78+
and both ran.
7779

7880
**The dependency that is not obvious, and it is now discharged.**
7981

@@ -112,9 +114,9 @@ every number in an earlier version of this table, is now wrong.**
112114
**Three sites.**
113115

114116
```
115-
pool.c3:493 the close hook, called with what was left after a race
116-
pool.c3:563 the close hook, called with everything the pool held
117-
pool.c3:526-527 one item with an identity the pool does not recognize -- RULED 2026-08-27
117+
pool.c3:494 the close hook, called with what was left after a race
118+
pool.c3:564 the close hook, called with everything the pool held
119+
pool.c3:527-528 one item with an identity the pool does not recognize -- RULED 2026-08-27
118120
```
119121

120122
**Re-printed 2026-08-28**, after the lifetime fix moved every line below
@@ -205,19 +207,33 @@ Documentation, not code — so that the silence is not read as a promise.
205207
writing code. 3 is cheapest and defensible. **1 and 2 combine** — a check while
206208
developing, a number afterwards.
207209

208-
**State: RULED 2026-08-28 — option 3, and it is stronger than option 3 as
209-
written here.** `on_close` takes the queue **by value**, so the pool physically
210-
cannot observe what the hook did and the type says so; the comment and the
211-
reference say it in words. **Options 1 and 2 are closed for good, not deferred.**
212-
The ruling, the five defaults that go with it and the work list are in
213-
[3tk-on-close-handoff-001.md](3tk-on-close-handoff-001.md), which is **3TK-56's
210+
**State: RULED 2026-08-28, BUILT 2026-08-30 by 3TK-56 — option 3, and it is
211+
stronger than option 3 as written here.** `on_close` takes the queue **by
212+
value**, so the pool physically cannot observe what the hook did and the type
213+
says so; the comment and the reference say it in words. **Options 1 and 2 are
214+
closed for good, not deferred.** The ruling, the five defaults that go with it
215+
and the work list are in
216+
[3tk-on-close-handoff-001.md](3tk-on-close-handoff-001.md), which was **3TK-56's
214217
only input besides the status file.** The measurement behind it: a by-value
215218
struct parameter is an lvalue on c3c 0.8.3, so the hook's ergonomics are
216219
unchanged, and the caller's copy is untouched, so nothing is left to count.
220+
`InnerQueue.take()` (`../3tk/src/queue.c3`) is the O(1) move both call sites
221+
use.
217222

218-
**Superseded state: open, waiting on your decision. Nothing blocked it** — the
219-
dependency on `Q5` is discharged, and all three options are on the table. See
220-
[Order](#order).
223+
**Superseded state: open, waiting on your decision.** Closed by 3TK-56.
224+
225+
**What 3TK-56 moved outside `3tk/src`:**
226+
227+
- `ref/3tk-decisions-004.md` — the `P6` entry, under `pool.c3` and `queue.c3`.
228+
`-003` went to `backup/`.
229+
- `ref/3tk-reference-004.md` — the `on_close` signature and its doc block, and
230+
`InnerQueue.take()` added to the queue's operation list. Edited in place, not
231+
versioned: this stage's charter names the file directly.
232+
- `3tk-port-findings-004.md` — new §4a, the argument for dtk and otk. `-003`
233+
went to `backup/`.
234+
- `3tk/test/t_queue.c3` — one positive test, `take_empties_the_source`. No
235+
negative is possible: a hook that keeps items dereferences nothing, so no
236+
build can notice.
221237

222238

223239
## Refuted — claims that did not survive the code
@@ -310,27 +326,27 @@ row.
310326

311327
## After a fix
312328

313-
**All the numbers below were re-measured on 2026-08-28, by 3TK-55, after 3TK-53
314-
and 3TK-54.**
329+
**All the numbers below were re-measured on 2026-08-30, by 3TK-56, after `P6`
330+
was built.**
315331
The one missing descriptor sentence is the pre-existing `inner.c3` module
316-
summary and is not new. `ref` moved 360 to 365 on 2026-08-27 because the reference and the decisions
317-
each took on new sentences that say *item*, and it has not moved since. `3tk/src`
318-
went 124 to 125 with the lifetime fix's new prose.
332+
summary and is not new. `ref` moved 365 to 366 with `take()`'s two new
333+
sentences in the decisions entry. `3tk/src` is unchanged at 125 — `take()`'s
334+
doc block does not say *item*.
319335

320336
**Every mechanical item touches `3tk/src`, so the doc loop is owed.**
321337
`ref/3tk-doc-loop-003.md` is the procedure; `check-doc-loop.sh` says whether it
322338
is still owed.
323339

324-
**`ref/3tk-decisions-003.md` is the current one**, and `-002` is in `backup/`.
325-
`P6` will add an entry when it is ruled; `P7` closed without one.
340+
**`ref/3tk-decisions-004.md` is the current one**, and `-003` is in `backup/`.
341+
`P6`'s entry is in it, under `pool.c3` and `queue.c3`; `P7` closed without one.
326342

327-
**The numbers to re-measure**, all true on 2026-08-28 after 3TK-54:
343+
**The numbers to re-measure**, all true on 2026-08-30 after 3TK-56:
328344

329345
```
330-
./run-builds.sh # four builds green, 87 checks, 91 tests per build, 0 failures
331-
./check-doc-loop.sh # 0 differing blocks, 452 sentences, 451 found, 1 missing, 0 banned
346+
./run-builds.sh # four builds green, 87 checks, 92 tests per build, 0 failures
347+
./check-doc-loop.sh # 0 differing blocks, 457 sentences, 456 found, 1 missing, 0 banned
332348
./run-sanitizers.sh # 3 passed, 0 failed — thread on two builds, address on one
333-
grep -roiwE 'items?' 3tk/src ref # 125 and 365
349+
grep -roiwE 'items?' 3tk/src ref # 125 and 366
334350
```
335351

336352
**`run-sanitizers.sh` joined the list here** because the lifetime fix is a

0 commit comments

Comments
 (0)