runner: Design reports the pack it launched with; resume only on it
Task 3 review, fix round 1 (spec 8.8).
1. A restarted runner reported its own pack for a commit made under
another. The digest is now recorded on the attempt's row
(steps.pack_digest) before each Design launch, a failed record
refuses the launch (provider_failed), and designReport reports the
recorded value ("" when none was). A failover's advance clears it,
so the next attempt records its own.
2. A resumed session kept its first prompt's pack while reporting the
new one. kept_sessions gains pack_digest, read as
keptSession.Fence (sessionFence{PackDigest}); recordKept writes the
fence the attempt ran under (keepFenced), and fixSession resumes
only when the kept fence equals sessionFenceFor(r). Task 9's forget
revision slots in as a second sessionFence field with its column.
The kept_sessions reads share keptColumns and scanKept.
TestDesignIsClaudeOnly now reports its refused step before the task's
next one, as the engine does (one running attempt per task): the next
step's launch records its pack on its own row.
Tests: TestPackDigestOnEveryDesignReport (recovered under pack A with
pack B installed reports A; nothing recorded reports nothing; a
failover's next attempt inherits nothing), TestPackChangeStartsAFresh
Session (a session kept under another pack is not resumable and the
fix round runs fresh with the current digest).
Run: thin -run 'Design|Prompt|Taste|Ask|Skipped|Fix|PackDigest|
PackChange|Kept|Resum|Session|Pi|Models|Worker|Forget|Advance|Failover|
Refus' ok (571 s); thintest -run 'Design|Fix|Resum' ok; go vet linux
and darwin/arm64 ok; gofmt clean.
Mutations (each alone, restored), all FAILED their test:
- F1 designReport reports the installed pack: nothing-recorded check.
- F2 digest not recorded before launch, F3 advance keeps the old
digest: TestPackDigestOnEveryDesignReport.
- F4 no fence check in fixSession: TestPackChangeStartsAFreshSession.
- F5 session kept with an empty fence, F6 fence not read back:
TestPackChangeStartsAFreshSession and TestFixPromptCarriesAskAndTaste.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+197
−42
internal/runner/thin/ask.go+39 −22internal/runner/thin/design_prompt_linux_test.go+87 −10internal/runner/thin/design_step.go+40 −2internal/runner/thin/design_step_test.go+4 −1internal/runner/thin/engineer.go+15 −4internal/runner/thin/state.go+11 −2internal/runner/thin/step.go+1 −1
diff --git a/internal/runner/thin/ask.go b/internal/runner/thin/ask.go| index 7b7de274..2038d753 100644 |
| --- a/internal/runner/thin/ask.go |
| +++ b/internal/runner/thin/ask.go |
| @@ -51,13 +51,45 @@ type keptSession struct { |
| // Model and Family are what the session was created on (§16.5): a |
| // question or fix round on it runs on that model or not at all. |
| Model, Family string |
| + // Fence is what the session was created under; a fix round resumes |
| + // it only under the same (fixSession). |
| + Fence sessionFence |
| } |
| -// keepSession records a step's kept session once its transcript is in dir. |
| +// sessionFence is what a kept session must match for a fix round to |
| +// resume it: PackDigest, the prompt pack it ran with ("" for none, |
| +// Engineering's), since a resumed session keeps its first prompt's pack |
| +// and a pack edit keeps the profile id (spec 8.8). Fields compared the |
| +// same way go beside it (the notebook's forget revision, spec 8.6), each |
| +// with its kept_sessions column, written once with the session. |
| +type sessionFence struct { |
| + PackDigest string |
| +} |
| + |
| +// keptColumns are a kept_sessions row as scanKept reads it. |
| +const keptColumns = "step_id, attempt, task_id, person, specialist, account, session_id, dir, candidate_sha, bytes, model, family, pack_digest" |
| + |
| +// scanKept reads one row of keptColumns. |
| +func scanKept(row *sql.Row) (keptSession, bool, error) { |
| + var k keptSession |
| + err := row.Scan(&k.StepID, &k.Attempt, &k.TaskID, &k.Person, &k.Specialist, &k.Account, &k.SessionID, &k.Dir, &k.Candidate, &k.Bytes, &k.Model, &k.Family, &k.Fence.PackDigest) |
| + if errors.Is(err, sql.ErrNoRows) { |
| + return k, false, nil |
| + } |
| + return k, err == nil, err |
| +} |
| + |
| +// keepSession records a step's kept session once its transcript is in |
| +// dir, under no fence. |
| func (s *State) keepSession(ctx context.Context, r stepRow, specialist, account, model, family, session, dir, candidate string, bytes int64) error { |
| - // The model and family are written once, with the session: a later |
| - // keep of the same attempt never rebinds them. |
| - _, err := s.db.ExecContext(ctx, "INSERT INTO kept_sessions(step_id, attempt, task_id, person, specialist, account, session_id, dir, candidate_sha, bytes, created_at, used_at, model, family) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?) ON CONFLICT(step_id, attempt) DO UPDATE SET session_id=excluded.session_id, dir=excluded.dir, candidate_sha=excluded.candidate_sha, bytes=excluded.bytes, used_at=excluded.used_at", r.StepID, r.Attempt, r.TaskID, r.Person, specialist, account, session, dir, candidate, bytes, now(), now(), model, family) |
| + return s.keepFenced(ctx, r, sessionFence{}, specialist, account, model, family, session, dir, candidate, bytes) |
| +} |
| + |
| +// keepFenced records a step's kept session and the fence it ran under. |
| +func (s *State) keepFenced(ctx context.Context, r stepRow, fence sessionFence, specialist, account, model, family, session, dir, candidate string, bytes int64) error { |
| + // The model, family and fence are written once, with the session: a |
| + // later keep of the same attempt never rebinds them. |
| + _, err := s.db.ExecContext(ctx, "INSERT INTO kept_sessions(step_id, attempt, task_id, person, specialist, account, session_id, dir, candidate_sha, bytes, created_at, used_at, model, family, pack_digest) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ON CONFLICT(step_id, attempt) DO UPDATE SET session_id=excluded.session_id, dir=excluded.dir, candidate_sha=excluded.candidate_sha, bytes=excluded.bytes, used_at=excluded.used_at", r.StepID, r.Attempt, r.TaskID, r.Person, specialist, account, session, dir, candidate, bytes, now(), now(), model, family, fence.PackDigest) |
| return err |
| } |
| @@ -87,22 +119,12 @@ func (s *State) setKeptCandidate(ctx context.Context, r stepRow, sha string) err |
| // keptSessionFor is the newest kept session of a step. |
| func (s *State) keptSessionFor(ctx context.Context, stepID string) (keptSession, bool, error) { |
| - var k keptSession |
| - err := s.db.QueryRowContext(ctx, "SELECT step_id, attempt, task_id, person, specialist, account, session_id, dir, candidate_sha, bytes, model, family FROM kept_sessions WHERE step_id=? ORDER BY attempt DESC LIMIT 1", stepID).Scan(&k.StepID, &k.Attempt, &k.TaskID, &k.Person, &k.Specialist, &k.Account, &k.SessionID, &k.Dir, &k.Candidate, &k.Bytes, &k.Model, &k.Family) |
| - if errors.Is(err, sql.ErrNoRows) { |
| - return k, false, nil |
| - } |
| - return k, err == nil, err |
| + return scanKept(s.db.QueryRowContext(ctx, "SELECT "+keptColumns+" FROM kept_sessions WHERE step_id=? ORDER BY attempt DESC LIMIT 1", stepID)) |
| } |
| // keptAttempt is the session one attempt of a step kept. |
| func (s *State) keptAttempt(ctx context.Context, stepID string, attempt int64) (keptSession, bool, error) { |
| - var k keptSession |
| - err := s.db.QueryRowContext(ctx, "SELECT step_id, attempt, task_id, person, specialist, account, session_id, dir, candidate_sha, bytes, model, family FROM kept_sessions WHERE step_id=? AND attempt=?", stepID, attempt).Scan(&k.StepID, &k.Attempt, &k.TaskID, &k.Person, &k.Specialist, &k.Account, &k.SessionID, &k.Dir, &k.Candidate, &k.Bytes, &k.Model, &k.Family) |
| - if errors.Is(err, sql.ErrNoRows) { |
| - return k, false, nil |
| - } |
| - return k, err == nil, err |
| + return scanKept(s.db.QueryRowContext(ctx, "SELECT "+keptColumns+" FROM kept_sessions WHERE step_id=? AND attempt=?", stepID, attempt)) |
| } |
| // keptForAsk is the kept session a question resumes: exactly the |
| @@ -124,12 +146,7 @@ func (s *State) keptForAsk(ctx context.Context, a wire.AskCommand) (k keptSessio |
| // keptCommit is the newest kept session of the task's specialist (for |
| // the person) that made or judged the commit sha. |
| func (s *State) keptCommit(ctx context.Context, task, person, specialist, sha string) (keptSession, bool, error) { |
| - var k keptSession |
| - err := s.db.QueryRowContext(ctx, "SELECT step_id, attempt, task_id, person, specialist, account, session_id, dir, candidate_sha, bytes, model, family FROM kept_sessions WHERE task_id=? AND person=? AND specialist=? AND candidate_sha=? ORDER BY created_at DESC, attempt DESC LIMIT 1", task, person, specialist, sha).Scan(&k.StepID, &k.Attempt, &k.TaskID, &k.Person, &k.Specialist, &k.Account, &k.SessionID, &k.Dir, &k.Candidate, &k.Bytes, &k.Model, &k.Family) |
| - if errors.Is(err, sql.ErrNoRows) { |
| - return k, false, nil |
| - } |
| - return k, err == nil, err |
| + return scanKept(s.db.QueryRowContext(ctx, "SELECT "+keptColumns+" FROM kept_sessions WHERE task_id=? AND person=? AND specialist=? AND candidate_sha=? ORDER BY created_at DESC, attempt DESC LIMIT 1", task, person, specialist, sha)) |
| } |
| func (s *State) touchKept(ctx context.Context, k keptSession, bytes int64) error { |
diff --git a/internal/runner/thin/design_prompt_linux_test.go b/internal/runner/thin/design_prompt_linux_test.go| index 672c0a68..e46cfbb6 100644 |
| --- a/internal/runner/thin/design_prompt_linux_test.go |
| +++ b/internal/runner/thin/design_prompt_linux_test.go |
| @@ -10,6 +10,15 @@ import ( |
| "amadan.net/oficina/equipo/internal/wire" |
| ) |
| +// finish reports row's attempt as the engine does, so the task's next |
| +// step can be accepted (one running attempt per task). |
| +func (r *designRig) finish(row stepRow, rep wire.StepReport) { |
| + r.t.Helper() |
| + if err := r.e.O.State.ReportStep(r.ctx, row, rep); err != nil { |
| + r.t.Fatal(err) |
| + } |
| +} |
| + |
| // TestFixPromptCarriesAskAndTaste (spec 8.6, Feeding): a Design fix |
| // round that resumes the session of the round before, through |
| // engineer.go's resume path, hands that session a message carrying the |
| @@ -20,10 +29,12 @@ import ( |
| func TestFixPromptCarriesAskAndTaste(t *testing.T) { |
| r := newDesignRig(t) |
| r.e.Note = designNote |
| - rep := r.exec(stepRow{DispatchCommand: designDispatch("ds1", 1)}) |
| + first := stepRow{DispatchCommand: designDispatch("ds1", 1)} |
| + rep := r.exec(first) |
| if rep.State != wire.StepDone || !rep.Pushed { |
| t.Fatalf("round 0: %+v", rep) |
| } |
| + r.finish(first, rep) |
| p, _ := specialist.Lookup(specialist.ProfileDesign) |
| if p.Pack == "" || rep.PackDigest != p.Pack { |
| t.Fatalf("round 0 ran with pack %q, pinned %q", rep.PackDigest, p.Pack) |
| @@ -80,24 +91,90 @@ func TestDesignPromptCarriesTasteAndAsk(t *testing.T) { |
| } |
| // TestPackDigestOnEveryDesignReport (spec 8.8): an attempt that ran and |
| -// failed reports the pack it ran with, and so does a report a restarted |
| -// runner finishes for a commit made earlier (designReport); an |
| -// Engineering report never carries one. |
| +// failed reports the pack it ran with, recorded on its row before the |
| +// launch; a report a restarted runner finishes for a commit made |
| +// earlier (designReport) reports the pack recorded then, not the one |
| +// installed now, and nothing when none was recorded; a failover's next |
| +// attempt inherits none; an Engineering report never carries one. |
| func TestPackDigestOnEveryDesignReport(t *testing.T) { |
| p, _ := specialist.Lookup(specialist.ProfileDesign) |
| r := newDesignRig(t) |
| r.e.Note = " say:nothing changed\n" |
| - rep := r.exec(stepRow{DispatchCommand: designDispatch("ds1", 1)}) |
| + row := stepRow{DispatchCommand: designDispatch("ds1", 1)} |
| + rep := r.exec(row) |
| if rep.State != wire.StepFailed || rep.PackDigest != p.Pack { |
| t.Fatalf("a failed attempt: %s %q", rep.State, rep.PackDigest) |
| } |
| - e := &Engineer{} |
| + if got, err := r.e.O.State.stepPackDigest(r.ctx, row); err != nil || got != p.Pack { |
| + t.Fatalf("recorded %q %v", got, err) |
| + } |
| + r.finish(row, rep) |
| + // Committed under an older pack A, recovered by a runner holding B. |
| + older := strings.Repeat("a", 64) |
| + recovered := stepRow{DispatchCommand: designDispatch("ds2", 1)} |
| + if err := r.e.O.State.AcceptDispatch(r.ctx, "d-ds2", recovered.DispatchCommand); err != nil { |
| + t.Fatal(err) |
| + } |
| failed := wire.StepReport{TaskID: "tk1", StepID: "ds2", Attempt: 1, State: wire.StepFailed, Reason: "push_failed"} |
| - if got := e.designReport(context.Background(), stepRow{DispatchCommand: designDispatch("ds2", 1)}, failed, phaseCommitted); got.PackDigest != p.Pack { |
| - t.Fatalf("a restarted commit's report: %q", got.PackDigest) |
| + if got := r.e.designReport(r.ctx, recovered, failed, phaseCommitted); got.PackDigest != "" { |
| + t.Fatalf("nothing recorded, reported %q", got.PackDigest) |
| + } |
| + if err := r.e.O.State.setStepPackDigest(r.ctx, recovered, older); err != nil { |
| + t.Fatal(err) |
| } |
| - plain := stepRow{DispatchCommand: wire.DispatchCommand{Person: connPerson, TaskID: "tk1", StepID: "s3", Attempt: 1, Specialist: wire.SpecialistEngineering}} |
| - if got := e.designReport(context.Background(), plain, failed, phaseCommitted); got.PackDigest != "" { |
| + if got := r.e.designReport(r.ctx, recovered, failed, phaseCommitted); got.PackDigest != older { |
| + t.Fatalf("a recovered commit reports %q, it ran with %q", got.PackDigest, older) |
| + } |
| + // A failover's next attempt has recorded nothing yet: it reports no |
| + // pack until its own launch records one. |
| + next := recovered |
| + if err := r.e.O.State.advanceStep(r.ctx, &next, nil, failed); err != nil || next.Attempt != 2 { |
| + t.Fatalf("advance %v %d", err, next.Attempt) |
| + } |
| + if got, err := r.e.O.State.stepPackDigest(r.ctx, next); err != nil || got != "" { |
| + t.Fatalf("the next attempt inherited %q %v", got, err) |
| + } |
| + plain := stepRow{DispatchCommand: wire.DispatchCommand{Person: connPerson, TaskID: "tk1", StepID: "ds2", Attempt: 1, Specialist: wire.SpecialistEngineering}} |
| + if got := r.e.designReport(r.ctx, plain, failed, phaseCommitted); got.PackDigest != "" { |
| t.Fatalf("Engineering's report: %q", got.PackDigest) |
| } |
| } |
| + |
| +// TestPackChangeStartsAFreshSession (spec 8.8): a Design fix round |
| +// resumes the kept session only when it was made with the pack |
| +// installed now; a session kept under another pack (a pack edit since) |
| +// is not resumed, and the round starts afresh with the current pack in |
| +// its first prompt. |
| +func TestPackChangeStartsAFreshSession(t *testing.T) { |
| + p, _ := specialist.Lookup(specialist.ProfileDesign) |
| + r := newDesignRig(t) |
| + r.e.Note = designNote |
| + first := stepRow{DispatchCommand: designDispatch("ds1", 1)} |
| + rep := r.exec(first) |
| + if rep.State != wire.StepDone || !rep.Pushed { |
| + t.Fatalf("round 0: %+v", rep) |
| + } |
| + r.finish(first, rep) |
| + k, found, err := r.e.O.State.keptCommit(r.ctx, "tk1", connPerson, wire.SpecialistEngineering, rep.CandidateSHA) |
| + if err != nil || !found || k.Fence != (sessionFence{PackDigest: p.Pack}) { |
| + t.Fatalf("kept %+v %v %v", k, found, err) |
| + } |
| + d := designDispatch("ds2", 1) |
| + d.Round, d.BaseSHA, d.Feedback = 1, rep.CandidateSHA, "Fix round 1 of 2. Review asked for more." |
| + row := stepRow{DispatchCommand: d, Base: rep.CandidateSHA} |
| + if _, ok := r.e.fixSession(r.ctx, row, row.Base); !ok { |
| + t.Fatal("the same pack's session is not resumable") |
| + } |
| + // The session was made under another pack. |
| + if _, err := r.e.O.State.db.ExecContext(r.ctx, "UPDATE kept_sessions SET pack_digest=? WHERE step_id=?", strings.Repeat("a", 64), "ds1"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, ok := r.e.fixSession(r.ctx, row, row.Base); ok { |
| + t.Fatal("another pack's session is resumable") |
| + } |
| + r.e.Note = " create:mockups/tk1/more/index.html|<h1>More</h1>\n" |
| + fix := r.exec(row) |
| + if fix.State != wire.StepDone || strings.Contains(fix.Summary, "(resumed session)") || fix.PackDigest != p.Pack { |
| + t.Fatalf("round 1 resumed another pack's session: %+v", fix) |
| + } |
| +} |
diff --git a/internal/runner/thin/design_step.go b/internal/runner/thin/design_step.go| index 713f73bc..35041a1b 100644 |
| --- a/internal/runner/thin/design_step.go |
| +++ b/internal/runner/thin/design_step.go |
| @@ -228,8 +228,13 @@ func (e *Engineer) designReport(ctx context.Context, r stepRow, rep wire.StepRep |
| if !design || refusal != "" { |
| return rep |
| } |
| - // The attempt ran with the pinned pack (designBinding checked it). |
| - rep.PackDigest = designPackDigest() |
| + // The pack the attempt was launched with, as recorded then: a |
| + // runner restarted since may hold another ("" when none was). |
| + digest, err := e.O.State.stepPackDigest(context.WithoutCancel(ctx), r) |
| + if err != nil { |
| + e.log("design pack", err) |
| + } |
| + rep.PackDigest = digest |
| if rep.State != wire.StepDone || !rep.Pushed || phase == phaseCommittedUnfinished { |
| return rep |
| } |
| @@ -547,6 +552,39 @@ func designPackDigest() string { |
| return p.Pack |
| } |
| +// sessionFenceFor is the fence r's attempt runs under: a Design step's |
| +// pack digest; Engineering's none. |
| +func sessionFenceFor(r stepRow) sessionFence { |
| + if r.Profile == specialist.ProfileDesign { |
| + return sessionFence{PackDigest: designPackDigest()} |
| + } |
| + return sessionFence{} |
| +} |
| + |
| +// setStepPackDigest records, before its launch, the pack r's attempt |
| +// runs with. |
| +func (s *State) setStepPackDigest(ctx context.Context, r stepRow, digest string) error { |
| + res, err := s.db.ExecContext(ctx, "UPDATE steps SET pack_digest=? WHERE step_id=? AND attempt=?", digest, r.StepID, r.Attempt) |
| + if err != nil { |
| + return err |
| + } |
| + if n, _ := res.RowsAffected(); n != 1 { |
| + return fmt.Errorf("design: step %s is not here", r.key()) |
| + } |
| + return nil |
| +} |
| + |
| +// stepPackDigest is the pack r's attempt was launched with ("" when none |
| +// was recorded). |
| +func (s *State) stepPackDigest(ctx context.Context, r stepRow) (string, error) { |
| + var digest string |
| + err := s.db.QueryRowContext(ctx, "SELECT pack_digest FROM steps WHERE step_id=? AND attempt=?", r.StepID, r.Attempt).Scan(&digest) |
| + if errors.Is(err, sql.ErrNoRows) { |
| + return "", nil |
| + } |
| + return digest, err |
| +} |
| + |
| // designPack is design-v1's pack while it matches its pin. |
| func designPack() (string, bool) { |
| p, ok := specialist.Lookup(specialist.ProfileDesign) |
diff --git a/internal/runner/thin/design_step_test.go b/internal/runner/thin/design_step_test.go| index 4d616567..be805293 100644 |
| --- a/internal/runner/thin/design_step_test.go |
| +++ b/internal/runner/thin/design_step_test.go |
| @@ -399,10 +399,13 @@ func TestDesignIsClaudeOnly(t *testing.T) { |
| if got := r.e.notClaude(r.ctx, connPerson); len(got) != 1 || got[0] != "codex-a" { |
| t.Fatalf("avoid %v", got) |
| } |
| - rep := r.exec(stepRow{DispatchCommand: designDispatch("ds4", 1)}) |
| + refused := stepRow{DispatchCommand: designDispatch("ds4", 1)} |
| + rep := r.exec(refused) |
| if rep.State != wire.StepFailed || rep.Reason != "policy_rejected" || rep.LogTail != designNoClaude { |
| t.Fatalf("Codex only: %+v", rep) |
| } |
| + // Reported as the engine does, so the task's next step is accepted. |
| + r.finish(refused, rep) |
| write(codex, bs[0]) |
| if got := r.e.notClaude(r.ctx, connPerson); len(got) != 1 || got[0] != "codex-a" { |
| t.Fatalf("avoid with both %v", got) |
diff --git a/internal/runner/thin/engineer.go b/internal/runner/thin/engineer.go| index d3ff5f75..6ed06583 100644 |
| --- a/internal/runner/thin/engineer.go |
| +++ b/internal/runner/thin/engineer.go |
| @@ -375,9 +375,15 @@ func (e *Engineer) Exec(ctx context.Context, r stepRow, progress func(wire.StepR |
| } |
| } |
| if design { |
| - // The pack this attempt runs with (spec 8.8), on every |
| - // report from here on. |
| - rep.PackDigest = designPackDigest() |
| + // The pack this attempt runs with (spec 8.8), recorded |
| + // before its launch so a restarted runner reports it, and on |
| + // every report from here on. |
| + digest := designPackDigest() |
| + if err := e.O.State.setStepPackDigest(ctx, r, digest); err != nil { |
| + e.log("design pack", err) |
| + return fail("provider_failed", true) |
| + } |
| + rep.PackDigest = digest |
| } |
| res = e.run(ctx, r, tree, spec) |
| if res.reason == reasonHeld { |
| @@ -546,7 +552,7 @@ func (e *Engineer) recordKept(ctx context.Context, r stepRow, b runner.AccountBi |
| // The session's model and family, bound for its questions and fix |
| // rounds (§16.5): the model it ran, as the harness reported it. |
| family := firstNonEmpty(res.family, b.Family) |
| - if err := e.O.State.keepSession(context.WithoutCancel(ctx), r, r.Specialist, b.LocalID, b.Model, family, res.session, e.keepDir(r), candidate, res.kept); err != nil { |
| + if err := e.O.State.keepFenced(context.WithoutCancel(ctx), r, sessionFenceFor(r), r.Specialist, b.LocalID, b.Model, family, res.session, e.keepDir(r), candidate, res.kept); err != nil { |
| e.log("kept sessions", err) |
| return false |
| } |
| @@ -1081,6 +1087,11 @@ func (e *Engineer) fixSession(ctx context.Context, r stepRow, base string) (kept |
| if !found { |
| return keptSession{}, false |
| } |
| + // A session made under another fence (a pack edit since) starts |
| + // afresh: resuming it would keep its first prompt's pack. |
| + if k.Fence != sessionFenceFor(r) { |
| + return keptSession{}, false |
| + } |
| // Claude's transcript, or Pi's (a session kept on a metered |
| // connection). |
| if _, err := os.Stat(keptTranscript(k.Dir, k.SessionID)); err != nil && !hasKeptSession(k.Dir, k.SessionID) { |
diff --git a/internal/runner/thin/state.go b/internal/runner/thin/state.go| index 302d48da..33b08f81 100644 |
| --- a/internal/runner/thin/state.go |
| +++ b/internal/runner/thin/state.go |
| @@ -105,8 +105,10 @@ func OpenState(ctx context.Context, dir string) (*State, error) { |
| // render_audit: its render_page calls' records (branch review 8). |
| // outcome: what a worker's Engineering commit is (wire.Outcome*), kept |
| // apart from its progress phase, and worker_report the final report a |
| - // restart sends again (Mac runners slice F). |
| - for _, col := range []string{"ns_id", "final_state", "final_reason", "not_before", "deferred_since", "design_options", "render_audit", "outcome", "worker_report"} { |
| + // restart sends again (Mac runners slice F). pack_digest: the pack a |
| + // Design attempt was launched with, recorded before its launch (spec |
| + // 8.8), so a restarted runner reports that one, not its own. |
| + for _, col := range []string{"ns_id", "final_state", "final_reason", "not_before", "deferred_since", "design_options", "render_audit", "outcome", "worker_report", "pack_digest"} { |
| if _, err = d.ExecContext(ctx, "ALTER TABLE steps ADD COLUMN "+col+" TEXT NOT NULL DEFAULT ''"); err != nil && !strings.Contains(err.Error(), "duplicate column") { |
| d.Close() |
| return nil, err |
| @@ -128,6 +130,13 @@ func OpenState(ctx context.Context, dir string) (*State, error) { |
| d.Close() |
| return nil, err |
| } |
| + // Added with Design feedback (spec 8.8): the pack a kept session ran |
| + // with, part of its sessionFence. Its later fields (the notebook's |
| + // forget revision) get their columns here beside it. |
| + if _, err = d.ExecContext(ctx, "ALTER TABLE kept_sessions ADD COLUMN pack_digest TEXT NOT NULL DEFAULT ''"); err != nil && !strings.Contains(err.Error(), "duplicate column") { |
| + d.Close() |
| + return nil, err |
| + } |
| // Added in Connections slice 1 review round 2: the home a sign-out |
| // still has to delete, and its provider, kept until it is gone. |
| for _, col := range []string{"home", "provider"} { |
diff --git a/internal/runner/thin/step.go b/internal/runner/thin/step.go| index b02f2066..d5bb3f31 100644 |
| --- a/internal/runner/thin/step.go |
| +++ b/internal/runner/thin/step.go |
| @@ -423,7 +423,7 @@ func (s *State) advanceStep(ctx context.Context, r *stepRow, used []wire.Usage, |
| return err |
| } |
| } |
| - res, err := t.Exec("UPDATE steps SET attempt=attempt+1, body=?, phase='', ns_id='' WHERE step_id=? AND attempt=? AND state=?", string(body), r.StepID, r.Attempt, runRunning) |
| + res, err := t.Exec("UPDATE steps SET attempt=attempt+1, body=?, phase='', ns_id='', pack_digest='' WHERE step_id=? AND attempt=? AND state=?", string(body), r.StepID, r.Attempt, runRunning) |
| if err != nil { |
| return err |
| } |