Merge branch 'main' into flutter/s1-list
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
# P2a — graph domain: nodes, edges, terminals, run evidence and stage visits
|
||||
|
||||
## What changed
|
||||
|
||||
New, app-only, pure-Dart files. No server, web client, legacy client, shell,
|
||||
`main.dart`, pubspec, other feature or platform source was edited.
|
||||
|
||||
| File | Lines | Responsibility |
|
||||
| --- | --- | --- |
|
||||
| `lib/features/graph/domain/graph_protocol.dart` | 43 | terminal constants, `resolveTarget`, terminal labels |
|
||||
| `lib/features/graph/domain/graph_definition.dart` | 152 | outcome/edge order, definition edges, definition nodes |
|
||||
| `lib/features/graph/domain/run_graph_state.dart` | 124 | recorded visited stages/routes, current-stage fallback, live start |
|
||||
| `lib/features/graph/domain/stage_visits.dart` | 107 | sequence-ordered visits, display visit, clamped visit selection |
|
||||
| `test/features/graph/domain/graph_fixtures.dart` | 96 | linear/diamond/self-loop/incomplete definitions and step fixtures |
|
||||
| `test/features/graph/domain/graph_protocol_test.dart` | 56 | shorthand and terminal-label regressions |
|
||||
| `test/features/graph/domain/graph_definition_test.dart` | 229 | edge order/ids, loops, duplicate keys, missing/unknown targets |
|
||||
| `test/features/graph/domain/run_graph_state_test.dart` | 170 | linear/diamond/self-loop/repeated visits/outcomes/terminals/no evidence |
|
||||
| `test/features/graph/domain/run_graph_state_live_test.dart` | 91 | current/last-stage fallback, live start, finished run |
|
||||
| `test/features/graph/domain/stage_visits_test.dart` | 150 | repeated visits by sequence, latest default, clamping, absent visit |
|
||||
|
||||
No layout, coordinates, widgets, styles or rendering were added.
|
||||
|
||||
## Behavior copied from the current web client
|
||||
|
||||
- **Terminals and `#`** (`web/src/protocol.js`): `#success`, `#failure`,
|
||||
`isTerminal` only for the explicit keys, and `resolveTarget`: a bare `#`
|
||||
becomes `#failure` for the `error` outcome and `#success` for every other
|
||||
outcome. All other values are preserved verbatim, including `""` and unknown
|
||||
stage keys. A missing target stays `null`, never a fabricated terminal.
|
||||
- **Labels** (`web/src/graph.js`): `nodeDisplayLabel` gives `Success` /
|
||||
`Failure` for graph nodes; `nodeLabel` gives the TUI-mirroring `SUCCESS` /
|
||||
`FAILURE`. Stage keys are unchanged.
|
||||
- **Definition edges** (`web/src/graph.js`): outcomes are success first, other
|
||||
outcomes alphabetical, `error` last; stages keep declaration order; ids are
|
||||
contiguous in that order; the label carries `error*` only when
|
||||
`fallback_error` is true. A `null` edge value declares no edge and is
|
||||
skipped. Empty/unknown targets are kept, with `knownTarget == false`.
|
||||
- **Definition nodes** (`web/src/graph.js` `layoutGraph`): stage nodes keep
|
||||
declaration order and one identity per key; terminal nodes are appended
|
||||
failure then success once any declared edge resolves to a terminal. These
|
||||
are definition nodes only, never run evidence.
|
||||
- **Run evidence** (`web/src/runDetail.js` `runGraphState`): visited stages in
|
||||
first-appearance order without duplicates; routes keyed
|
||||
`source\0outcome\0resolvedTarget` without duplicates; only a resolved
|
||||
terminal is visited by its target; a non-terminal target is not visited until
|
||||
a step lands there. Current stage is `current_stage` when non-blank, else the
|
||||
last recorded step's stage, else `null`. A start timestamp is read only while
|
||||
executing, for a `running` visit of the current stage.
|
||||
- **Visits** (`web/src/runDetail.js` `runTimeline`, `clampVisitIndex`,
|
||||
`displayVisit`, and `web/src/app.js` stage routing): visits are grouped by
|
||||
stage and ordered by recorded sequence with stable ties; the display visit
|
||||
is a positive `control.visit`, else position + 1; no requested visit selects
|
||||
the stage's most recent visit; an explicit index clamps to `[0, count)`; a
|
||||
stage with no recorded visit yields `step == null`.
|
||||
|
||||
The run map is the same detail the runs feature already holds; this slice only
|
||||
reads `steps`, so it adds no second event fold. Live-event merging remains in
|
||||
`lib/features/runs/domain/run_step_evidence.dart` and `run_events.dart`.
|
||||
|
||||
## Honest edge handling
|
||||
|
||||
- A missing/`null` definition edge produces no edge and no node.
|
||||
- An empty or unknown target is returned as recorded, flagged `knownTarget:
|
||||
false`; it never becomes a stage node or terminal and never produces a
|
||||
visited stage.
|
||||
- A blank recorded stage key is not turned into an empty visited identity. A
|
||||
step with a blank outcome or target records no route and no terminal visit.
|
||||
- Self edges and loops record one route and one node identity; nothing recurses.
|
||||
- A stage with no recorded visits cannot be presented as visited: selection
|
||||
exposes a null step rather than synthesizing one.
|
||||
|
||||
## Checks actually run
|
||||
|
||||
```
|
||||
flutter pub get
|
||||
dart format lib/features/graph test/features/graph # 10 files, 0 changed after formatting
|
||||
flutter test test/features/graph/domain # 41 passed
|
||||
flutter analyze # No issues found! (0.8s)
|
||||
flutter test # 139 passed
|
||||
```
|
||||
|
||||
Focused coverage is the requested matrix:
|
||||
|
||||
- **Linear**: plan -> build -> ship, contiguous ids, implicit `error*`
|
||||
fallback, terminals.
|
||||
- **Diamond**: fan-out/fan-in edges stay distinct and ordered; converging
|
||||
routes do not merge.
|
||||
- **Self loop**: `a/retry -> a` is one edge and one node identity; one run
|
||||
self-loop is one route and one visited stage.
|
||||
- **Repeated stage**: repeated visits remain separate ordered entries; visited
|
||||
stage identity is not duplicated; repeated identical routes collapse.
|
||||
- **Different outcomes**: success/approved/rejected routes to the same target
|
||||
remain distinct.
|
||||
- **Terminals**: bare `#` resolves by outcome, explicit terminals normalize,
|
||||
labels are `SUCCESS`/`FAILURE`, mid-run targets do not fabricate visits.
|
||||
- **Missing evidence**: null/absent/malformed steps and graphs yield empty
|
||||
evidence, no terminals and no fabricated visits.
|
||||
|
||||
## Honest limits
|
||||
|
||||
- **No UI, layout or wiring.** This is deliberately the nonvisual foundation
|
||||
slice; the native graph screen, layout, highlighting and interaction are
|
||||
later work and are not claimed here.
|
||||
- **No browser evidence.** A nonvisual pure-Dart change has no rendered
|
||||
behavior to capture; no browser or screenshot check applies.
|
||||
- **No live server or device used.** All tests use local fixtures. No run,
|
||||
pipeline, schedule, workflow or service was created, changed or restarted.
|
||||
- **Mobile unverified.** Only web-targeted Flutter tests and analysis ran; no
|
||||
Android/iOS build, emulator, ADB or device.
|
||||
- **Committed, not deployed.** The reviewed slice is commit `2c10507` on
|
||||
`flutter/p2-model`; current `main` was merged in after review (final merge
|
||||
`f07ada0`, which includes `main` `e8bde4f`). No push, install, preview server
|
||||
or canonical-URL change was made by this landing stage; server-side checks and
|
||||
the actual land follow.
|
||||
@@ -0,0 +1,100 @@
|
||||
# P2b — deterministic pure node layout
|
||||
|
||||
## What changed
|
||||
|
||||
New app-only, pure-Dart files. No existing file, server, web client, legacy
|
||||
client, shell, `main.dart`, pubspec, other feature or platform source was edited.
|
||||
|
||||
| File | Lines | Responsibility |
|
||||
| --- | --- | --- |
|
||||
| `lib/features/graph/layout/layout_models.dart` | 127 | measured extents, gap config, immutable node box, layout + ranks |
|
||||
| `lib/features/graph/layout/graph_ranks.dart` | 191 | deterministic SCC ranks over the landed definition nodes/edges |
|
||||
| `lib/features/graph/layout/graph_node_layout.dart` | 142 | column/row placement, bounds, validation |
|
||||
| `test/features/graph/layout/layout_fixtures.dart` | 102 | shared definitions and measured extents |
|
||||
| `test/features/graph/layout/graph_ranks_test.dart` | 116 | linear/diamond/cycle/self-loop/disconnected/unknown/long-chain ranks |
|
||||
| `test/features/graph/layout/graph_node_layout_test.dart` | 224 | ordering, terminals, heterogeneous and expanded extents, bounds, determinism |
|
||||
| `test/features/graph/layout/graph_layout_validation_test.dart` | 96 | empty input, missing/extra measurements, duplicate keys, invalid sizes |
|
||||
|
||||
No layout widgets, painters, edge routing, styling or shell wiring were added.
|
||||
|
||||
## Public API
|
||||
|
||||
```dart
|
||||
GraphRanks assignGraphRanks(List<GraphNode> nodes, List<GraphEdge> edges);
|
||||
|
||||
GraphLayout layoutGraphNodes({
|
||||
required List<GraphNode> nodes,
|
||||
required List<GraphEdge> edges,
|
||||
required Map<String, NodeExtent> extents,
|
||||
required GraphLayoutConfig config,
|
||||
});
|
||||
```
|
||||
|
||||
`NodeExtent` is the caller's measured width/height after text layout.
|
||||
`GraphLayoutConfig` takes `columnGap`, `rowGap` and an optional outer `padding`.
|
||||
No node size, font, colour or device value is assumed in the library.
|
||||
|
||||
`GraphLayout` returns an unmodifiable `nodes` list of `GraphNodeBox`
|
||||
(`key`, `terminal`, `stageIndex`, `rank`, `x`, `y`, `width`, `height`), an
|
||||
unmodifiable `ranks` map, `rankCount`, and total `width`/`height` including
|
||||
padding. Node keys, terminal flags and stage indices are copied from the
|
||||
landed `graphNodes` identities unchanged.
|
||||
|
||||
## Ranking behavior
|
||||
|
||||
Ranks are read from the definition supplied by the caller; the existing
|
||||
`graphNodes`/`graphEdges` helpers remain the source of identities.
|
||||
|
||||
- Iterative Tarjan strongly connected components (no recursion; a 2000-stage
|
||||
chain is covered), then longest-path ranks over the condensation DAG.
|
||||
- Every member of a cycle shares one rank, so cyclic routes cannot recurse or
|
||||
push members apart. Self loops are internal supervision and add no rank.
|
||||
- Disconnected stages and disconnected terminals stay at rank 0.
|
||||
- Edges whose source or target is not a node are ignored. An unknown or empty
|
||||
target never creates a node or a rank.
|
||||
- Ranking is linear in nodes plus edges and stable for repeated input.
|
||||
|
||||
## Placement behavior
|
||||
|
||||
- One column per rank; nodes keep definition order inside a rank.
|
||||
- A column is as wide as its widest measured node; columns are separated by
|
||||
`columnGap` and top-aligned.
|
||||
- Nodes are centred in their column and stacked with exactly `rowGap` between
|
||||
measured boxes (centres are compared in the heterogeneous test).
|
||||
- Supplied widths/heights are placed verbatim, so expanded text is never
|
||||
clipped to a fixed box; growing the extents grows the total bounds.
|
||||
- Bounds include every box: tests assert `right <= width` and
|
||||
`bottom <= height` for every fixture.
|
||||
- The result is immutable and identical for identical input.
|
||||
|
||||
Measurements are required for every node; a missing key throws
|
||||
`ArgumentError` rather than inventing a default size. Extra measurements are
|
||||
ignored because they cannot become nodes. Duplicate/empty node keys, negative
|
||||
or non-finite gaps and extents are rejected.
|
||||
|
||||
## Checks actually run
|
||||
|
||||
```
|
||||
flutter pub get
|
||||
dart format lib/features/graph/layout test/features/graph/layout
|
||||
flutter test test/features/graph/layout # 21 passed
|
||||
flutter analyze # No issues found!
|
||||
flutter test # 173 passed
|
||||
git diff --check # clean
|
||||
```
|
||||
|
||||
Tests cover linear, diamond, cycle, self-loop, disconnected, terminals,
|
||||
unknown/empty targets, heterogeneous extents, 2.6x expanded text, determinism,
|
||||
bounds and invalid input.
|
||||
|
||||
## Honest limits
|
||||
|
||||
- **Nodes only.** Edge routing, ports, labels, lanes, hit testing, selection
|
||||
highlighting, painting and native controls are separate later items.
|
||||
- **Not rendered.** A pure nonvisual slice has no browser behavior to capture;
|
||||
no screenshot or browser check applies.
|
||||
- **No server or device.** Tests use local fixtures only; no run, pipeline,
|
||||
schedule, service, emulator, ADB, Android/iOS build or live chat was touched.
|
||||
- **Mobile unverified.** Only web-targeted Flutter test/analyze ran.
|
||||
- **Uncommitted candidate.** Per this stage's instruction the slice is left in
|
||||
the worktree; no commit, push or deployment was made.
|
||||
@@ -0,0 +1,114 @@
|
||||
# R2c — native retry / restart action
|
||||
|
||||
Small app-only addition, new files only. `RetryRunAction(run, gateway,
|
||||
onRunChanged)` is the deliberate retry entry point for a stopped failed run; it
|
||||
does not add a screen or controller and is not wired into the shell.
|
||||
|
||||
## What changed
|
||||
|
||||
| File | Lines | Responsibility |
|
||||
| --- | --- | --- |
|
||||
| `lib/features/runs/actions/retry_action.dart` | 123 | `RetryRunAction`, gating, send/refusal/resync orchestration |
|
||||
| `lib/features/runs/actions/retry_dialog.dart` | 207 | Native resume/restart confirmation, refusal display, key lifetime |
|
||||
| `lib/features/runs/actions/retry_eligibility.dart` | 16 | `canRetryRun` mirroring the web `canRetry` |
|
||||
| `lib/features/runs/actions/retry_intent.dart` | 29 | Mode, confirmed intent and idempotency-key generation |
|
||||
| `lib/features/runs/actions/retry_wording.dart` | 33 | Web-verbatim words, titles, error wording and test keys |
|
||||
| `test/.../retry_test_support.dart` | 112 | Fake gateway and Material/Cupertino hosts |
|
||||
| `test/.../retry_action_test.dart` | 245 | Eligibility, both platforms, modes and key fields |
|
||||
| `test/.../retry_resilience_test.dart` | 223 | Immediate refusals, recheck outcomes, key retention |
|
||||
| `test/.../retry_safety_test.dart` | 133 | Double submit, late replies, narrow 2x layout |
|
||||
|
||||
No repository, gateway, socket, controller, shell, main, pubspec, web, server or
|
||||
device file was edited.
|
||||
|
||||
## Behavior
|
||||
|
||||
Eligibility is exactly the browser's rule: a loaded run that is not executing and
|
||||
whose status is `failed` (`run != null && !run.executing && status == "failed"`).
|
||||
A stale `failed` status while execution is still in flight, a running/waiting/
|
||||
succeeded/canceled run, and a malformed run render nothing.
|
||||
|
||||
The button is a Material `FilledButton` or a Cupertino `CupertinoButton.filled`,
|
||||
labelled `Retry`. Opening the prompt sends nothing, and `Keep` only closes it.
|
||||
|
||||
The first confirmation is the browser's retry copy: title `Retry run {id}?`,
|
||||
message `Only failed runs can be retried. The server starts a new run from the
|
||||
same input.`, confirm `Retry`, dismiss `Keep`, plus the browser-only secondary
|
||||
`Restart from start` that leads to a distinct confirmation. That second prompt
|
||||
uses title `Restart run {id}?`, message `This replays the whole pipeline from the
|
||||
start instead of resuming the failed stage.` and confirm `Restart from start`;
|
||||
the resume actions are gone, so the more destructive choice cannot be mistaken
|
||||
for resume.
|
||||
|
||||
Resume calls `RunsRepository.retryRun` with only `run_id` and `request_key`, so
|
||||
`retry_mode` is omitted and the server's `resume` default applies. Restart sends
|
||||
`retry_mode: "restart"` with the same two required fields.
|
||||
|
||||
A `request_key` is created on the first confirm of an open prompt, not on opening
|
||||
or `Keep`. It survives a refusal, so pressing confirm again for the same
|
||||
uncertain request reuses the key and the server can dedupe it. Closing the prompt
|
||||
and opening it again is a fresh deliberate intent and gets a new key, so a resume
|
||||
attempt followed by a restart attempt never shares a key. Switching to the
|
||||
restart confirmation before any send simply confirms restart with that prompt's
|
||||
first key. Keys are bounded and run-scoped (`app-retry-{runId}-…`, well under the
|
||||
server's 128-character cap).
|
||||
|
||||
A server refusal returns to the prompt immediately: the exact server words are
|
||||
visible and `Keep`/back are available while the detached `get_run` recheck is
|
||||
still pending. One bounded re-read is issued per refusal, single-flight through a
|
||||
retained future, with no retry loop or polling. If server truth says the run is no
|
||||
longer retryable, confirm is disabled and an attempted tap sends nothing; the
|
||||
refusal stays visible until dismissal. If the recheck itself fails, truth is
|
||||
unknown, so confirm is re-enabled and a deliberate retry uses the retained key.
|
||||
Late retry replies and late rechecks after disposal or navigation are ignored.
|
||||
|
||||
Construction, controls and error colour are standard Material/Cupertino defaults;
|
||||
there is no custom palette, fixed control size or dependency. The narrow layout
|
||||
relies on the native dialog's own scrolling/wrapping.
|
||||
|
||||
## Acceptance checks
|
||||
|
||||
Fake-gateway widget tests, both platforms, no socket or real server:
|
||||
|
||||
- eligibility table for stopped failed vs executing failed, running, waiting,
|
||||
succeeded and canceled runs, plus the same visibility table under both apps;
|
||||
- `Retry` opens the native `AlertDialog`/`CupertinoAlertDialog`, `Keep` closes it
|
||||
and the recorded gateway calls are still empty;
|
||||
- resume sends exactly `{run_id, request_key}` and no `retry_mode`; restart sends
|
||||
exactly `{run_id, request_key, retry_mode: "restart"}`;
|
||||
- key format is deterministic under an injected clock/entropy, bounded, fresh per
|
||||
call, retained across an uncertain retry (resume and restart), and different
|
||||
after a deliberate reopen or mode change;
|
||||
- refusal message appears while `get_run` is deliberately unresolved, with Keep
|
||||
enabled, confirm disabled and no callback yet; Keep then closes and the late
|
||||
recheck still delivers server truth safely;
|
||||
- ineligible recheck (`succeeded`) blocks a repeat action; failed recheck leaves
|
||||
the same key and a working deliberate retry;
|
||||
- two confirm taps while in flight produce one `retry_run`; both the retry reply
|
||||
and the recheck are safe after disposal;
|
||||
- 320×480 at 2× text: both resume and restart confirmations render on both apps
|
||||
with no exception, and Keep sends nothing.
|
||||
|
||||
## Checks actually run
|
||||
|
||||
```
|
||||
dart format lib/features/runs/actions test/features/runs/actions # clean
|
||||
flutter analyze # No issues found!
|
||||
flutter test test/features/runs/actions # 40 passed
|
||||
flutter test # 69 passed
|
||||
flutter build web # Built build/web (14.5s)
|
||||
```
|
||||
|
||||
## Honest limits
|
||||
|
||||
- **Not wired into a run-detail screen.** This branch has no runs screen or
|
||||
controller; the manager owns that integration. There is no browser interaction
|
||||
or rendered capture for this widget, and `flutter build web` proves compilation
|
||||
only, not rendered behavior.
|
||||
- Browser parity is by source/word/request-shape comparison with
|
||||
`web/src/actions.js` and `web/src/repository.js`; the web client itself was not
|
||||
changed and no live web retry was performed.
|
||||
- **Mobile unverified.** No Android/iOS build, emulator, ADB or device was used.
|
||||
- No real server or run was retried, canceled or otherwise mutated; all evidence
|
||||
uses local fakes.
|
||||
- The candidate is committed, not pushed or deployed.
|
||||
@@ -0,0 +1,140 @@
|
||||
# T1a — template catalogue, validate and create-only submit
|
||||
|
||||
## What changed
|
||||
|
||||
New nonvisual `templates` data/domain slice. One shared file was edited:
|
||||
`app/.gitignore` re-includes `test/**/data/`, because the repository's runtime
|
||||
`data/` rule was silently excluding this slice's tests from the candidate. No
|
||||
other lane's work, `lib/main.dart`, shell, pubspec, `web/`, server or Android
|
||||
file was touched.
|
||||
|
||||
| File | Lines | Responsibility |
|
||||
| --- | --- | --- |
|
||||
| `lib/features/templates/domain/template_entry.dart` | 63 | Immutable server template; models key/name/description/source/scheduled and keeps every unknown field in deeply read-only `raw` |
|
||||
| `lib/features/templates/data/template_repository.dart` | 84 | `TemplateRepository(ApiGateway)`: list, validate, create-only submit |
|
||||
| `test/features/templates/data/template_test_support.dart` | 47 | Recording/refusing fake gateways, server-refusal error, Unicode source fixture |
|
||||
| `test/features/templates/data/template_list_test.dart` | 165 | Catalogue request shape, field preservation, deep immutability, missing/malformed catalogue |
|
||||
| `test/features/templates/data/template_create_test.dart` | 147 | Validate/submit envelopes, blank-name gate, missing payloads, verbatim refusals |
|
||||
| `app/.gitignore` | +4 | Re-includes `test/**/data/` so test files enter the candidate |
|
||||
|
||||
Nothing under `lib/main.dart`, `lib/shell/`, another feature, `pubspec.*`,
|
||||
`web/`, the Go server or `android/` was changed. No dependency was added.
|
||||
|
||||
## Review findings addressed
|
||||
|
||||
- **Tests could never land (blocking).** `test/features/templates/data/` was
|
||||
excluded by the repository root rule `data/`; `app/.gitignore` only re-included
|
||||
`lib/**/data/`. The same negation now covers `test/**/data/`, so these three
|
||||
test files are untracked-but-visible to git and `git add -n` succeeds. Fixing
|
||||
the rule (rather than `git add -f`) also protects later `test/**/data/` lanes
|
||||
such as S1a. No test was moved, so `test/` still mirrors `lib/`.
|
||||
- **`raw` was only shallowly immutable (advisory).** `TemplateEntry.fromJson`
|
||||
now deep-copies nested maps/lists into read-only collections, and the listed
|
||||
test proves nested mutation throws and that the copy does not alias the reply.
|
||||
- **Malformed-catalogue branches were untested (advisory).** Added tests for a
|
||||
non-list `templates` value and a non-object catalogue entry, both rejecting
|
||||
with explicit messages.
|
||||
- `_text` still stringifies a non-string protocol value with `'$value'`; the
|
||||
protocol only sends strings, and this matches how the browser would render
|
||||
such a value, so the behaviour was left unchanged and is documented here
|
||||
rather than claimed as strict parity.
|
||||
|
||||
## Wire behaviour (mirrors `web/src/repository.js`)
|
||||
|
||||
- `listTemplates()` sends exactly `{"type":"list_templates"}` with no fields and
|
||||
returns the `templates` catalogue. A reply with no `templates` field is the
|
||||
older server's empty catalogue (`?? []` in the browser), not a fake template.
|
||||
Each entry keeps `key`, `name`, `description`, `source`, `scheduled` and all
|
||||
unknown fields in `TemplateEntry.raw`; the reply list/maps are never mutated.
|
||||
`raw` is a deep unmodifiable copy: nested unknown maps and lists are copied
|
||||
into read-only collections, so neither the view nor a later caller can mutate
|
||||
the server reply through it.
|
||||
- `listTemplates()` rejects a malformed envelope instead of fabricating
|
||||
entries: a non-list `templates` throws
|
||||
`"The server returned no template catalogue."` and a non-object entry throws
|
||||
`"The server returned a template that is not an object."`. The real server
|
||||
cannot produce either, but a protocol mistake must not look like an empty or
|
||||
half-populated catalogue.
|
||||
- `validate(source)` sends exactly `{"type":"validate","source":<source>}` and
|
||||
returns the reply's `graph`. A reply without a graph throws
|
||||
`TemplateRepositoryException("The server returned no graph.")` — the browser's
|
||||
exact words — rather than reporting a valid definition.
|
||||
- `submit(name, source)` sends exactly
|
||||
`{"type":"submit","name":<trimmed name>,"source":<source>,"create_only":true}`.
|
||||
A blank/whitespace-only name is refused locally with
|
||||
`TemplateRepositoryException("Enter a pipeline name.")` and no gateway call is
|
||||
made; the accepted name is trimmed. A reply without `detail` throws
|
||||
`TemplateRepositoryException("The server returned no pipeline detail.")`.
|
||||
- The source string is never trimmed, normalised or re-encoded: Unicode, tabs,
|
||||
newlines and significant leading/trailing whitespace arrive unchanged.
|
||||
- A server refusal is never caught or reworded by the repository. It reaches the
|
||||
caller as the same gateway error object, so the server's own text is shown.
|
||||
- The repository exposes only these three operations. It has no publish, run,
|
||||
schedule or overwrite path, so loading or validating a template cannot start
|
||||
work or mutate a retained pipeline.
|
||||
|
||||
## Checks actually run
|
||||
|
||||
```
|
||||
flutter pub get # Got dependencies
|
||||
dart format lib/features/templates test/features/templates # clean
|
||||
flutter analyze # No issues found! (0.9s)
|
||||
flutter test test/features/templates # 13 passed
|
||||
flutter test # 76 passed
|
||||
flutter build web # ✓ Built build/web (15.5s)
|
||||
git diff --check # clean
|
||||
git check-ignore / git add -n # tests are no longer ignored
|
||||
```
|
||||
|
||||
Tests are part of the candidate, not merely present on disk:
|
||||
|
||||
```
|
||||
$ git add -n app/test/features/templates/data/template_list_test.dart \
|
||||
app/test/features/templates/data/template_create_test.dart \
|
||||
app/test/features/templates/data/template_test_support.dart
|
||||
add 'app/test/features/templates/data/template_create_test.dart'
|
||||
add 'app/test/features/templates/data/template_list_test.dart'
|
||||
add 'app/test/features/templates/data/template_test_support.dart'
|
||||
exit=0
|
||||
|
||||
$ git status --porcelain=v1 -uall
|
||||
M app/.gitignore
|
||||
?? app/lib/features/templates/data/template_repository.dart
|
||||
?? app/lib/features/templates/domain/template_entry.dart
|
||||
?? app/notes/T1a.md
|
||||
?? app/test/features/templates/data/template_create_test.dart
|
||||
?? app/test/features/templates/data/template_list_test.dart
|
||||
?? app/test/features/templates/data/template_test_support.dart
|
||||
```
|
||||
|
||||
Focused acceptance coverage:
|
||||
|
||||
- exact `list_templates` request (no fields, one call) and preservation of
|
||||
modelled plus unknown fields, including nested unknown data;
|
||||
- listing does not mutate the reply's template list or entry maps; `raw` and
|
||||
every nested map/list are read-only, and the copy does not alias the reply;
|
||||
- missing catalogue -> empty list; malformed catalogue -> explicit refusal;
|
||||
- blank/whitespace name -> refusal with zero gateway calls;
|
||||
- Unicode/emoji, tab/newline and leading/trailing source whitespace preserved in
|
||||
both `validate` and `submit`; submit sends only name, source and
|
||||
`create_only: true`, with the name trimmed;
|
||||
- missing `graph` and missing `detail` rejected with the browser's exact
|
||||
messages, with no fabricated graph/detail;
|
||||
- validate and submit server refusals surface as the identical error object,
|
||||
not a wrapper.
|
||||
|
||||
## Honest limits
|
||||
|
||||
- **Not wired into a screen.** This branch has no templates screen and the task
|
||||
owns data/domain only; the manager owns integration. No browser capture was
|
||||
made because there is no rendered change in this slice.
|
||||
- **Mobile unverified.** No Android/iOS build, emulator, ADB or device was used.
|
||||
The code is plain Dart with no platform-specific code.
|
||||
- No live server, template catalogue, validate call or submit/creation was
|
||||
performed. All tests use local fake gateways with no socket, so no real
|
||||
pipeline was created or run.
|
||||
- No export-gate workaround, server change or service operation was made; the
|
||||
pending export-cap fix remains another lane's scope.
|
||||
- **Not committed.** The stage instruction says not to commit, push or deploy,
|
||||
so the candidate above is uncommitted in the working tree even though the run
|
||||
prompt asks to commit a reviewed candidate. Nothing was pushed or deployed.
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
# X1 — Omni-search
|
||||
|
||||
## Scope and API
|
||||
|
||||
Implemented the `search` feature under `lib/features/search/` with no
|
||||
`main.dart`, shell, pubspec, server, web or Android edits.
|
||||
|
||||
Entry point:
|
||||
|
||||
```dart
|
||||
SearchScreen(
|
||||
gateway: apiGateway, // required ApiGateway
|
||||
onOpen: (hit) { ... }, // required ValueChanged<JsonMap>
|
||||
cupertino: null, // optional; omitted = iOS/macOS Cupertino, else Material
|
||||
)
|
||||
```
|
||||
|
||||
`onOpen` always receives the server's original result map unchanged, including
|
||||
its `target`. Unknown/absent payloads and results without a target are
|
||||
read-only and never call `onOpen`; the client never invents a route or mutates
|
||||
server state.
|
||||
|
||||
Request shape is exact and shared-gateway only:
|
||||
|
||||
```json
|
||||
{"type":"search","search":{"query":"plan","kind":"","limit":0}}
|
||||
```
|
||||
|
||||
`limit` is always `0` (server default cap), never a client-chosen larger value.
|
||||
|
||||
## Behaviour
|
||||
|
||||
- `t:`/`type:` tokens: unquoted, whitespace-delimited, case-insensitive, last
|
||||
supported token wins; quoted, escaped, unknown and trailing-punctuation
|
||||
tokens stay literal. The parser mirrors `web/src/search.js`.
|
||||
- Kind selector: All kinds / Pipelines / Runs / Steps / Fields / Artifacts /
|
||||
Versions. Changing it removes recognised type tokens from the field and sends
|
||||
at once, like the browser's selector.
|
||||
- Empty text with All kinds clears locally and sends nothing. Blank text with a
|
||||
valid kind is a kind-only browse, matching the server/browser contract.
|
||||
- 250 ms debounce; Enter sends at once. Every request carries a monotonically
|
||||
increasing token, and replies for superseded edits are dropped.
|
||||
- Loading, searching, retained-results refresh progress, empty (query-specific
|
||||
and kind-only wording) and error are distinct. A truncated reply with no rows
|
||||
says the server's scan limit was reached and keeps its truncation/scan bounds
|
||||
on screen instead of claiming a complete empty; a complete empty has no bounds
|
||||
line. A reply without `search_results` and an unknown-command rejection use
|
||||
the server-upgrade sentence; any other failure shows the server's own text.
|
||||
Error state offers Retry.
|
||||
- Rows show the kind derived from the server payload (`Unrecognised result` for
|
||||
an unknown payload), title, snippet (first case-insensitive query occurrence in
|
||||
bold), and recency. Bounds show result count, cap, scanned steps/bytes, scan
|
||||
limit and a truncation sentence when the server reports it, including for a
|
||||
truncated reply with zero rows.
|
||||
- In-hand results are re-narrowed by the effective kind while a narrowed request
|
||||
loads, so the list always agrees with the control.
|
||||
- Standard platform controls only: Material `SearchBar`, dropdown,
|
||||
`LinearProgressIndicator`, `CircularProgressIndicator`, `ListTile`,
|
||||
`FilledButton.tonalIcon`; Cupertino `CupertinoSearchTextField`, action-sheet
|
||||
kind picker, `CupertinoListSection`/`CupertinoListTile`,
|
||||
`CupertinoActivityIndicator`, `CupertinoButton.filled`. No CSS port, custom
|
||||
palette, fixed row/bubble dimensions or bespoke buttons. Typography and
|
||||
colours come from the ambient Material/Cupertino theme; rows and the header
|
||||
scroll in one `CustomScrollView` so 2× text never clips.
|
||||
|
||||
## Automated checks
|
||||
|
||||
Run from `app/` with `/Users/alan/development/flutter/bin/flutter`:
|
||||
|
||||
- `flutter test test/features/search` — **36 passed** (controller, repository,
|
||||
query/token parser, row/snippet/routing, Material + Cupertino widget tests).
|
||||
- `flutter test` — **65 passed** (whole app suite, including existing transport,
|
||||
runs and shell tests).
|
||||
- `flutter analyze` — **No issues found**.
|
||||
- `flutter build web` (default `lib/main.dart`) — **succeeded**.
|
||||
- `flutter build web -t tool/search_fixture/main.dart` — **succeeded** for the
|
||||
rendered probe.
|
||||
- `node --check tool/search_probe.mjs` — passed.
|
||||
- `git diff --no-index --check /dev/null <file>` on every touched file — no
|
||||
whitespace errors (all task files are untracked, so plain `git diff --check`
|
||||
would not see them).
|
||||
|
||||
Tests were written before the implementation (initial run failed on missing
|
||||
symbols). Coverage includes the exact envelope, token parsing, selector token
|
||||
clearing, no-request empty state, stale success and failure replies,
|
||||
error/retry, truncation/bounds (including a truncated reply with zero rows),
|
||||
per-kind row text, snippet spans, read-only hits, `onOpen` targets, and
|
||||
MaterialApp/CupertinoApp at 390/1000 wide with 2× text.
|
||||
|
||||
## Rendered browser evidence
|
||||
|
||||
Built the Web-only fixture (`tool/search_fixture/main.dart`) and drove real
|
||||
headless Chrome through CDP with `tool/search_probe.mjs` on an OS-assigned
|
||||
loopback port. The probe typed `plan` into the real field, asserted five rows,
|
||||
the server snippet, recency and truncation/scanned bounds, then clicked the
|
||||
pipeline row and asserted that the fixture receiver got `pipeline:24`. It also
|
||||
typed `needle` with no matching fixtures and asserted the Material and Cupertino
|
||||
truncated-empty copy plus the retained `Results truncated … 0 results … scanned
|
||||
2000 steps … scan limit 1.0 MiB` line, capturing both.
|
||||
|
||||
Captures are in the run's shared artifacts:
|
||||
|
||||
- `/Users/alan/.local/share/pipelines/data/artifacts/49/public/x1-search/x1-search-material-phone.png` — 390×844, Material controls, five mixed-kind results with recency/snippet/bounds.
|
||||
- `/Users/alan/.local/share/pipelines/data/artifacts/49/public/x1-search/x1-search-material-desktop.png` — 1280×800, same results.
|
||||
- `/Users/alan/.local/share/pipelines/data/artifacts/49/public/x1-search/x1-search-cupertino-phone.png` — 390×844, Cupertino search field/kind picker/grouped rows, dark system theme.
|
||||
- `/Users/alan/.local/share/pipelines/data/artifacts/49/public/x1-search/x1-search-open-target.png` — the row click landing on `Opened pipeline target: pipeline:24`.
|
||||
- `/Users/alan/.local/share/pipelines/data/artifacts/49/public/x1-search/x1-search-truncated-empty.png` — 390×844 Material, zero rows with the server's scan-limit sentence and truncation/scan bounds.
|
||||
- `/Users/alan/.local/share/pipelines/data/artifacts/49/public/x1-search/x1-search-truncated-empty-cupertino.png` — 390×844 Cupertino dark, the same bounded empty state.
|
||||
|
||||
The fixture and probe are development-only entry points; they are not imported
|
||||
by `lib/main.dart` and are not part of the production routing. The browser run
|
||||
used a static fake gateway, not a live Pipelines server or operator data.
|
||||
|
||||
## Not verified / open items
|
||||
|
||||
- No shell registration or navigation wiring was added (manager owns
|
||||
`main.dart`/`shell/`); the screen is exported for that integration.
|
||||
- No real server, operator chat/run, or production URL was used.
|
||||
- Mobile targets (Android/iOS) were **not** built, installed or exercised;
|
||||
only Web was rendered and tested. Source is kept portable.
|
||||
- No commit, push, deployment or canonical URL change was made.
|
||||
Reference in New Issue
Block a user