# Native Needs you and Today

Branch: `native/needs-you`, created from `origin/main` at `eb367315` in an
isolated worktree under the physical TMPDIR. The list/Today checkpoint was
committed as 5f507fb9 before merging main 18fb5be4 normally (merge 3a2fc7a6).
The merge retains both slices' reviewed copy, fixture entry points and UI
schemes; package budgets combine the two additive device projections.
No merge to main, deployment or release is authorized.

## Source rules and scope

Needs you comes from `GET /needs-you`; it remains the badge source, including
set-aside tasks. Today is separate from that count. The existing foreground
event stream reconciles task and card events through session.refresh, which
reads `/snapshot`, `/tasks`, and `/needs-you`. Pull to refresh uses that same
path.

The Today projection uses the existing `/tasks` response. Tasks with live
running or queued steps and no pending decision appear under Running now.
Done tasks whose stable `done_at` falls on the person's local calendar day
appear under Finished today; cancelled and reopened tasks are excluded.
Finished rows sort by done_at then id, newest first; active rows use updated_at.
A later note cannot move a task's completion day. Older server payloads without
done_at still decode, but are not assigned a guessed completion day.

The controller approved optional `wire.Task.done_at` on 2026-11-26 after the
store review showed that PostThread updates updated_at on completed tasks.
The existing DoneAt is mapped to UTC, omitted when unset, and documented in
the generated Task OpenAPI schema. Reopening retains the old DoneAt in the
store; completing again replaces it, following existing transition semantics.
No transition behavior, migration, route, or runner protocol changes.

The server returns the newest 100 tasks by created_at, with no pagination.
The controller accepted this existing web-list window for slice 4 on
2026-11-26. Older active tasks or older tasks completed today can fall outside
it. Follow-up: a bounded device query for active tasks or tasks finished
since a supplied date. No server route is added in this slice.

## Reviewed copy

Approved by Luna through the controller, 2026-11-26:

- `native.needs.running_now`: Running now. Today subsection heading.
- `native.needs.finished_today`: Finished today. Today subsection heading.

`chat.day.today` and `work.needs_empty` are copied byte-identical from the
reviewed web catalog and covered by parity. Native catalog entries use the
existing manual/translated convention; this report and source comments
record the approval provenance.

## Verification

Test-first and mutation results will be recorded here as each guard is built.

Initial list/Today commands:

- `swift test --package-path native/apple --filter NeedsTodayTests`: with
  empty projection/selector stubs, 4 tests failed with 5 assertion issues
  (`needs-you-today-red.log`). Implementation then passed all four
  (`needs-you-today-green.log`).
- `swift test --package-path native/apple --filter NeedsInboxTests`: with
  the badge returning nil, two tests failed with five assertion issues
  (`needs-you-inbox-red.log`). Implementing the optional server inbox count
  passed; the final focused run also covers task-event refresh.
- `swift test --package-path native/apple --filter
  'NeedsTodayTests|NeedsInboxTests'`: 7 tests passed after source restoration
  (`needs-you-list-restored.log`). The event test verifies a refresh updates
  the badge and Today together. The 100-task test verifies the exact returned
  IDs, no inferred older task, the existing `/tasks` route, and bearer use.

The isolated mutation runner (`$TMPDIR/needs-you-mutate.py`) applied each
change separately, ran the focused suites, required a failing assertion
rather than a compile error, and restored the source in `finally`.
All 16 mutations were killed:

- Allow done or cancelled work into Running now (separate mutations).
- Drop the pending-decision exclusion or live-step requirement.
- Ignore running steps, ignore queued steps, or choose the first live step.
- Include non-done tasks in Finished today or ignore the calendar day.
- Use UTC instead of the person's time zone.
- Reverse date order or the stable id tie-break.
- Count all tasks for the badge; add one to the inbox count; turn unknown
  into zero; omit set-aside tasks from the count.

Approved copy is present in both generated catalogs. `check-parity.py`
includes the two newly imported web keys and passes (223 strings at this
pre-slice-3 stage).

Action integration plan (waiting for slice 3): a row derives one action from
its current task/card. Question opens the existing native card; Merge opens
the shared confirmation; retry uses only the row's retry decision (not every
retry option in the full task menu); Resume/Run now use the existing pause
rules and connection revision. Other decisions open the task. Today offers
Undo only through slice 3's receipt, creator, merge provenance and age guards,
with its existing confirmation. No new action authority is inferred from a
row appearing in a list.

## Stable completion time verification

- Before mapping the field, `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test
  ./internal/equipo/chat -run '^TestTaskDoneAt' -count=1` failed with
  `completed task has no done_at` (`needs-you-done-red.log`). The store test
  exercises first completion, a note 48 hours later, reopening, and a second
  completion through the existing saveTask transitions. A separate direct
  projection test checks an offset timestamp is encoded with a UTC Z suffix.
- Before changing Today, the focused Swift suites failed the regression
  contrasting completion time with later notes (`needs-you-done-native-red.log`).
  The native regression also decodes an older payload without done_at and a
  payload with an explicit done_at field, and checks ordering uses completion.
- The implementation passes both focused suites and
  `go test ./internal/plan3test -run '^TestPersonAPIDeviceContract$' -count=1`.
  OpenAPI Task was regenerated from wire schemas; only the optional date-time
  property changed.
- The list checkpoint native gate passed: 275 tests, string parity, both apps.
  Final gates will be repeated after action integration.

Completion-time mutations (each restored; Go command above or the focused
Swift suites): all 15 killed by assertion failures. Remove the field mapping;
map updated_at instead; omit UTC conversion; serialize an unset field; rewrite
DoneAt for a later note; keep the first completion on a second completion;
filter by activity day; sort by activity time; guess a missing completion from
updated_at; drop the done stage; drop the local-day restriction; force UTC day
boundaries; reverse completion ordering; reverse the id tie-break; ignore the
native done_at field. The UTC mutation initially survived because SQLite
normalizes loaded timestamps; the direct projection test now kills it. A
malformed closure mutation was rejected as a compile failure and rerun with a
valid closure; it then failed the intended calendar assertions.

The existing package size exemptions increase by exactly the approved device
field, its projection, and its regressions (wire +2 source lines; chat +4 source
and +102 test lines). No new GET route or performance exemption is needed.

## Paused for slice 3 review fixes

Controller requested pausing slice 4 on 2026-11-26. All source mutations are
restored. Completion-time native checkpoint passed 276 tests and both builds;
the added running-order regression and its two mutations also passed (9 focused
tests after restoration). Linux-targeted make build/vet, staticcheck v0.7.0,
govulncheck v1.8.0, copy release, reference scan, lane check, fmt, spacing,
gitleaks, and corrected size budgets passed. macOS build/vet/staticcheck/
govulncheck hit the existing unix.O_PATH toolproxy compile failure. The full
local make test run was interrupted on the controller's pause request; later
Go targets in that loop have not run. No Linux hub verdict is claimed yet.
The Mac fixture and slice 4 simulator were stopped. Slice 4 remains uncommitted
in its own worktree, awaiting slice 3 integration and final validation.


## Row actions after the main merge

NeedsRowAction follows work_views.go decisionOf and work_parts.html's needs
list, rather than promoting every item in the task menu. A row has one primary
action: its answerable question, its open merge card's Merge choice, Try again
only for retry/review_blocked, Resume for the matched unknown-spend connection,
Run now bound to the current held card or predicted step offer, or Open.
Questions use LiveQuestionCard, including typed answers and remember controls.
Direction, recovery, settings and unknown choices open the task for their full
context. An unknown option keeps the whole decision on the web through the
landed slice 3 fallback. Owner/creator/lifecycle checks reuse TaskDecision and
TaskPause; pause actions also enforce the owner role and merging exclusion.

Each row reads the full task before offering a write. A failed or stale read
falls back to Open. TaskDetailModel sends the action, so Merge retains its
model-level confirmation and card revision, and retry/error handling stays
shared. Resume refetches its connection after conflicts; Run now sends the
shown step revision and connection offer. Every write refreshes the task/list.

The existing task confirmation view is extracted as TaskConfirmationSheet,
shared by task detail, inline Merge and Finished today's Undo. Undo eligibility
and its receipt revision are unchanged from slice 3. Finished rows still use
stable done_at, not later task activity.

Initial row selector tests failed 10 assertions against an Open-only stub.
The initial model tests failed 9 assertions against stub loading/actions.
After implementation, the focused list/action/model and shared task-model run
passed 37 tests. The test fixture was corrected to start a fresh session rather
than merge an empty card array over an already-open fixture merge card; the
Run now assertion uses the API's actual step_revision field.

Commands: `swift test --package-path native/apple --filter NeedsRowActionTests`,
then `--filter NeedsRowModelTests`, then `--filter
'NeedsRowActionTests|NeedsRowModelTests|NeedsTodayTests|NeedsInboxTests|TaskDetailModelTests'`.

The post-merge reference scan matched a retired-name pattern across a new
test's word boundary. Renaming the test fixes the scan without changing its
assertions or adding an exemption.


## Row-action mutations

`python3 "$TMPDIR/needs-you-action-mutate.py"` runs the two focused row suites,
requires assertion failures, and restores each mutation in finally. All 18
mutations were killed after restoration:

- Drop the owner role or merging exclusion.
- Promote every menu retry to a list retry; omit review_blocked; ignore the
  stopped/terminated pause guard.
- Ignore the merge needs state or its offered Merge choice.
- Ignore the held-card needs state or its offered Run now choice.
- Allow a retry to override a selected decision card.
- Offer hold actions after needs_you clears.
- Ignore the matching Resume connection or the resumable step.
- Offer Run now without a predicted offer.
- Ignore the fresh task revision or the failed-read flag.
- Remove the row's busy guard.
- Send Wait when the held-card row shows Run now.

The cleared-hold mutation initially survived. A new regression keeps the
step's hold/offer but clears needs_you, matching an event/refetch race; the row
must then offer Open. The rerun kills the mutation. Earlier slice 1 and 3
creator/lifecycle, retry, connection matching, Undo, confirmation and error
mutations remain covered by the shared helpers' suites. The unchanged list,
completion-time and badge mutations are recorded above.

Local Go verification after merging main: make copy-release-check,
runner-dead-references, lanes-check, fmt-check, spacing, gitleaks, budget and
migration-check passed. Linux-targeted make build and make vet, staticcheck
v0.7.0, and govulncheck passed. Commands used GOTOOLCHAIN=go1.26.11,
CGO_ENABLED=0, and fmt-check used that toolchain's bin directory in PATH.
TestTaskDoneAt and TestPersonAPIDeviceContract passed uncached. The complete
Linux hub run remains the final gate for all make test/performance/runner-host
checks, including the Linux-only toolproxy and namespace checks.


## Final native interaction and visual verification

`native/scripts/check-native.sh` passed after the row/Today polish: 338 tests
in 45 suites, one pre-existing known issue, 329 byte-identical web strings,
and both Mac and iPhone builds. A final repeat also covers the Mac capture
fixture change; its result is retained with the validation evidence.

The NeedsYouUI scheme passed all four simulator tests on
73E0FBCC-185A-4892-889F-150F8DC9729C. It verifies three distinct row actions,
Merge confirmation before submission, the reviewed empty state, running and
finished Today rows, Undo confirmation, and no Undo without its server offer.
Command: `xcodebuild -project native/ios/EquipoPhone.xcodeproj -scheme
NeedsYouUI -configuration Debug -destination 'platform=iOS Simulator,id=73E0FBCC-185A-4892-889F-150F8DC9729C'
-derivedDataPath native/build/Phone -resultBundlePath
"$TMPDIR/needs-you-polish-actions-ui.xcresult" CODE_SIGNING_ALLOWED=NO test`.

Screenshots exported from that result bundle are iphone-needs-you.png,
iphone-today.png, iphone-empty.png and iphone-needs-merge-confirmation.png.
The branch's Debug Mac app supplies mac-needs-you.png, showing the same
three row actions and Today. Its native sidebar is collapsed using the app's
toggle: AppKit bitmap capture does not include the composited sidebar
material. The image captures the real window, including its toolbar; no
image compositing or replacement content is used. The Mac capture is produced
by `native/scripts/build-mac.sh --configuration debug` and launching the
bundle with EQUIPO_NEEDS_FIXTURE=list and EQUIPO_FIXTURE_CAPTURE set.

All images and validation logs are in the audit site's build/slice4 directory.
No new copy questions remain. The 100-task window follow-up remains as noted
above. Linux hub CI is checked after the normal helper push.

## Screenshot review polish

The controller requested consistent clock formatting, no redundant Needs you
badge in its own list, a shared task header on the question row, and completion
time on the status line. Needs you now suppresses only its row badge; other
lists keep it. Questions retain the native answer/set-aside controls beneath
the shared project, title, status and task-opening chevron. The stopped status
line stays: work_parts.html's task-row retains that line, as the controller
confirmed.

The clock regression failed four assertions before the fix: TimeWords used
0:20 in en_IE and en_GB. It now pads 24-hour hours while preserving the locale's
12-hour clock. Completion status uses the same TimeWords. Luna approved
native.needs.done_at = "Done at %@" on 2026-11-26 for unmerged tasks. Merged
tasks use the byte-identical web work.merged pattern and merged.at; without
merge metadata they retain their existing status rather than invent a time.
The new completion-status test failed two assertions against a nil stub.
Both tests pass after implementation. Explicit mutations remove hour padding,
use generic completion words for merges, and use done_at instead of merged.at.
The UI suite additionally checks the question's task header, absence of the
redundant badge, and the reviewed merged-time status.

After screenshot review polish, `native/scripts/check-native.sh` passed with
340 tests in 45 suites, one existing known issue, 330 parity strings, and both
app builds. All three polish mutations were killed. The NeedsYouUI scheme
passed all four tests again (`needs-you-reviewed-ui.xcresult`), and all four
iPhone screenshots plus the Mac screenshot were recaptured and inspected.
The latest evidence supersedes the earlier pre-review screenshots/logs.

## Linux contract-fixture correction

The first Linux hub run on dd5f67df failed check shard 7: TestContractAutoMerge
and TestContractPublishSite rejected the additive done_at field as unexpected.
The other check shards passed; perf was skipped after this failure. The strict
completed-task fixtures had not been updated alongside the projection.
Only task-merged.json and task-published.json now include a UTC completion
timestamp. No production behavior changes in this correction.

`GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/thintest -run
'^(TestContractAutoMerge|TestContractPublishSite)$' -count=1` passes (1.746s).
`python3 native/scripts/check-fixtures.py` passes. The initial failed hub JSON
is retained as validation/ci-first-failure.json. A new normal commit/push
starts a fresh full Linux gate.

## Fable review corrections, 2026-11-26

Review of 2b9e7ef1 found that decision rows had lost Set aside and Undo.
NeedsTaskRow now uses the existing SetAsideButton and AsideStub for merge,
direction and held cards, through the same revision-bound visibility endpoint.
An aside card offers no primary action, including when a previously rendered
button's closure is still available. The existing question card continues to
provide its own answer and visibility controls.

Run now captures the displayed prediction and sends its step, step revision
and offer through the slice 1 task run-now endpoint. It never substitutes the
held card's unbound answer. A changed offer retains api.offer_changed. Resume
and Run now both refresh the inbox and reload the row. The old Resume
connection is cleared before the task read, including when no new resumable
step exists.

Questions render from the card and listed task before GET /tasks/{id}.
A successful inbox refresh advances a row-read generation, so pull-to-refresh
retries a failed detail read even when the task revision has not changed.
Today uses only the last step, excluding copy holds and skip offers, matching
workingNow. A still-running earlier Preview does not put a finished last step
back in Running now.

Correction to the earlier screenshot report: work.merged's second slot is a
commit, not a time. Luna approved native.needs.merged_at =
"Merged into %1$@ at %2$@" (branch, TimeWords time), 2026-11-26. Both native
catalogs use that key; the reviewed web string stays unchanged.

Test-first command:
swift test --package-path native/apple --filter 'NeedsRow|NeedsToday'
The initial run failed on the missing row visibility/read-generation APIs.
The implemented baseline passed 23 tests in four suites. Added tests cover
all three decision kinds, revision-bound Set aside/Undo, an aside primary
action's suppression, question rendering before reads, failed-read recovery,
a stale Resume connection, both post-action refreshes, the shown Run now
offer changing before the tap, and an earlier running step/copy holds.

Review mutation commands:
python3 "$TMPDIR/needs-review-mutate.py"
python3 "$TMPDIR/needs-review-extra-mutate.py"
Each runs the focused suite after one deliberate mutation, requires an
Expectation failed result, and restores the source in finally. The first
13 mutations were killed: missing Set aside control, aside primary action,
aside stub, replacement of the shown offer, missing held-offer guard,
question blocked on read, fixed refresh key, stale Resume retained,
missing inbox refresh, missing row reload, earlier running step selected,
copy hold included, copy skip included. Two more removed the visibility
busy and canSetAside guards and were killed. A stale-tap guard initially
survived because the held-card fixture had no offer; adding its real
prediction makes this a meaningful test of a queued Run now tap after
Set aside. Final result follows below.

All 16 review mutations are killed, including the strengthened stale-tap case.
Restored-source validation:
- native/scripts/check-native.sh: passed; 343 tests in 45 suites, one existing
  known issue; 330 parity strings; both Mac and iPhone Simulator builds.
- xcodebuild -project native/ios/EquipoPhone.xcodeproj -scheme NeedsYouUI
  -configuration Debug -destination 'platform=iOS Simulator,id=F7282573-4021-4BF7-8118-772D452597FF'
  -derivedDataPath native/build/Phone -resultBundlePath
  "$TMPDIR/needs-review-ui-final.xcresult" CODE_SIGNING_ALLOWED=NO test:
  all five tests passed. The initial UI build caught a test query typo
  (XCUIElement versus XCUIElementQuery count), corrected before this run.
- native/scripts/build-mac.sh --configuration debug: passed.

Recaptured and inspected iphone-needs-you.png, iphone-needs-aside.png and
mac-needs-you.png; refreshed Today, empty and merge-confirmation captures too.
The new aside image shows the real native stub and Undo; the ordinary list
shows Set aside on the merge row. Screenshots and mutation/gate logs are in
the audit site's build/slice4 and validation directories. No new copy questions.

## Refresh follow-ups, 2026-11-26

Branch `native/needs-you-followups`, from origin/main `7c113ac8`.
The last matching Resume connection survives task/connection reads and
transient network failures. A changed hold or authoritative connection result,
or a refused task/connection/resume request, clears it. Existing task revision
freshness guards remain in force. A refused Resume clears before its refetch,
so a second tap cannot reuse a rejected pause revision.

Event refreshes no longer bump every row's read key. The task revision drives
row reads; explicit Needs you pull-to-refresh and read-error Retry also bump
the retry generation. Unchanged successfully read rows skip HTTP even then;
failed task or connection reads retry. Resume/Run now retain their forced
post-action task read. Direction Set aside now pins `aside: true` in the actual
request, and Undo pins false.

Test-first commands and evidence:
- `swift test --package-path native/apple --filter 'NeedsFollowupTests|NeedsRowModelTests'`
  failed with 15 assertion issues before the behavioral implementation
  (after correcting a test-only private-setter compilation error).
- Focused restored-source suite including StoppedWorkReviewTests passed 30
  tests before adding the final retry/changed-hold cases.
- `python3 "$TMPDIR/needs-followups-mutate.py"` and
  `python3 "$TMPDIR/needs-followups-extra.py"`: all 14 mutations killed.
  The failed-task retry mutation initially survived because the fixture had
  never loaded successfully. Added a previously successful row whose later
  read fails; the same mutation then failed on read count and recovery.

Mutations: clear before task read; clear before connection read; remove row
revision cache; ignore changed revision; ignore failed task read; ignore
failed connection read; refresh every event; never retry failed rows; retain
refused task connection; retain refused connection response; retain refused
Resume before refetch; retain removed hold; direction Set aside sends false;
retain changed step connection while reading. Each was restored in `finally`;
each killed run contains an assertion failure, not a compiler error.

The gate also imports main's two missing reviewed web reason strings,
`work.reason.merge_credential` and `work.reason.amadan_unreachable`, unchanged.
No new copy and no server behavior changes. Evidence is under the audit site's
`build/slice4/validation/followups/` (red/green logs, mutation scripts/results,
and native gate).

Final `native/scripts/check-native.sh`: passed, 354 tests in 47 suites with
one existing known issue, 332 parity strings, Mac and iPhone Simulator builds.
`git diff --check`: passed. Post-commit reference scan and Linux CI verdict
are recorded with the pushed head in the evidence directory.
