@cloudhal/schedules 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +103 -2
- package/dist/src/automation.d.ts +82 -0
- package/dist/src/automation.js +199 -0
- package/dist/src/budget-meter.d.ts +58 -0
- package/dist/src/budget-meter.js +130 -0
- package/dist/src/budget.d.ts +41 -0
- package/dist/src/budget.js +76 -0
- package/dist/src/builtins.d.ts +132 -0
- package/dist/src/builtins.js +473 -0
- package/dist/src/engine.d.ts +16 -0
- package/dist/src/engine.js +30 -0
- package/dist/src/errors.d.ts +22 -0
- package/dist/src/errors.js +56 -0
- package/dist/src/feed-check.d.ts +56 -0
- package/dist/src/feed-check.js +365 -0
- package/dist/src/findings.d.ts +185 -0
- package/dist/src/findings.js +287 -0
- package/dist/src/ids.d.ts +24 -0
- package/dist/src/ids.js +96 -0
- package/dist/src/index.d.ts +24 -0
- package/dist/src/index.js +24 -0
- package/dist/src/instant.d.ts +19 -0
- package/dist/src/instant.js +50 -0
- package/dist/src/notify.d.ts +50 -0
- package/dist/src/notify.js +60 -0
- package/dist/src/recurrence.d.ts +155 -0
- package/dist/src/recurrence.js +939 -0
- package/dist/src/release-when.d.ts +23 -0
- package/dist/src/release-when.js +55 -0
- package/dist/src/release.d.ts +198 -0
- package/dist/src/release.js +552 -0
- package/dist/src/scheduler.d.ts +490 -0
- package/dist/src/scheduler.js +1343 -0
- package/dist/src/sql/finish.d.ts +32 -0
- package/dist/src/sql/finish.js +103 -0
- package/dist/src/sql/index.d.ts +6 -0
- package/dist/src/sql/index.js +15 -0
- package/dist/src/sql/rows.d.ts +125 -0
- package/dist/src/sql/rows.js +297 -0
- package/dist/src/sql/store.d.ts +467 -0
- package/dist/src/sql/store.js +2166 -0
- package/dist/src/taint.d.ts +65 -0
- package/dist/src/taint.js +138 -0
- package/dist/src/text.d.ts +6 -0
- package/dist/src/text.js +25 -0
- package/dist/src/time-entry.d.ts +6 -0
- package/dist/src/time-entry.js +6 -0
- package/dist/src/time.d.ts +61 -0
- package/dist/src/time.js +140 -0
- package/package.json +69 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,104 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cloudhal/schedules
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Scheduled publishing and automations for Cloudhal sites ([RFC-0008](../../docs/rfcs/0008-schedules.md), [ADR-0023](../../docs/adr/0023-schedules.md)): the time model, the RRULE subset, releases pinned to exact node versions, automation and run state, taint and budget accounting, and the scheduler's `runDue` with its D1/SQLite store.
|
|
4
|
+
|
|
5
|
+
Everything here is **Worker-safe**: no Node-only import at any entry. The only Temporal entry point is `temporal-polyfill/implementation` (never a native or global `Temporal`, never `Temporal.Now`; Biome refuses the other entries and a test scans the repository). `now` is always injected.
|
|
6
|
+
|
|
7
|
+
| Entry | What |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `@cloudhal/schedules` | Time model, recurrence, release model, automation/run state machines, taint, budgets, `TickMeter`, the `Scheduler` interface, `runDue`, `createScheduler`. No storage dependency beyond the `SqlDriver` type. |
|
|
10
|
+
| `@cloudhal/schedules/engine` | The Temporal-free part: the release model, run ids, instant helpers, `TickMeter`, `releaseFinishStatements`, the scheduler's types. `@cloudhal/core-ts` applies releases through it, so the site Worker never bundles the time-zone library. |
|
|
11
|
+
| `@cloudhal/schedules/time` | The time model alone; `@cloudhal/core-ts/time` re-exports it (one implementation). |
|
|
12
|
+
| `@cloudhal/schedules/recurrence` | The RRULE subset alone (parse, validate, expand, presets, sentences). |
|
|
13
|
+
| `@cloudhal/schedules/sql` | `SqlScheduleStore` over `SqlDriver` for migration `0017_schedules`. |
|
|
14
|
+
| `@cloudhal/schedules/testing` | `describeScheduleStoreConformance`, `describeSchedulerConformance`, `fakeReleaseExecutor`, `countingDriver`, `expectContract*` (vitest). |
|
|
15
|
+
|
|
16
|
+
## Time (§9)
|
|
17
|
+
|
|
18
|
+
- `resolveLocalTime("2026-11-02T09:00", "Europe/Istanbul")` → `{ at: "2026-11-02T06:00:00.000Z", offset: "+03:00" }`. A time inside a DST gap moves to the next valid time (`adjusted: "dst-gap"`); a repeated time resolves to its first instant (D2).
|
|
19
|
+
- `recomputeExecuteAt(when)` — never early: a stored wall-clock time is re-resolved with today's tzdata and the instant only ever moves later (`adjusted: "tzdata"`).
|
|
20
|
+
- `isTimeZone`, `toLocalDateTime`, `zoneOffset`, `latenessSeconds`, `canonicalInstant` (the stored form is `Date#toISOString()`).
|
|
21
|
+
|
|
22
|
+
## Recurrence (§9.3, D3)
|
|
23
|
+
|
|
24
|
+
`parseRule`, `formatRule`, `validateRecurrence` (minimum interval 1 hour, at most 24 a day), `occurrences`, `nextOccurrence`, `occurrencesBetween`, `presetRule`/`presetOf`, `presetMinuteOffset`. Gap occurrences move forward instead of being dropped (the documented deviation from RFC 5545 §3.3.10); property tests compare the expander with `rrule-temporal` on seeded random rules with that difference excluded.
|
|
25
|
+
|
|
26
|
+
Sentences are data: `describeRecurrence(rec)` returns `{ key, times, days?, weekdays?, monthDays?, n?, count?, until? }`; `renderRecurrence(sentence, "en" | "tr")` renders it with `RECURRENCE_MESSAGES` ("On the second Tuesday of every month at 09:07" / "Her ayın ikinci salısı 09:07").
|
|
27
|
+
|
|
28
|
+
## Releases (§6)
|
|
29
|
+
|
|
30
|
+
- `pinItems`, `dependencyClosure` (with `referencedNodeIds` as the default extractor), `composeRelease` (S1: `nodes(S) = nodes(L) − ids + targets`), `releaseConflicts` (S4), `missingDependency`, `planRelease`.
|
|
31
|
+
- `RELEASE_TRANSITIONS`, `HOLDING_STATES`, `TERMINAL_RELEASE_STATES`, `releaseWhen` (lead time, horizon), `baseApprovalVerdict` (D5, D9), `isPastLateLimit` and `nextRetryAt` (the one-hour rule and back-off), `orderReleases` and `releaseOverlaps` (D15).
|
|
32
|
+
|
|
33
|
+
### Identifiers (stable)
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
rl1 = "rl1:" + hex(SHA-256(utf8(lines.join("\n"))))
|
|
37
|
+
lines = ["site <siteId>"] + per item, sorted by node id (code-unit order):
|
|
38
|
+
"<set|remove> <nodeId> <nodeKind> <targetRev>:<targetHash>|- <baseRev>:<baseHash>|-"
|
|
39
|
+
|
|
40
|
+
runId = "run_" + Crockford-base32(first 100 bits of SHA-256(utf8(subjectId + "\n" + occurrenceAt.toISOString())))
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The time is not in `rl1:` (D4); an approval request's `args_hash` covers `approvalArgs(releaseId, when)`. Release and automation ids are random (`rel_`/`aut_` + 20 Crockford characters); lease tokens are random per claim.
|
|
44
|
+
|
|
45
|
+
## Automations (§5.3, §11)
|
|
46
|
+
|
|
47
|
+
`AUTOMATION_TRANSITIONS`, `RUN_TRANSITIONS`, `accountRunResult` (three failures pause, a budget breach pauses at once), `dueOccurrences` (only the latest missed occurrence runs), `runWindow`, `runEndsAt`, `killSwitchPauses`/`killSwitchResumes`; taint (`checkRunCall`, `afterRunCall`, `forbiddenUntrustedScopes`, `untrustedEffectiveScopes`); budgets (`checkRunBudget`, `budgetLeft`, `withinDailyWriteCap`).
|
|
48
|
+
|
|
49
|
+
## Scheduler (§8)
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { createScheduler, TICK_BUDGETS, TickMeter } from "@cloudhal/schedules";
|
|
53
|
+
import { SqlScheduleStore } from "@cloudhal/schedules/sql";
|
|
54
|
+
|
|
55
|
+
const scheduler = createScheduler({
|
|
56
|
+
openStore: (meter) => new SqlScheduleStore(meter.wrap(d1Driver)),
|
|
57
|
+
newMeter: (budget) => new TickMeter(budget),
|
|
58
|
+
releases: releaseExecutor({ graph, schedules }), // `@cloudhal/core-ts/releases`
|
|
59
|
+
builtins, systemJobs, checkApproval, wake: "minute",
|
|
60
|
+
});
|
|
61
|
+
await scheduler.runDue(new Date(controller.scheduledTime), TICK_BUDGETS.free, "cron");
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
In practice every ticker calls `runScheduledTick` from `@cloudhal/core-ts/releases`, which builds the graph, this store, the executor and the system jobs over one `TickMeter`. `runClaimedRelease` ends a run a caller claimed itself (a person's "Publish now", `SqlScheduleStore.claimManualRun`).
|
|
65
|
+
|
|
66
|
+
`runDue` claims each occurrence with a compare-and-swap and a fresh lease token and guards every later write on that token, so concurrent ticks produce one effect (S3). Releases run one at a time per site in time order (D15), at most an hour late (S8), with back-off retries and lease recovery. `SqlScheduleStore.releaseFinishStatements(…, guard)` gives `publishRelease` the statements that end a release to append to its own guarded batch.
|
|
67
|
+
|
|
68
|
+
For the API and MCP (rollout steps 7–8) the store also has `automationByKey`, `openAgentRun`, `readyAgentRun`, `openManualWindow`, `recordRunCall`, `endAgentRunAs`, `updateAutomation`, `deleteAutomation`, `retitleRelease` and `releaseLateness`. The scheduler's `checkApproval` is `createReleaseApprovalCheck` from `@cloudhal/mcp-server/schedules` (re-exported by `@cloudhal/api` with `releaseRights`).
|
|
69
|
+
|
|
70
|
+
## Built-in automations (§11.1, rollout step 9)
|
|
71
|
+
|
|
72
|
+
`createBuiltinRunner(sources)` is the `BuiltinRunner` for the five jobs; `@cloudhal/core-ts/automations` implements `BuiltinSources` over the site graph (`graphBuiltinRunner`), and `runScheduledTick` uses it by default. Every job runs in bounded steps — one per tick, at most `BUILTIN_STEP_COST[job]` statements — and keeps its position in `automations.cursor`, so a large site spans several ticks and a crash between them continues the same run. Findings (Studio-only JSON on the run, at most 200; counts exact) carry stable codes:
|
|
73
|
+
|
|
74
|
+
| Job | Steps | Finding codes | Counts |
|
|
75
|
+
|---|---|---|---|
|
|
76
|
+
| `broken-links` | pages of 50 live pages, entries, terms and menus; then the week's 404 rows (taints: `broken_links`) | `broken-internal-link`, `broken-media-reference`, `broken-menu-target`, `link-to-gated-content`, `not-found-path` (with a redirect `proposal`) | per code, `broken-links`, `nodes-scanned`, `links-checked` |
|
|
77
|
+
| `stale-content` | pages of 200 entries (route fields only) | `stale-entry` (oldest first) | `stale-entries`, `entries-scanned` |
|
|
78
|
+
| `feed-check` | `/rss.xml`, then `/sitemap.xml` (taints: `feed_check`) | `feed-unreachable`, `feed-invalid`, `feed-item-incomplete`, `feed-future-date`, `feed-missing-entry`, `feed-gated-node` (the gate self-check), `feed-asset-not-live` | per code, `documents-checked`, `feed-problems`, `feed-errors` |
|
|
79
|
+
| `weekly-digest` | one | `digest-published`, `digest-scheduled`, `digest-attention`, `digest-open-findings` (sections) | `published`, `scheduled`, `needs-attention`, `open-findings` |
|
|
80
|
+
| `cleanup` | retention batches until nothing is left, then reminders | `stale-draft` | `runs-deleted`, `releases-deleted`, `findings-trimmed`, `leases-cleared`, `stale-runs-closed`, `stale-drafts` |
|
|
81
|
+
|
|
82
|
+
Every built-in run also records `counts.steps` and `counts.statements` (its budget use). A step that reads visitor text or a fetched document returns `taint`; the running run is marked at once. `RunDueDeps.notify` (`ScheduleNotifier`) receives `automation-findings`, `automation-digest`, `automation-failed` and `automation-paused` after the run's end is committed; Studio's notifications are derived from the run rows by `@cloudhal/api`. A person's "Run now" is `SqlScheduleStore.startBuiltinNow`: a `manual` run for this minute that the next tick steps, after which the automation returns to its schedule. Nothing seeds automations: people create them in Studio (D7).
|
|
83
|
+
|
|
84
|
+
Statements per path (counted by `TickMeter`, Workers Free budget 40):
|
|
85
|
+
|
|
86
|
+
| Path | Statements |
|
|
87
|
+
|---|---|
|
|
88
|
+
| Idle tick | 1 (2 when the heartbeat is due, every fifth minute) |
|
|
89
|
+
| Release published, executor not committing | 9 |
|
|
90
|
+
| Release published, `publishRelease` shape (4 reads + 8-statement batch) | 18 |
|
|
91
|
+
| Release published by `runScheduledTick` with the real `publishRelease` (core-ts suite, no asset blobs) | 17 |
|
|
92
|
+
| Release missed | 7 |
|
|
93
|
+
| Release recovered (expired lease or transient error) | 13 |
|
|
94
|
+
| Built-in step (claim, a two-statement step, finish) | 8 |
|
|
95
|
+
| Built-in step that taints the run (more to do) | 10 |
|
|
96
|
+
| `broken-links` tick (core-ts suite: a page of live nodes) | 9–10 |
|
|
97
|
+
| `stale-content` tick | 8–9 |
|
|
98
|
+
| `feed-check` tick | 9 |
|
|
99
|
+
| `weekly-digest` tick | 13 |
|
|
100
|
+
| `cleanup` tick (retention batch / draft reminders) | 17 / 8 |
|
|
101
|
+
| Agent-task occurrence recorded | 6 |
|
|
102
|
+
| Agent-task window closed | 8 |
|
|
103
|
+
| First tick registering system jobs | 3 |
|
|
104
|
+
| System job run (plus the job's own) | 6 |
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automation and run state machines (RFC-0008 §5.3, §8.6, §11.2, §11.6). Pure.
|
|
3
|
+
*/
|
|
4
|
+
import type { Automation, AutomationRecurrence, AutomationState, ScheduleRunState } from "@cloudhal/core-contracts";
|
|
5
|
+
import { type Occurrence } from "./recurrence.js";
|
|
6
|
+
/** Three consecutive failures pause an automation (D11). */
|
|
7
|
+
export declare const CONSECUTIVE_FAILURE_LIMIT = 3;
|
|
8
|
+
/** How long a built-in step holds its automation before another tick may continue it. */
|
|
9
|
+
export declare const AUTOMATION_LEASE_MS: number;
|
|
10
|
+
/**
|
|
11
|
+
* Automation transitions (§5.3): `active ⇄ paused`; `active → auto-paused` (failures, budget);
|
|
12
|
+
* `active → broken` (key revoked, owner removed, role changed); `active → ended` (COUNT/UNTIL).
|
|
13
|
+
* Only a person resumes (`paused | auto-paused | broken → active`); the kill switch pauses with
|
|
14
|
+
* `pausedReason = kill-switch` and resuming the site resumes exactly those. A paused automation may
|
|
15
|
+
* still break (its key can be revoked meanwhile); an edited rule may revive an ended one.
|
|
16
|
+
*/
|
|
17
|
+
export declare const AUTOMATION_TRANSITIONS: Readonly<Record<AutomationState, readonly AutomationState[]>>;
|
|
18
|
+
export declare function canTransitionAutomation(from: AutomationState, to: AutomationState): boolean;
|
|
19
|
+
export declare function assertAutomationTransition(from: AutomationState, to: AutomationState): void;
|
|
20
|
+
/**
|
|
21
|
+
* Run transitions (§5.3): `due` (claimed) → `running` → `succeeded | failed | budget-exceeded |
|
|
22
|
+
* killed`; agent tasks start at `ready` (window open) and become `missed` when the window closes
|
|
23
|
+
* without `begin_run`; coalesced occurrences are written directly as `skipped`.
|
|
24
|
+
*/
|
|
25
|
+
export declare const RUN_TRANSITIONS: Readonly<Record<ScheduleRunState, readonly ScheduleRunState[]>>;
|
|
26
|
+
export declare const OPEN_RUN_STATES: readonly ScheduleRunState[];
|
|
27
|
+
export declare function canTransitionRun(from: ScheduleRunState, to: ScheduleRunState): boolean;
|
|
28
|
+
export declare function isOpenRun(state: ScheduleRunState): boolean;
|
|
29
|
+
export interface FailureAccounting {
|
|
30
|
+
consecutiveFailures: number;
|
|
31
|
+
/** Set when the automation must leave `active`. */
|
|
32
|
+
pause?: {
|
|
33
|
+
state: "auto-paused";
|
|
34
|
+
pausedReason: "failures" | "budget";
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* What a finished run does to its automation (D11): success resets the failure count; `failed`
|
|
39
|
+
* (and an agent task's `missed` window: the agent did not show up) adds one, and the third in a
|
|
40
|
+
* row auto-pauses; `budget-exceeded` auto-pauses at once. `skipped` (coalesced by downtime) and
|
|
41
|
+
* `killed` (a person or the kill switch) are not the automation's fault and change nothing.
|
|
42
|
+
*/
|
|
43
|
+
export declare function accountRunResult(consecutiveFailures: number, result: ScheduleRunState, job: "builtin" | "agent-task"): FailureAccounting;
|
|
44
|
+
/** The first occurrence strictly after `after`, or undefined when the recurrence has ended. */
|
|
45
|
+
export declare function nextRunAfter(recurrence: Pick<AutomationRecurrence, "start" | "timeZone" | "rule">, after: string | Date | number): Occurrence | undefined;
|
|
46
|
+
/** The first occurrence at or after `from` (a new or resumed automation's `nextRunAt`). */
|
|
47
|
+
export declare function firstRunFrom(recurrence: Pick<AutomationRecurrence, "start" | "timeZone" | "rule">, from: string | Date | number): Occurrence | undefined;
|
|
48
|
+
export interface DueOccurrences {
|
|
49
|
+
/** The occurrence that runs (or whose window is recorded). */
|
|
50
|
+
latest: Occurrence;
|
|
51
|
+
/** How many earlier missed occurrences are coalesced into one `skipped` row (`counts.coalesced`). */
|
|
52
|
+
coalesced: number;
|
|
53
|
+
/** The earliest coalesced occurrence (the `skipped` row's `occurrenceAt`). */
|
|
54
|
+
firstCoalesced?: Occurrence;
|
|
55
|
+
/** The next occurrence after `now` (the new `nextRunAt`), or undefined: the automation ended. */
|
|
56
|
+
next?: Occurrence;
|
|
57
|
+
}
|
|
58
|
+
/** At most this many missed occurrences are counted after downtime (the count saturates). */
|
|
59
|
+
export declare const MAX_COALESCED = 1000;
|
|
60
|
+
/**
|
|
61
|
+
* The missed policy for recurring jobs (§8.6, S8): of the occurrences in `[nextRunAt, now]` only
|
|
62
|
+
* the latest runs; earlier ones are coalesced. Undefined when nothing is due.
|
|
63
|
+
*/
|
|
64
|
+
export declare function dueOccurrences(recurrence: Pick<AutomationRecurrence, "start" | "timeZone" | "rule">, nextRunAt: string | Date | number, now: string | Date | number): DueOccurrences | undefined;
|
|
65
|
+
/** An agent task's run window: `[occurrence, occurrence + windowMinutes]` (§8.6, §11.2). */
|
|
66
|
+
export declare function runWindow(occurrenceAt: string | Date | number, windowMinutes: number): {
|
|
67
|
+
opensAt: string;
|
|
68
|
+
closesAt: string;
|
|
69
|
+
};
|
|
70
|
+
/** `endsAt = min(window end, start + maxMinutes)` (§11.2). */
|
|
71
|
+
export declare function runEndsAt(window: {
|
|
72
|
+
closesAt: string;
|
|
73
|
+
}, startedAt: string | Date | number, maxMinutes: number): string;
|
|
74
|
+
/** True while `now` is inside the window (inclusive start, exclusive end). */
|
|
75
|
+
export declare function insideWindow(window: {
|
|
76
|
+
opensAt: string;
|
|
77
|
+
closesAt: string;
|
|
78
|
+
}, now: string | Date | number): boolean;
|
|
79
|
+
/** Pausing for the site's kill switch: every `active` automation, marked so resume finds them (§11.6). */
|
|
80
|
+
export declare function killSwitchPauses(automations: readonly Pick<Automation, "id" | "state">[]): string[];
|
|
81
|
+
/** Resuming the site resumes exactly the automations the kill switch paused. */
|
|
82
|
+
export declare function killSwitchResumes(automations: readonly Pick<Automation, "id" | "state" | "pausedReason">[]): string[];
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automation and run state machines (RFC-0008 §5.3, §8.6, §11.2, §11.6). Pure.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
import { ScheduleError } from "./errors.js";
|
|
11
|
+
import { nextOccurrence, occurrencesBetween } from "./recurrence.js";
|
|
12
|
+
import { canonicalInstant, instantMs, MINUTE_MS } from "./time.js";
|
|
13
|
+
|
|
14
|
+
/** Three consecutive failures pause an automation (D11). */
|
|
15
|
+
export const CONSECUTIVE_FAILURE_LIMIT = 3;
|
|
16
|
+
/** How long a built-in step holds its automation before another tick may continue it. */
|
|
17
|
+
export const AUTOMATION_LEASE_MS = 10 * MINUTE_MS;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Automation transitions (§5.3): `active ⇄ paused`; `active → auto-paused` (failures, budget);
|
|
21
|
+
* `active → broken` (key revoked, owner removed, role changed); `active → ended` (COUNT/UNTIL).
|
|
22
|
+
* Only a person resumes (`paused | auto-paused | broken → active`); the kill switch pauses with
|
|
23
|
+
* `pausedReason = kill-switch` and resuming the site resumes exactly those. A paused automation may
|
|
24
|
+
* still break (its key can be revoked meanwhile); an edited rule may revive an ended one.
|
|
25
|
+
*/
|
|
26
|
+
export const AUTOMATION_TRANSITIONS =
|
|
27
|
+
{
|
|
28
|
+
active: ["paused", "auto-paused", "broken", "ended"],
|
|
29
|
+
paused: ["active", "broken", "ended"],
|
|
30
|
+
"auto-paused": ["active", "paused", "broken", "ended"],
|
|
31
|
+
broken: ["active", "paused", "ended"],
|
|
32
|
+
ended: ["active"],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function canTransitionAutomation(from , to ) {
|
|
36
|
+
return AUTOMATION_TRANSITIONS[from].includes(to);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function assertAutomationTransition(from , to ) {
|
|
40
|
+
if (!canTransitionAutomation(from, to))
|
|
41
|
+
throw new ScheduleError("invalid_transition", `an automation cannot go from ${from} to ${to}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Run transitions (§5.3): `due` (claimed) → `running` → `succeeded | failed | budget-exceeded |
|
|
46
|
+
* killed`; agent tasks start at `ready` (window open) and become `missed` when the window closes
|
|
47
|
+
* without `begin_run`; coalesced occurrences are written directly as `skipped`.
|
|
48
|
+
*/
|
|
49
|
+
export const RUN_TRANSITIONS = {
|
|
50
|
+
due: ["running", "skipped", "missed", "killed", "failed"],
|
|
51
|
+
ready: ["running", "missed", "killed"],
|
|
52
|
+
running: ["succeeded", "failed", "budget-exceeded", "killed", "missed"],
|
|
53
|
+
succeeded: [],
|
|
54
|
+
failed: [],
|
|
55
|
+
missed: [],
|
|
56
|
+
skipped: [],
|
|
57
|
+
"budget-exceeded": [],
|
|
58
|
+
killed: [],
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const OPEN_RUN_STATES = ["due", "ready", "running"];
|
|
62
|
+
|
|
63
|
+
export function canTransitionRun(from , to ) {
|
|
64
|
+
return RUN_TRANSITIONS[from].includes(to);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function isOpenRun(state ) {
|
|
68
|
+
return OPEN_RUN_STATES.includes(state);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* What a finished run does to its automation (D11): success resets the failure count; `failed`
|
|
79
|
+
* (and an agent task's `missed` window: the agent did not show up) adds one, and the third in a
|
|
80
|
+
* row auto-pauses; `budget-exceeded` auto-pauses at once. `skipped` (coalesced by downtime) and
|
|
81
|
+
* `killed` (a person or the kill switch) are not the automation's fault and change nothing.
|
|
82
|
+
*/
|
|
83
|
+
export function accountRunResult(
|
|
84
|
+
consecutiveFailures ,
|
|
85
|
+
result ,
|
|
86
|
+
job ,
|
|
87
|
+
) {
|
|
88
|
+
if (result === "succeeded") return { consecutiveFailures: 0 };
|
|
89
|
+
if (result === "budget-exceeded")
|
|
90
|
+
return { consecutiveFailures, pause: { state: "auto-paused", pausedReason: "budget" } };
|
|
91
|
+
const counts = result === "failed" || (result === "missed" && job === "agent-task");
|
|
92
|
+
if (!counts) return { consecutiveFailures };
|
|
93
|
+
const n = consecutiveFailures + 1;
|
|
94
|
+
return n >= CONSECUTIVE_FAILURE_LIMIT
|
|
95
|
+
? { consecutiveFailures: n, pause: { state: "auto-paused", pausedReason: "failures" } }
|
|
96
|
+
: { consecutiveFailures: n };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The first occurrence strictly after `after`, or undefined when the recurrence has ended. */
|
|
100
|
+
export function nextRunAfter(
|
|
101
|
+
recurrence ,
|
|
102
|
+
after ,
|
|
103
|
+
) {
|
|
104
|
+
return nextOccurrence(recurrence, after);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The first occurrence at or after `from` (a new or resumed automation's `nextRunAt`). */
|
|
108
|
+
export function firstRunFrom(
|
|
109
|
+
recurrence ,
|
|
110
|
+
from ,
|
|
111
|
+
) {
|
|
112
|
+
return nextOccurrence(recurrence, instantMs(from) - 1);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
/** At most this many missed occurrences are counted after downtime (the count saturates). */
|
|
127
|
+
export const MAX_COALESCED = 1_000;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The missed policy for recurring jobs (§8.6, S8): of the occurrences in `[nextRunAt, now]` only
|
|
131
|
+
* the latest runs; earlier ones are coalesced. Undefined when nothing is due.
|
|
132
|
+
*/
|
|
133
|
+
export function dueOccurrences(
|
|
134
|
+
recurrence ,
|
|
135
|
+
nextRunAt ,
|
|
136
|
+
now ,
|
|
137
|
+
) {
|
|
138
|
+
if (instantMs(nextRunAt) > instantMs(now)) return undefined;
|
|
139
|
+
// Beyond MAX_COALESCED the count saturates; `latest` is always the true latest.
|
|
140
|
+
const between = occurrencesBetween(recurrence, instantMs(nextRunAt) - 1, now, MAX_COALESCED);
|
|
141
|
+
const latest = between.latest;
|
|
142
|
+
if (!latest) return undefined;
|
|
143
|
+
const first = between.count > 1 ? between.occurrences[0] : undefined;
|
|
144
|
+
const next = nextOccurrence(recurrence, now);
|
|
145
|
+
return {
|
|
146
|
+
latest,
|
|
147
|
+
coalesced: between.count - 1,
|
|
148
|
+
...(first ? { firstCoalesced: first } : {}),
|
|
149
|
+
...(next ? { next } : {}),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** An agent task's run window: `[occurrence, occurrence + windowMinutes]` (§8.6, §11.2). */
|
|
154
|
+
export function runWindow(
|
|
155
|
+
occurrenceAt ,
|
|
156
|
+
windowMinutes ,
|
|
157
|
+
) {
|
|
158
|
+
const opens = instantMs(occurrenceAt);
|
|
159
|
+
return {
|
|
160
|
+
opensAt: canonicalInstant(opens),
|
|
161
|
+
closesAt: canonicalInstant(opens + windowMinutes * MINUTE_MS),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** `endsAt = min(window end, start + maxMinutes)` (§11.2). */
|
|
166
|
+
export function runEndsAt(
|
|
167
|
+
window ,
|
|
168
|
+
startedAt ,
|
|
169
|
+
maxMinutes ,
|
|
170
|
+
) {
|
|
171
|
+
return canonicalInstant(
|
|
172
|
+
Math.min(instantMs(window.closesAt), instantMs(startedAt) + maxMinutes * MINUTE_MS),
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** True while `now` is inside the window (inclusive start, exclusive end). */
|
|
177
|
+
export function insideWindow(
|
|
178
|
+
window ,
|
|
179
|
+
now ,
|
|
180
|
+
) {
|
|
181
|
+
const t = instantMs(now);
|
|
182
|
+
return t >= instantMs(window.opensAt) && t < instantMs(window.closesAt);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Pausing for the site's kill switch: every `active` automation, marked so resume finds them (§11.6). */
|
|
186
|
+
export function killSwitchPauses(
|
|
187
|
+
automations ,
|
|
188
|
+
) {
|
|
189
|
+
return automations.filter((a) => a.state === "active").map((a) => a.id);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Resuming the site resumes exactly the automations the kill switch paused. */
|
|
193
|
+
export function killSwitchResumes(
|
|
194
|
+
automations ,
|
|
195
|
+
) {
|
|
196
|
+
return automations
|
|
197
|
+
.filter((a) => a.state === "paused" && a.pausedReason === "kill-switch")
|
|
198
|
+
.map((a) => a.id);
|
|
199
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-invocation query budget (RFC-0008 §8.1, §8.2, S17). A `TickMeter` wraps the `SqlDriver`
|
|
3
|
+
* a tick uses and counts statements — every `get`, `all` and `run` is one, a `batch()` counts each
|
|
4
|
+
* of its statements (the conservative reading of L7) — and refuses a statement that would exceed
|
|
5
|
+
* `maxQueries` before it reaches the database, so a tick stops cleanly under the platform's limit
|
|
6
|
+
* (Workers Free: 50 D1 queries per invocation; the tick takes 40). `runDue` also asks
|
|
7
|
+
* `canAfford(n)` before starting a unit of work, so a refusal mid-path is a safety net only.
|
|
8
|
+
*/
|
|
9
|
+
import type { SqlDriver } from "@cloudhal/storage";
|
|
10
|
+
export type TickTrigger = "cron" | "alarm" | "request" | "node" | "manual";
|
|
11
|
+
export interface TickBudget {
|
|
12
|
+
/** Statements (queries) one invocation may execute. */
|
|
13
|
+
maxQueries: number;
|
|
14
|
+
/** Releases one invocation may run. */
|
|
15
|
+
maxReleases: number;
|
|
16
|
+
/** Wall-clock milliseconds after which no new unit of work starts. */
|
|
17
|
+
deadlineMs: number;
|
|
18
|
+
}
|
|
19
|
+
/** Workers Free and Paid budgets (§8.2); Node uses `paid` (no platform limit, same bounded steps). */
|
|
20
|
+
export declare const TICK_BUDGETS: {
|
|
21
|
+
readonly free: {
|
|
22
|
+
readonly maxQueries: 40;
|
|
23
|
+
readonly maxReleases: 1;
|
|
24
|
+
readonly deadlineMs: 8000;
|
|
25
|
+
};
|
|
26
|
+
readonly paid: {
|
|
27
|
+
readonly maxQueries: 900;
|
|
28
|
+
readonly maxReleases: 50;
|
|
29
|
+
readonly deadlineMs: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare class TickMeter {
|
|
33
|
+
#private;
|
|
34
|
+
readonly budget: TickBudget;
|
|
35
|
+
/** `clock` is a monotonic-enough millisecond source for the deadline (injected in tests). */
|
|
36
|
+
constructor(budget: TickBudget, clock?: () => number);
|
|
37
|
+
/** Statements executed so far. */
|
|
38
|
+
get used(): number;
|
|
39
|
+
get remaining(): number;
|
|
40
|
+
/** True when `n` more statements fit, keeping `reserve` for the heartbeat. */
|
|
41
|
+
canAfford(n: number, reserve?: number): boolean;
|
|
42
|
+
deadlinePassed(): boolean;
|
|
43
|
+
/** Counts `n` statements, refusing before the budget would be exceeded. */
|
|
44
|
+
take(n: number): void;
|
|
45
|
+
/**
|
|
46
|
+
* Counts `n` statements that already ran outside the limit (a system job's own driver): later
|
|
47
|
+
* units see less room, and nothing is refused.
|
|
48
|
+
*/
|
|
49
|
+
note(n: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* A driver that counts every statement into this meter without refusing any — for work whose
|
|
52
|
+
* own bounds hold (the analytics rollup, the comments job) but whose statements share the
|
|
53
|
+
* invocation's platform limit with the tick.
|
|
54
|
+
*/
|
|
55
|
+
wrapCounting(inner: SqlDriver): SqlDriver;
|
|
56
|
+
/** A driver that counts (and limits) every statement it executes through `inner`. */
|
|
57
|
+
wrap(inner: SqlDriver): SqlDriver;
|
|
58
|
+
}
|