Commit 10b05c8
authored
refactor(authority): encode unsigned non-zero runtime TTLs (#615)
## Why
The schema owns human-readable non-zero duration parsing, while
downstream Authority contracts consume exact positive whole-second
integers. This internal refactor makes both validated runtime TTL states
unsigned and non-zero without changing configuration or the existing
signed protobuf request contract.
## What changed
- Store private validated `max_ttl_seconds` and `bundle_ttl_seconds` as
`std::num::NonZeroU32`.
- Convert schema-validated `NonZeroDuration` values once through
`AuthorityConfigBuilder`: require whole seconds, retain the `i32::MAX`
maximum-token-TTL bound, and checked-narrow to standard non-zero
integers.
- Keep Authority service state, issuance clamping, and effective TTLs
unsigned and non-zero; call `.get()` only at Chrono, Cedar,
policy-bundle, library, or wire integer boundaries.
- Keep protobuf `requested_ttl_seconds: i32` unchanged. The issuance
adapter normalizes it once: `<= 0` selects the configured maximum; a
positive request becomes `NonZeroU32` and clamps against that unsigned
maximum.
- Cover negative, zero, positive, and over-maximum requests plus exact
claim and protobuf expiry behavior.
## Contract
No user, TOML, environment, or wire change is introduced. Compact
duration syntax, `"1h"` / `"30s"` defaults, canonical
`FIRMA_AUTHORITY_MAX_TTL` / `FIRMA_AUTHORITY_BUNDLE_TTL` precedence,
whole-second and range errors, and effective values remain unchanged.
Runtime uses `NonZeroU32` rather than a duration type because its
consumers are exact positive whole-second integer boundaries; schema
parsing remains owned by `NonZeroDuration`. The remaining signed
protobuf request and non-positive sentinel are intentionally deferred to
a separate follow-up.
## Atomic revisions
1.
[`32539c5c`](32539c5)
— accepted plan and plan-review dispositions.
2.
[`20f0e090`](20f0e09)
— encode maximum-token-TTL runtime/config/service/issuance state as
`NonZeroU32`.
3.
[`ae6c1c31`](ae6c1c3)
— encode bundle-TTL runtime/config/consumer state as `NonZeroU32`.
4.
[`ad1c34eb`](ad1c34e)
— record the independent implementation review.
5.
[`8a6e26aa`](8a6e26a)
— record the atomic-commit re-review.
6.
[`d01d9c11`](d01d9c1)
— mechanically remove the plan artifact.
## Plan and independent review
- Accepted plan and plan-review dispositions: [`32539c5c:
authority-non-zero-runtime-ttl-plan.md`](https://github.com/Firma-AI/openfirma/blob/32539c5cedb0fe31f08a6d8ca1f8db468df2d15f/docs/architecture/authority-non-zero-runtime-ttl-plan.md).
- Independent implementation review:
[`ad1c34eb`](https://github.com/Firma-AI/openfirma/blob/ad1c34eb09bfbb2f2e3cd59832e1510427e3827e/docs/architecture/authority-non-zero-runtime-ttl-plan.md#post-implementation-adversarial-review).
- Atomic-commit re-review:
[`8a6e26aa`](https://github.com/Firma-AI/openfirma/blob/8a6e26aaa4078c3fc4db1f39d008cd1ff5e569a8/docs/architecture/authority-non-zero-runtime-ttl-plan.md).
- Immediate mechanical plan removal:
[`d01d9c11`](d01d9c1).
No plan Markdown remains at the tip or in the PR diff.1 parent 7fd412b commit 10b05c8
9 files changed
Lines changed: 145 additions & 75 deletions
File tree
- crates
- firma-authority
- src
- tests/integration
- firma-config-schema
- src
- tests
- firma/src/services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
40 | | - | |
| 40 | + | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | | - | |
44 | | - | |
| 44 | + | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
77 | | - | |
| 78 | + | |
78 | 79 | | |
79 | | - | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
| 90 | + | |
90 | 91 | | |
91 | | - | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| |||
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
182 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
183 | 193 | | |
184 | 194 | | |
185 | 195 | | |
186 | 196 | | |
187 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
188 | 203 | | |
189 | 204 | | |
190 | 205 | | |
| |||
216 | 231 | | |
217 | 232 | | |
218 | 233 | | |
219 | | - | |
220 | | - | |
| 234 | + | |
| 235 | + | |
221 | 236 | | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
231 | 243 | | |
232 | 244 | | |
233 | 245 | | |
| |||
247 | 259 | | |
248 | 260 | | |
249 | 261 | | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | 262 | | |
259 | 263 | | |
260 | 264 | | |
| |||
589 | 593 | | |
590 | 594 | | |
591 | 595 | | |
592 | | - | |
593 | | - | |
| 596 | + | |
| 597 | + | |
594 | 598 | | |
595 | 599 | | |
596 | 600 | | |
| |||
678 | 682 | | |
679 | 683 | | |
680 | 684 | | |
681 | | - | |
| 685 | + | |
682 | 686 | | |
683 | 687 | | |
684 | 688 | | |
| |||
696 | 700 | | |
697 | 701 | | |
698 | 702 | | |
699 | | - | |
| 703 | + | |
700 | 704 | | |
701 | | - | |
| 705 | + | |
702 | 706 | | |
703 | 707 | | |
704 | 708 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | | - | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | | - | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
114 | 120 | | |
115 | 121 | | |
116 | 122 | | |
| |||
141 | 147 | | |
142 | 148 | | |
143 | 149 | | |
144 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
145 | 153 | | |
146 | 154 | | |
147 | 155 | | |
148 | 156 | | |
149 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
150 | 188 | | |
151 | 189 | | |
152 | 190 | | |
| |||
183 | 221 | | |
184 | 222 | | |
185 | 223 | | |
186 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
187 | 227 | | |
188 | 228 | | |
189 | 229 | | |
| |||
202 | 242 | | |
203 | 243 | | |
204 | 244 | | |
205 | | - | |
| 245 | + | |
206 | 246 | | |
207 | 247 | | |
208 | 248 | | |
| |||
238 | 278 | | |
239 | 279 | | |
240 | 280 | | |
241 | | - | |
| 281 | + | |
242 | 282 | | |
243 | 283 | | |
244 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | | - | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | | - | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
597 | 598 | | |
598 | 599 | | |
599 | 600 | | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
607 | 607 | | |
608 | 608 | | |
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
613 | 617 | | |
614 | 618 | | |
615 | 619 | | |
| |||
624 | 628 | | |
625 | 629 | | |
626 | 630 | | |
627 | | - | |
| 631 | + | |
628 | 632 | | |
629 | 633 | | |
630 | 634 | | |
631 | 635 | | |
632 | | - | |
| 636 | + | |
633 | 637 | | |
634 | 638 | | |
635 | 639 | | |
636 | 640 | | |
637 | | - | |
| 641 | + | |
638 | 642 | | |
639 | 643 | | |
640 | 644 | | |
641 | 645 | | |
642 | | - | |
| 646 | + | |
643 | 647 | | |
644 | 648 | | |
645 | 649 | | |
| |||
0 commit comments