From 62a9c41e223285a892e8ed787067297cbeb7fc6d Mon Sep 17 00:00:00 2001 From: sftimeless <37782990+sftimeless@users.noreply.github.com> Date: Thu, 19 Nov 2026 22:09:08 -0800 Subject: [PATCH] Release setup 2026-11-19.1: minute/hourly cost caps and the enforced review window Keel now accepts minute and hourly windows on deny_if_cost_exceeds, and enforces one review deadline per held request. Mirrors the reviewed product files: - keel-policy/reference/policy-document.schema.json adds "minute" and "hourly" to the cost-cap window enum. - keel-policy/SKILL.md lists the two windows, says every windowed cap is a fixed UTC-aligned window, and adds "What a review timeout does": a decision at or after the deadline is refused with a 409 and nothing runs; the deadline is the rule's timeout_seconds (else the project default, Keel's 600 seconds) or the Permit's lifetime, whichever is first; a review that names no approver is written only when the user accepts both the project default window and Keel's default approver. - shared/scripts/test_schema_validation.py pins the accepted windows. SOURCE.json, scripts/check_release_bundle.py and SHA256SUMS move to release 2026-11-19.1 with the new product digest. Co-Authored-By: Claude Opus 5.5 --- SHA256SUMS | 10 ++--- SOURCE.json | 4 +- keel-policy/SKILL.md | 44 ++++++++++++++++++- .../reference/policy-document.schema.json | 2 + scripts/check_release_bundle.py | 4 +- shared/scripts/test_schema_validation.py | 11 +++++ 6 files changed, 65 insertions(+), 10 deletions(-) diff --git a/SHA256SUMS b/SHA256SUMS index 26663fc..bc51948 100644 --- a/SHA256SUMS +++ b/SHA256SUMS @@ -2,15 +2,15 @@ b97a81728fc0d91f066bb92f27695c81f9bb25bd88d93bf470230132f33d0799 .github/workfl b63eff93f485d563b24680091496a39b3a62ecf3c8bb229cfc4eecd80c7e2262 .gitignore 3c0871d9b30c3e9647426b5b756be7dbfc5eee8728e6f0e0c371385de7c5f8f7 LICENSE 89e7fa8c08b6ada7931706085c33924173454fc51b866cb6726f8976d030e715 README.md -91509233a45fafff234017cef5be2bdaf429868b5a9b7e8f9caf6950756e4b47 SOURCE.json -d924c42ecc5a084e441bc3450ca815d84ee205e49426ef3988e7c749e7dae78a keel-policy/SKILL.md +c3895b7b544b2bd2375c54d84967831bcc89eb455cc825c22f4e065035b3456b SOURCE.json +ab07a1b63c978192177ecd8a8d46f59d36883a1113b5c63005ac35db6936cd60 keel-policy/SKILL.md 6b449605b6b4fe6eb84f5b12befb90a57b7841d2973bbf9341cf40866e7dd81a keel-policy/examples/README.md 9a13b533704c1a37734bd6c28fc202c7acdaa8335773d55790dac50a693f8b2b keel-policy/examples/stripe-refund-approval-enterprise.json 2a52514e8db0901ab73e59b924f195008541d0069ebad9b514bd373cb905e2d2 keel-policy/examples/stripe-refund-approval.json 49f43e551f32e484e263fa026dfd4fde5a8b50cd462f0f68e06ae371380f3b24 keel-policy/reference/enforceability-report.schema.json 8e818177237d6d99d5dd3867b60585160b3add4d17699c86c948b902328f9171 keel-policy/reference/field-provenance.json 5526029f8d79d7d2b31daed8ebeeb42942d0a18a0562a4a3789e8c8a7c83b14a keel-policy/reference/fields.md -9d86eeb4fecf6db831856c0b77b9e83caeb161ec82d046eaf4fc2f8e73d96f27 keel-policy/reference/policy-document.schema.json +8954c9b8c8af07cbb2576608575025d9d14588a55e32c3ee0e96858ab9df81b2 keel-policy/reference/policy-document.schema.json 7d662cffa24744af7a26f62d813127b4bc0a44ff62f725c883054165ddec3272 keel-policy/scripts/consume_authoring_context.py d8a8ad9886f43efb6b5b7065ef167150b2c8b03f640cc8647f52680ae211e2eb keel-policy/scripts/validate_enforceability_report.py ff71e2933eb4ab5be18d5fa41eb324a376ffd460c39157ecd6db39bfc016ee44 keel-policy/tests/test_authoring_context_consumption.py @@ -38,14 +38,14 @@ af96ae9a32e470a2c1390ec452c13ae1c3657d7ed54c99925b0a57501503894b keel-setup/tes c8006372327167f6317d7ae41d79da3c2dd45a7510f1cdc544616facd27d9d83 keel-setup/tests/test_setup_state.py ea797a44c033a6ce519b82595c858cdb0879868854b949226792f3bffe2d4ba3 keel-setup/tests/test_verify_execute.py ba172f0dcadea1b19f3279e3c3151dabc1719cdc65ddce77eb5c74550c101ce0 scripts/check_execute_contract.py -959f57ae981f35d4e4234c5fb087e4de2602f84ddd4ad834feed1a00efe7d1de scripts/check_release_bundle.py +62f86699b30a07044abe6deb4e90451b0909005ae6c9e1f6aafb8300cf38581b scripts/check_release_bundle.py e0195765e2b9a31938a455fc81f93b02127f7b769948607b19a821f2bd82b2d1 shared/CONSTITUTION.md 6510e9f92c2a8fa3c40a2ca99eca06e2acaad146101c9526e06bb53f18085421 shared/feedback-report.schema.json 67ef5250861a9f1f3f2c3671205adc12dfa2e049ffd68449b78337d2ac490727 shared/feedback-report.template.md 378cd5a1c96810c36054553bde92c137deceec890a5c046a8e8d9a7bfecce51b shared/scripts/bounded_input.py e64ed436bc35d73cdad6366f2dd3f01530426cb529237d2990be07171c93b08c shared/scripts/schema_validation.py 0e15d2320554d19fddd24299afc807317c6313d7cd96c6fe0fd3dbaf25558fad shared/scripts/test_bounded_input.py -4cbb3be5a54865a85549400f7c57610a7284623899674c0902354b870b1980ad shared/scripts/test_schema_validation.py +15cefd9bf0a20be746237f4970c4b95abf3ee6778442b43907dca4c5b85a0174 shared/scripts/test_schema_validation.py 8f7c8bfd8ec6bc7faab7ea1341365ba67f31846232a2c3acac5f7c4bdaa3c411 shared/scripts/test_validate_feedback_report.py 696a0c609ef7895cfe3737942dc4e32feeeb870bbd23689fbeee965752498587 shared/scripts/validate_feedback_report.py 46a7d399e61d2aaa135d030455a75b704e9cbe028e604373c3ab5d6918876372 tools/public_surface.json diff --git a/SOURCE.json b/SOURCE.json index 9c7fc73..3810a0e 100644 --- a/SOURCE.json +++ b/SOURCE.json @@ -1,7 +1,7 @@ { "bundle_schema_version": "keel.public_setup_bundle.v1", - "public_release_version": "2026-11-18.1", - "product_source_sha256": "adf8f87bfbb3a10b221b5350b40adf6484159b092e7172546924e30de59dab3e", + "public_release_version": "2026-11-19.1", + "product_source_sha256": "64f2e92364468ae3140abb0e7798343712660ee755603fe0709e7ab306ca9b2a", "included_roots": [ "keel-policy", "keel-setup", diff --git a/keel-policy/SKILL.md b/keel-policy/SKILL.md index 549f90a..16b6e26 100644 --- a/keel-policy/SKILL.md +++ b/keel-policy/SKILL.md @@ -410,11 +410,23 @@ case. Handle it like this: `deny_if_cost_exceeds` is easy to describe more strongly than it behaves, and the two window kinds do not make the same promise. State the one that applies. -**Windowed caps** — `daily`, `weekly`, `monthly`, `quarterly`. Keel tracks accumulated provider +**Windowed caps** — `minute`, `hourly`, `daily`, `weekly`, `monthly`, `quarterly`. +Keel tracks accumulated provider cost using reconciled actual usage for completed requests, and estimated exposure for requests still in flight. The historical part is what the provider actually charged, so the window self-corrects as requests complete. +Every windowed cap is a **fixed window aligned to the UTC clock** — the clock minute, the clock +hour, the UTC day, a Monday-start week, the calendar month or quarter — not a sliding one. An +`hourly` cap resets at the top of each UTC hour; it is not "in any 60 minutes". Read it back that +way, and if the user means a rolling period, say that Keel's cost windows do not express one +rather than encoding it as if they did. A short window can settle above its cap: a request counts +in the window it was admitted in until its usage is reported, then in the window the report +arrived in, so calls in flight when a window opens add to it. There is no per-second cost window. +Below a minute, the request-count controls work: `deny_if_rate_exceeds`, and +`throttle_if_rate_exceeds` outside `basic`. They count requests over a sliding `window_seconds`, +not money. + **Per-request caps** — `window: "request"`. Keel makes the decision before provider dispatch using a conservative cost estimate. There is no accumulated history to correct it, so the estimate is the whole basis of the decision. @@ -440,6 +452,36 @@ upper bound across every supported request shape, and "maximum" would promise ex narrows the range of possible costs, but it is not itself a cost control and does not make the final cost predictable. Offer it for what it does. +## What a review timeout does + +A held request has one review deadline, and Keel enforces it when the decision is recorded. An +approval or a rejection at or after the deadline is refused with a 409 +(`review_window_elapsed`, or `conflict` once Keel has already closed the hold): no vote is +recorded, nothing runs, the hold expires, and the request has to be made again for a fresh review. +A late approval never lets the action through. + +The review window comes from one place: + +- the rule's own `timeout_seconds`, on its `approval_requirement` or `require_attestation` (when a + rule carries both, the `approval_requirement` value wins); otherwise +- the project's default review window. A `require_human_review` that names no approver uses it. + Until the project sets its own (from 300 seconds to 7 days), it is Keel's default of 600 seconds. + +The deadline is that window or the end of the Permit's own lifetime, whichever comes first — for +example a `constrain_permit_lifetime` limit or the request's own expiry. So read `timeout_seconds` +back as the most time the approver has, after which the action does not run: "an approver has up +to one hour; after that the refund does not happen and must be requested again". It is still the +user's value under invariant 3. Do not choose it, and do not move it towards Keel's default. + +A `require_human_review` with no approver needs no `timeout_seconds`, but it is not a way around +state 2. It makes two choices for the user: the window (the project's default) and the approver +(the project owner, or the organization's `owner` role when the project has no owner). Write it +only when the user accepts both; otherwise ask for the timeout. In the readback, name who approves +and say the review closes after the project's review window, which is 10 minutes unless the project +has set another. You cannot see which, so never state a number as that project's setting. The +project default belongs to a project owner or an organization owner or admin; the agent does not +change it. + ## What requires a user decision Three categories. Telling them apart is what keeps invention out of the document. diff --git a/keel-policy/reference/policy-document.schema.json b/keel-policy/reference/policy-document.schema.json index ac331ec..9a41f1f 100644 --- a/keel-policy/reference/policy-document.schema.json +++ b/keel-policy/reference/policy-document.schema.json @@ -1034,6 +1034,8 @@ }, "window": { "enum": [ + "minute", + "hourly", "daily", "weekly", "monthly", diff --git a/scripts/check_release_bundle.py b/scripts/check_release_bundle.py index c291ad8..ec2df97 100644 --- a/scripts/check_release_bundle.py +++ b/scripts/check_release_bundle.py @@ -11,8 +11,8 @@ ROOT = Path(__file__).resolve().parents[1] -PUBLIC_RELEASE_VERSION = "2026-11-18.1" -PRODUCT_SOURCE_SHA256 = "adf8f87bfbb3a10b221b5350b40adf6484159b092e7172546924e30de59dab3e" +PUBLIC_RELEASE_VERSION = "2026-11-19.1" +PRODUCT_SOURCE_SHA256 = "64f2e92364468ae3140abb0e7798343712660ee755603fe0709e7ab306ca9b2a" PUBLICATION_LAYER_FILES = [ ".github/workflows/ci.yml", ".gitignore", diff --git a/shared/scripts/test_schema_validation.py b/shared/scripts/test_schema_validation.py index 304e1e0..b0ac942 100644 --- a/shared/scripts/test_schema_validation.py +++ b/shared/scripts/test_schema_validation.py @@ -32,6 +32,17 @@ def test_approval_selectors_are_closed_and_bound_to_their_type(self): self.assertTrue(schema_validation.validate({"type": "approver_group", "timeout_seconds": 60, "group_id": identifier, "group_slug": "reviewers"}, schema)) + def test_cost_windows_are_exactly_the_ones_keel_accepts(self): + root = pathlib.Path(__file__).resolve().parents[2] + policy_schema = json.loads((root / "keel-policy/reference/policy-document.schema.json").read_text()) + schema = policy_schema["$defs"]["DenyIfCostExceedsParams"] + accepted = ["minute", "hourly", "daily", "weekly", "monthly", "quarterly", "request"] + self.assertEqual(schema["properties"]["window"]["enum"], accepted) + for window in accepted: + self.assertEqual(schema_validation.validate({"window": window, "cap_micros": 100}, schema), [], window) + for window in ("second", "per_second", "hour", "rolling_hour", "yearly"): + self.assertTrue(schema_validation.validate({"window": window, "cap_micros": 100}, schema), window) + def test_date_time_requires_an_unambiguous_rfc3339_instant(self): schema = {"type": "string", "format": "date-time"} for value in ("2026-11-06T12:00:00", "20261106T120000Z", "2026-11-06T12:00Z",