media: Astra round 1's P2s: retirement weights in the sim, allowance copy
P2-1: the simulation exempted every retired row from the exact weight rule, so it could not tell retirement before the result read (weight 1) from retirement after it (weight 2, commitDone's retired fallback). The checker now records each result read and takes the reads of the step a row settles in as its settlement's; I2 also holds weight_tenths still. A witness retires one long 4K row after the read and one before it, and a mutation charging the fallback at 1 fails it. Checker cases insert freshly settled rows. P2-2: the allowance paragraph said a failed job is charged at the same weights; only a long video whose result says above 1080p is charged at 2. The row is redrafted for Luna pass 6b. A7 gains Astra's note on mixed console and image versions. Findings committed as CODEX-FINDINGS-media-spike-values.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 files changed,
+182
−31
docs/site/media-conversion.md+1 −1docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion-6b.md+21 −0docs/superpowers/notes/media-conversion-copy-deck.md+1 −1docs/superpowers/reviews/CODEX-FINDINGS-media-spike-values.md+21 −0docs/superpowers/specs/2026-11-16-video-conversion-design.md+7 −0internal/sim/mediajobs/invariants_test.go+26 −14internal/sim/mediajobs/witness_test.go+71 −8internal/sim/mediajobs/world_test.go+34 −7
diff --git a/docs/site/media-conversion.md b/docs/site/media-conversion.md| index 8ddb806e5..cb18ec87b 100644 |
| --- a/docs/site/media-conversion.md |
| +++ b/docs/site/media-conversion.md |
| @@ -217,7 +217,7 @@ Fair use applies on every deployment. By default an account can have 20 conversi |
| Your deployment can give your account a monthly allowance of media minutes, shared by its apps. Where billing is on, the account's Billing page shows the allowance and how much you've used. A minute of video up to 1080p counts as 1 media minute, a minute of video above 1080p counts as 2, and a minute of audio counts as 0.1, so 10 minutes of audio is 1 media minute. |
| -A done job is charged for the length of its source: 1 media minute per minute for video up to 1080p, 2 for video above 1080p, and 0.1 for audio. A failed job is charged for the engine time it used at the same weights; a video the engine never got to read counts as up to 1080p. If the engine loses the task record, it is charged the full reserved time. A job that never starts is uncharged. While a job runs, the most it could cost is held against the allowance. A long video job is held at 2 media minutes per minute because nothing is known of the picture until the engine reads the file. |
| +A done job is charged for the length of its source: 1 media minute per minute for video up to 1080p, 2 for video above 1080p, and 0.1 for audio. A failed job is charged for the engine time it used, at 1 media minute per minute for video and 0.1 for audio. The one exception is a long job whose result says its video is above 1080p, which is charged at 2. If the engine loses the task record, the job is charged the full time it was allowed to run, at 1 a minute for video. A job that never starts is uncharged. While a job runs, the most it could cost is held against the allowance. A long video job is held at 2 media minutes per minute because nothing is known of the picture until the engine reads the file. |
| As with other monthly limits, the account's owners get a warning at 80% of the limit. At twice the monthly limit, new conversions are refused with `402` until the 1st of the UTC month, or until the account buys a media pack or moves to a larger plan. A job can also fail `allowance_exceeded` when what's left of the allowance won't cover the file. See [Plans](/docs/plans). |
diff --git a/docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion-6b.md b/docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion-6b.md| new file mode 100644 |
| index 000000000..be5a45837 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion-6b.md |
| @@ -0,0 +1,21 @@ |
| +# Copy pass 6b: media conversion, one allowance row after review |
| + |
| +You are the copy-review gate itself for this one row. Paul delegated copy review of platform UI, CLI, email and docs copy inside a plan to you on 2026-10-25; your verdict IS the review. Do NOT run the copy-review skill or start any server. You are writing a review report. |
| + |
| +Same feature, house rules and rulings as `docs/superpowers/notes/LUNA-COPY-BRIEF-media-conversion.md` and pass 6 (`LUNA-COPY-BRIEF-media-conversion-6.md` and its result `LUNA-COPY-RESULT-media-conversion-6.md`; read all three). |
| + |
| +Review ONLY the row marked "(pending Luna pass 6b)" in `docs/superpowers/notes/media-conversion-copy-deck.md`: `docs.media.allowance.3`, the second paragraph of "The allowance" on `docs/site/media-conversion.md`. Readers are app developers and account owners. |
| + |
| +Why it changed: the branch's billing review (Astra round 1, `docs/superpowers/reviews/CODEX-FINDINGS-media-spike-values.md`, the second P2) found that pass 6's text, "A failed job is charged for the engine time it used at the same weights; a video the engine never got to read counts as up to 1080p", overstates the charge. The facts, from spec §11 A7 "Charge" and `chargeWeight` in `internal/mediajobs/track.go`: |
| + |
| +- A done job: its source's length at its weight (1 up to 1080p, 2 above, 0.1 audio). |
| +- A failed job: the engine time it used, at 1 for video and 0.1 for audio. The only failed job charged at 2 is a long-class video whose result the console read and which says the video is above 1080p. A short-class job is never charged at 2: the short class refuses a video above 1080p before converting it. A failed job with no result for the console to read (the engine stopped it, it ran past its time, it crashed) is charged at 1. |
| +- A job whose task record the engine lost: the full time it was allowed to run (its deadline plus a 30-second stop grace), at 1 for video and 0.1 for audio. |
| +- A job that never starts: nothing. |
| +- While a job runs, the most it could cost is held; a long video job is held at 2. |
| + |
| +Change the row only where it misleads, can't be parsed, or contradicts a fact above. Keep it a plain paragraph. Don't add the 30-second figure unless it helps the reader act. |
| + |
| +## What to return |
| + |
| +A table `key | new | why` with the row if you change it (its full new text), or the single line "approved as written". Then `## Flags` with anything you could not verify, or "none". |
diff --git a/docs/superpowers/notes/media-conversion-copy-deck.md b/docs/superpowers/notes/media-conversion-copy-deck.md| index ce251659d..696227138 100644 |
| --- a/docs/superpowers/notes/media-conversion-copy-deck.md |
| +++ b/docs/superpowers/notes/media-conversion-copy-deck.md |
| @@ -516,7 +516,7 @@ row is applied to the page verbatim. |
| | `docs.media.limits.13` | Fair use applies on every deployment. By default an account can have 20 conversions waiting or running, and send 30 a minute with bursts of 10. An account runs up to 2 short jobs and 1 long job at once, and the rest wait their turn. The deployment holds at most 200 waiting jobs. Your operator can change these numbers. | |
| | `docs.media.allowance.1` | ### The allowance | |
| | `docs.media.allowance.2` | Your deployment can give your account a monthly allowance of media minutes, shared by its apps. Where billing is on, the account's Billing page shows the allowance and how much you've used. A minute of video up to 1080p counts as 1 media minute, a minute of video above 1080p counts as 2, and a minute of audio counts as 0.1, so 10 minutes of audio is 1 media minute. | (approved, Luna pass 6) |
| -| `docs.media.allowance.3` | A done job is charged for the length of its source: 1 media minute per minute for video up to 1080p, 2 for video above 1080p, and 0.1 for audio. A failed job is charged for the engine time it used at the same weights; a video the engine never got to read counts as up to 1080p. If the engine loses the task record, it is charged the full reserved time. A job that never starts is uncharged. While a job runs, the most it could cost is held against the allowance. A long video job is held at 2 media minutes per minute because nothing is known of the picture until the engine reads the file. | (approved, Luna pass 6) |
| +| `docs.media.allowance.3` | A done job is charged for the length of its source: 1 media minute per minute for video up to 1080p, 2 for video above 1080p, and 0.1 for audio. A failed job is charged for the engine time it used, at 1 media minute per minute for video and 0.1 for audio. The one exception is a long job whose result says its video is above 1080p, which is charged at 2. If the engine loses the task record, the job is charged the full time it was allowed to run, at 1 a minute for video. A job that never starts is uncharged. While a job runs, the most it could cost is held against the allowance. A long video job is held at 2 media minutes per minute because nothing is known of the picture until the engine reads the file. | (pending Luna pass 6b) |
| | `docs.media.allowance.4` | As with other monthly limits, the account's owners get a warning at 80% of the limit. At twice the monthly limit, new conversions are refused with `402` until the 1st of the UTC month, or until the account buys a media pack or moves to a larger plan. A job can also fail `allowance_exceeded` when what's left of the allowance won't cover the file. See [Plans](/docs/plans). | |
| | `docs.media.residency.1` | ## Where conversion runs | |
| | `docs.media.residency.2` | Conversion runs in your store's region: the engine reads the source from your store and writes the outputs back to it there. A store in a region with no conversion engine is refused with `no_engine_in_region`. It is never converted somewhere else. | |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-media-spike-values.md b/docs/superpowers/reviews/CODEX-FINDINGS-media-spike-values.md| new file mode 100644 |
| index 000000000..b89371c5c |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-media-spike-values.md |
| @@ -0,0 +1,21 @@ |
| +# Astra findings: media-spike-values, round 1 of 3 |
| + |
| +Reviewer: gpt-6-astra, reasoning effort high, read-only. Brief: `CODEX-REVIEW-BRIEF-media-spike-values.md`. Reviewed tip 2d5eb9f5cfbf444ef7450434427d40181a276c8a. The report below is the reviewer's final message, unedited. |
| + |
| +--- |
| + |
| +No P1 findings. |
| + |
| +- **P2 — Check 7: the simulation permits incorrect weights on retired settlements.** [invariants_test.go:382](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-spike-values/internal/sim/mediajobs/invariants_test.go:382) accepts weight 1 for every `retired` row, including one retired **after** its above-1080p result was read. That case must retain weight 2, as [track.go:248](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-spike-values/internal/mediajobs/track.go:248) currently does. A regression charging that fallback at weight 1 would pass this checker. The simulation records facts when the codec writes them ([world_test.go:480](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-spike-values/internal/sim/mediajobs/world_test.go:480)), so it cannot distinguish the two retirement cases. **Fix:** record successful result reads and add witnesses for retirement before and after reading a 4K result, requiring weights 1 and 2 respectively. **Fault family:** I3—settlement weight must reflect the source facts actually read. |
| + |
| +- **P2 — Check 9: the allowance copy overstates failed-job charges.** [media-conversion.md:220](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-spike-values/docs/site/media-conversion.md:220), repeated in `docs.media.allowance.3`, says failed above-1080p video uses weight 2 unless the engine never read it. An honest short-class job probes a 4K source, refuses it with `needs_long_class`, and charges weight 1: [media.go:122](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-spike-values/internal/media/media.go:122) caps the weight by class. Likewise, the engine may read a source but leave no result for the console; that also charges weight 1. **Fix:** describe both exceptions explicitly: short-class failures use weight 1, and video settlements without source facts read by the console use weight 1. Update the page and deck together. **Fault family:** the published billing explanation must match settlement accounting. |
| + |
| +No P3 findings. |
| + |
| +Wire compatibility: mixed versions break video conversions. A new console sends `dr`/`hl`, which an old image’s strict decoder rejects; a new image can emit `hdr`, which an old console rejects. The new reader accepts older results without `hdr`. These mixed-version failures are not stated in A7; they are acceptable under the brief’s premise that no deployment runs the engine yet, provided initial activation pairs the console and image from this release. |
| + |
| +Validation: `git diff --check` passed. Targeted Go tests were blocked by the read-only filesystem before execution; the reported simulation runs were not independently reproduced. GOCACHE remained unset. |
| + |
| +Census verdict — **approve** `internal/plans`: [catalog.go:54](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-spike-values/internal/plans/catalog.go:54) changes only a comment, introducing no root reads or weakened checks. Independently recomputed the envelope hash; it matches [the overlay at line 3](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/media-spike-values/internal/provision/testdata/plan14-root-reads-media-spike-values.tsv:3). |
| + |
| +**READY AFTER FIXES** |
| \ No newline at end of file |
diff --git a/docs/superpowers/specs/2026-11-16-video-conversion-design.md b/docs/superpowers/specs/2026-11-16-video-conversion-design.md| index c7cc97e06..6e8ffdbff 100644 |
| --- a/docs/superpowers/specs/2026-11-16-video-conversion-design.md |
| +++ b/docs/superpowers/specs/2026-11-16-video-conversion-design.md |
| @@ -1060,6 +1060,13 @@ the outputs. Store destroy gains the refusal of §5.3. |
| - **Residual, as A2.** A tenant who compromises the codec in its own |
| job can report its source as 1080p or less and pay weight 1 for that |
| job. It gains nothing else, and every other bound holds. |
| + - **Mixed versions.** The payload gains `hl` and `dr` and the result |
| + gains `hdr`, and both sides decode strictly, so an older image |
| + refuses a newer console's video payloads and an older console |
| + refuses a newer image's HDR results. No deployment runs the engine |
| + yet; console and image are rolled together from the release that |
| + carries A7 (plan 3: every release builds the image), and a newer |
| + console reads an older image's results. |
| - **Unchanged by the spike:** `video_bytes` 40 GiB, `video_max_hi` 30 |
| minutes, `audio_max` 8 hours, `audio_bytes` 10 GiB, the class rows, |
| `codecHeadroomDB` 0.5, `refuseDolbyVision5` false (no profile 5 sample |
diff --git a/internal/sim/mediajobs/invariants_test.go b/internal/sim/mediajobs/invariants_test.go| index 8fb754ad6..5b00fd4f3 100644 |
| --- a/internal/sim/mediajobs/invariants_test.go |
| +++ b/internal/sim/mediajobs/invariants_test.go |
| @@ -22,7 +22,7 @@ import ( |
| // transaction that writes charged_ms and the terminal state, and |
| // nothing writes charged_ms afterwards. Checked: settled exactly when |
| // terminal; no charge on an unsettled row; a settled row's state, |
| -// charged_ms, source_ms and error never change. |
| +// charged_ms, source_ms, error and weight_tenths never change. |
| // - I3. Never undercharged. charged_ms is at least the time ECS reports |
| // the task ran, or the row's full bound when ECS cannot say. Amended |
| // by A5: this holds for a row whose task was observed (it settled |
| @@ -59,12 +59,15 @@ import ( |
| // 0.1 for audio; a settled row is charged at the weight its row |
| // stores, which is never above that reservation weight and is 2 only |
| // on a long video whose codec reported a source above 1080p. |
| -// - I3 (weight). A long video whose codec reported a source above |
| -// 1080p in a result the job table reads settles at weight 2, unless |
| -// it settled without reading a result: retired before its result was |
| -// read, or engine_lost (no task record, so no result is read and the |
| -// full bound is charged at the weight at or below 1080p). Every other |
| -// charged row settles at its preset's weight at or below 1080p. |
| +// - I3 (weight). A charged row settles at weight 2 exactly when it is a |
| +// long video and the job table read, in the step it settled, a result |
| +// whose source facts its codec wrote above 1080p. Any other charged |
| +// row settles at its preset's weight at or below 1080p: one that |
| +// settled without reading a result (retired before the read, |
| +// engine_lost), one whose result had no facts or did not parse, and |
| +// every short video. The read is recorded by recGrants.ReadResult, so |
| +// a row retired after its result was read (commitDone's retired |
| +// fallback) is held to weight 2 and one retired before it to 1. |
| // - I9. No release while a task might exist (whole-branch review round |
| // 2, A5). A row frees its place (task_stopped false to true) only when |
| // ECS's record shows its task stopped, or no Run of its execution |
| @@ -279,9 +282,9 @@ func check(w *world) { |
| if !p.Settled { |
| continue |
| } |
| - if r, ok := cur[id]; ok && (!r.Settled || r.State != p.State || r.ChargedMS != p.ChargedMS || r.SourceMS != p.SourceMS || r.Error != p.Error) { |
| - w.fail("I2", "settled row %s changed: %s %d ms (source %d, %q) became %s %d ms (source %d, %q), settled %v", |
| - shortID(p.JobID), p.State, p.ChargedMS, p.SourceMS, p.Error, r.State, r.ChargedMS, r.SourceMS, r.Error, r.Settled) |
| + if r, ok := cur[id]; ok && (!r.Settled || r.State != p.State || r.ChargedMS != p.ChargedMS || r.SourceMS != p.SourceMS || r.Error != p.Error || r.WeightTenths != p.WeightTenths) { |
| + w.fail("I2", "settled row %s changed: %s %d ms (source %d, %q, weight %d) became %s %d ms (source %d, %q, weight %d), settled %v", |
| + shortID(p.JobID), p.State, p.ChargedMS, p.SourceMS, p.Error, p.WeightTenths, r.State, r.ChargedMS, r.SourceMS, r.Error, r.WeightTenths, r.Settled) |
| } |
| } |
| @@ -363,14 +366,22 @@ func check(w *world) { |
| } |
| // I3 (weight) and I8 (weight): the weight a charged row settles at. |
| + // A row first seen settled takes the reads of this step as the ones |
| + // its settlement made. |
| for _, r := range rows { |
| - if !r.Settled || r.Execution == "" || (r.State != "done" && r.ChargedMS == 0) { |
| + if !r.Settled || r.Execution == "" { |
| + continue |
| + } |
| + if p, had := w.prev[r.id()]; !had || !p.Settled { |
| + w.readAtEnd[r.Execution] = w.readNow[r.Execution] |
| + } |
| + if r.State != "done" && r.ChargedMS == 0 { |
| continue |
| } |
| longVideo := r.Preset == media.PresetVideo720p && r.Class == media.ClassLong |
| reportedHi := w.reported[r.Execution] && w.hi[r.Execution] |
| want := baseWeight(r.Preset) |
| - if longVideo && reportedHi { |
| + if longVideo && reportedHi && w.readAtEnd[r.Execution] { |
| want = simVideoHiWeight |
| } |
| got := chargedWeight(r) |
| @@ -379,8 +390,8 @@ func check(w *world) { |
| w.fail("I8", "row %s %s is charged at weight %d, over its class's reservation weight %d", shortID(r.JobID), r.State, got, reserveWeight(r)) |
| case got == simVideoHiWeight && !(longVideo && reportedHi): |
| w.fail("I8", "row %s %s is charged at weight %d, and no long-class result reported a source above 1080p", shortID(r.JobID), r.State, got) |
| - case got != want && !((r.Error == media.CodeRetired || r.Error == media.CodeEngineLost) && got == baseWeight(r.Preset)): |
| - w.fail("I3", "row %s %s %q is charged at weight %d, want %d from the source its codec reported", shortID(r.JobID), r.State, r.Error, got, want) |
| + case got != want: |
| + w.fail("I3", "row %s %s %q is charged at weight %d, want %d from the result its settlement read", shortID(r.JobID), r.State, r.Error, got, want) |
| } |
| if p, had := w.prev[r.id()]; had && !p.Settled { |
| switch { |
| @@ -540,6 +551,7 @@ func check(w *world) { |
| } |
| w.prev = cur |
| + w.readNow = map[string]bool{} |
| } |
| // cleanupDue reports whether a row's cleanup is due at now (P1). |
diff --git a/internal/sim/mediajobs/witness_test.go b/internal/sim/mediajobs/witness_test.go| index 3e12fdfc4..2ce5c78c4 100644 |
| --- a/internal/sim/mediajobs/witness_test.go |
| +++ b/internal/sim/mediajobs/witness_test.go |
| @@ -610,6 +610,51 @@ func TestWitnessAbove1080pWeighsTwice(t *testing.T) { |
| } |
| } |
| +// TestWitnessRetiredBeforeAndAfterTheRead (spec §11 A7; Astra round 1, |
| +// P2-1): a long 4K video whose app is retired after the job table read its |
| +// result settles failed retired at weight 2, the weight of the facts it |
| +// read (commitDone's retired fallback); one retired before the read |
| +// settles at weight 1, as no facts were read. |
| +func TestWitnessRetiredBeforeAndAfterTheRead(t *testing.T) { |
| + w := newWitness(t, "", nil) |
| + four := sourcePicture{3840, 2160, true} |
| + |
| + w.object(shop, "uploads/clip-1.mov", 2<<30) |
| + after, task := w.runJob(t, shop, "uploads/clip-1.mov", video, "") |
| + ra := w.rowOf(t, shop, after.ID) |
| + w.now = w.now.Add(5 * time.Minute) |
| + w.codecSucceedsAs(ra.Execution, (5 * time.Minute).Milliseconds(), 0, four) |
| + w.finish(t, task, media.ExitDone) |
| + w.retireOnRead = ra.Execution |
| + w.track(t) |
| + if w.retireOnRead != "" { |
| + t.Fatal("the result was never read") |
| + } |
| + ra = w.rowOf(t, shop, after.ID) |
| + wantRow(t, ra, "failed", media.CodeRetired, (5 * time.Minute).Milliseconds()) |
| + if ra.WeightTenths != 20 { |
| + t.Fatalf("retired after the read: weight %d, want 20", ra.WeightTenths) |
| + } |
| + |
| + blog := appRef{"acct1", "blog"} |
| + w.object(blog, "uploads/clip-2.mov", 2<<30) |
| + before, task2 := w.runJob(t, blog, "uploads/clip-2.mov", video, "") |
| + rb := w.rowOf(t, blog, before.ID) |
| + w.now = w.now.Add(5 * time.Minute) |
| + w.codecSucceedsAs(rb.Execution, (5 * time.Minute).Milliseconds(), 0, four) |
| + w.finish(t, task2, media.ExitDone) |
| + if _, err := w.jobs.Retire(ctx, mj.Scope{Account: blog.Account, App: blog.App}, w.now); err != nil { |
| + t.Fatal(err) |
| + } |
| + w.clean(t) |
| + w.track(t) |
| + rb = w.rowOf(t, blog, before.ID) |
| + wantRow(t, rb, "failed", media.CodeRetired, (5 * time.Minute).Milliseconds()) |
| + if rb.WeightTenths != 10 { |
| + t.Fatalf("retired before the read: weight %d, want 10", rb.WeightTenths) |
| + } |
| +} |
| + |
| // TestWitnessHostileResults (spec §11 A2): durations outside 0 to the |
| // grant fail engine_failed charged ECS's runtime; 0 and 1 ms commit done, |
| // charged by duration, with charged_ms still ECS's 9-minute runtime. |
| @@ -887,16 +932,21 @@ func TestCheckerCatchesEachInvariant(t *testing.T) { |
| t.Fatal(err) |
| } |
| }}, |
| - {"I3", "a long video that reported 4K charged at weight 1", func(t *testing.T, f fixture) { |
| - f.w.reported[f.d.Execution], f.w.hi[f.d.Execution] = true, true |
| - f.w.exec(t, `UPDATE media_jobs SET class = 'long', weight_tenths = 10 WHERE job_id = ?`, f.d.JobID) |
| + {"I3", "a long video settled at weight 1 after reading a 4K result", func(t *testing.T, f fixture) { |
| + x := settledFailed(f, media.ClassLong, 10) |
| + f.w.reported[x.Execution], f.w.hi[x.Execution], f.w.readNow[x.Execution] = true, true, true |
| + f.w.insertRow(x) |
| + }}, |
| + {"I8", "a short video settled at weight 2", func(t *testing.T, f fixture) { |
| + x := settledFailed(f, media.ClassShort, 20) |
| + f.w.reported[x.Execution], f.w.hi[x.Execution], f.w.readNow[x.Execution] = true, true, true |
| + f.w.insertRow(x) |
| }}, |
| - {"I8", "a short video charged at weight 2", func(t *testing.T, f fixture) { |
| - f.w.reported[f.d.Execution], f.w.hi[f.d.Execution] = true, true |
| - f.w.exec(t, `UPDATE media_jobs SET weight_tenths = 20 WHERE job_id = ?`, f.d.JobID) |
| + {"I8", "a long video settled at weight 2 with no report above 1080p", func(t *testing.T, f fixture) { |
| + f.w.insertRow(settledFailed(f, media.ClassLong, 20)) |
| }}, |
| - {"I8", "a long video charged at weight 2 with no report above 1080p", func(t *testing.T, f fixture) { |
| - f.w.exec(t, `UPDATE media_jobs SET class = 'long', weight_tenths = 20 WHERE job_id = ?`, f.d.JobID) |
| + {"I2", "a settled row's stored weight rewritten, its charge the same", func(t *testing.T, f fixture) { |
| + f.w.exec(t, `UPDATE media_jobs SET weight_tenths = 10 WHERE job_id = ?`, f.d.JobID) |
| }}, |
| {"I8", "an execution run on a refused revision", func(t *testing.T, f fixture) { |
| k := media.ClassKey{Preset: audio, Class: media.ClassShort} |
| @@ -923,6 +973,19 @@ func TestCheckerCatchesEachInvariant(t *testing.T) { |
| } |
| } |
| +// settledFailed is a video row of class that failed engine_failed and |
| +// settled at weight, charged 1 s, with no task ever observed (so I3's |
| +// charge checks pass and only the weight is in question). |
| +func settledFailed(f fixture, class string, weight int64) row { |
| + x := f.q |
| + x.Key, x.Class = "uploads/clip-5.mov", class |
| + x.JobID = media.JobID(x.Key, x.ETag, video, class) |
| + x.State, x.Error, x.Execution = "failed", media.CodeEngineFailed, strings.Repeat("6", 32) |
| + x.GrantedS, x.DeadlineS, x.ChargedMS, x.Settled, x.TaskStopped = 600, 900, 1000, true, true |
| + x.EndedAt, x.WeightTenths = f.w.now.UnixMilli(), weight |
| + return x |
| +} |
| + |
| func (w *world) exec(t *testing.T, q string, args ...any) { |
| t.Helper() |
| res, err := w.db.Exec(q, args...) |
diff --git a/internal/sim/mediajobs/world_test.go b/internal/sim/mediajobs/world_test.go| index 954ba05e9..befcd02c6 100644 |
| --- a/internal/sim/mediajobs/world_test.go |
| +++ b/internal/sim/mediajobs/world_test.go |
| @@ -205,6 +205,28 @@ func (g *recGrants) Grant(c context.Context, r media.GrantRequest) (media.Transf |
| return tr, exp, err |
| } |
| +// ReadResult notes each result the job table read whole (the settlement |
| +// that follows takes its weight from it, spec §11 A7) and, when the world |
| +// asks, retires the execution's app right after the read, before the |
| +// settlement commits. |
| +func (g *recGrants) ReadResult(c context.Context, execution string) ([]byte, error) { |
| + b, err := g.FakeGrants.ReadResult(c, execution) |
| + if err == nil { |
| + g.w.readNow[execution] = true |
| + } |
| + if g.w.retireOnRead != "" && g.w.retireOnRead == execution { |
| + g.w.retireOnRead = "" |
| + for _, r := range g.w.readRows() { |
| + if r.Execution == execution { |
| + if _, rerr := g.w.jobs.Retire(c, mj.Scope{Account: r.Account, App: r.App}, g.w.now); rerr != nil { |
| + g.w.fail("MODEL", "retire on read: %v", rerr) |
| + } |
| + } |
| + } |
| + } |
| + return b, err |
| +} |
| + |
| // destroyEvent is a store destroy (or app purge) the world carried out: |
| // Live is the store's rows with task_stopped 0 at that moment. |
| type destroyEvent struct { |
| @@ -239,13 +261,17 @@ type world struct { |
| runs []runRecord |
| grantLog []grantRecord |
| recGrants *recGrants |
| - mayExist map[string]bool // executions with a Run not definitively rejected: a task may exist, or appear later |
| - observed map[string]bool // executions whose task the job table was shown: an ARN from Run, or ListByStartedBy found it |
| - reported map[string]bool // executions whose codec wrote a result that parses, with source facts |
| - hi map[string]bool // of those, the ones whose facts are above 1080p (spec §11 A7) |
| - ecs map[string]media.Task // the last record ECS showed for each execution, kept after it expires |
| - prev map[string]row // the rows at the last check, by rowKey |
| - destroyed []destroyEvent |
| + mayExist map[string]bool // executions with a Run not definitively rejected: a task may exist, or appear later |
| + observed map[string]bool // executions whose task the job table was shown: an ARN from Run, or ListByStartedBy found it |
| + reported map[string]bool // executions whose codec wrote a result that parses, with source facts |
| + hi map[string]bool // of those, the ones whose facts are above 1080p (spec §11 A7) |
| + readNow map[string]bool // executions whose result the job table read since the last check |
| + readAtEnd map[string]bool // executions whose row settled in a check step whose reads included its result |
| + |
| + retireOnRead string // recGrants retires this execution's app once its result has been read (a teardown racing the settlement) |
| + ecs map[string]media.Task // the last record ECS showed for each execution, kept after it expires |
| + prev map[string]row // the rows at the last check, by rowKey |
| + destroyed []destroyEvent |
| trace []string |
| violations []string |
| @@ -271,6 +297,7 @@ func buildWorld(seed int64, rng *rand.Rand, verbose bool, limits media.Limits, a |
| limits: limits, allowance: allow, |
| keys: map[appRef][]string{}, purging: map[appRef]bool{}, |
| mayExist: map[string]bool{}, observed: map[string]bool{}, reported: map[string]bool{}, hi: map[string]bool{}, |
| + readNow: map[string]bool{}, readAtEnd: map[string]bool{}, |
| ecs: map[string]media.Task{}, prev: map[string]row{}, |
| stats: map[string]int{}, done: map[string]int{}, events: map[string]int{}, |
| } |