# Search, filter, and sort records

**Flow key:** `search-filter-sort`

## Outcome

An authorized user can narrow and order the eligible dataset reproducibly without hidden-data leakage, stale queries, duplicates, or omissions.

## Actors

- User
- Search/query service
- Record store/index
- Permission service

## Preconditions and entry points

- A deterministic synthetic dataset covers empty/null, Unicode, dates, numbers, statuses, roles, and tenant isolation.
- Expected result sets and order are known.

## Required test data

Use synthetic, isolated, resettable data. Never use real credentials, payment instruments, private customer records, or production notifications.

| Data | Canonical valid seed | Critical variations |
|---|---|---|
| Dataset | 20 synthetic records with stable IDs | 0, 1, page boundary, large supported set |
| Queries | `carbon alpha` | empty, typo, phrase, emoji/emoticon, accents, RTL, markup/operator literals |
| Filters | status Active and owner Self | none, conflicting, unknown/deleted option, multi-select |
| Sort | updated descending then name ascending | nulls, equal values, locale collation, stale field |
| Permissions | standard user subset | admin, revoked record, other tenant |

## Canonical steps

Treat this as the ordinary successful path inferred from common product behavior. Adapt it to observed labels, business rules, APIs, and implementation evidence; do not invent a requirement.

| Step | User or system action | Expected evidence |
|---:|---|---|
| 1 | Open the canonical list/search view. | Default query, scope, count, sort, and visible columns are clear. |
| 2 | Enter a representative query. | Only current authorized matches appear; out-of-order responses cannot replace them. |
| 3 | Apply one and multiple filters. | Chips, counts, URL state, facets, and results agree. |
| 4 | Apply sort and secondary tie-breaker. | Ordering is deterministic across pages and refresh. |
| 5 | Page/scroll, open a result, and return. | No duplicates/omissions occur and view state restores. |
| 6 | Change/delete a matching record and permissions. | Results converge without leaking hidden records through counts, suggestions, or timing. |

## Alternate paths

- Simple search
- Advanced query
- Saved view
- Faceted filters
- Server versus client sorting

## Failure and recovery paths

- Index lag
- Out-of-order responses
- Deleted filter value
- Permission changes mid-query
- Unstable pagination under updates

## Completion oracle

- The stated outcome is true in visible UI and authoritative persisted state.
- Exactly one intended business result and no unintended side effect occurred.
- Identity, tenant, authorization, money/data, lifecycle, notifications, integrations, analytics, and audit agree where applicable.
- Refresh, retry, back/forward, and a second authorized read do not reveal a contradictory result.
- Any partial, delayed, canceled, failed, or unknown outcome is labeled truthfully and has a safe recovery path.

## Evidence to capture

- Entry context, actor, tenant, role, feature flags, locale, time zone, and initial identifiers/state.
- Step-level screenshots or DOM state plus request/response, correlation, job, event, and stable business IDs where available.
- Before/after authoritative records, versions, totals, permissions, lifecycle states, and downstream side effects.
- Notifications, audit events, integration deliveries, retries, deduplication, latency, and recovery evidence.
- Untested branches, unsafe-to-run cases, product decisions, and evidence tier.

## Product decisions to resolve

- Exact eligibility, required data, authorization, and validation rules.
- Which steps are synchronous, asynchronous, optional, skippable, reversible, or irreversible.
- Idempotency, concurrency, timeout, retry, cancellation, and compensation semantics.
- Retention, privacy, notification, audit, performance, accessibility, and localization commitments.

## Related CARBON items

- [search](../../items/organization/search.md)
- [filter](../../items/organization/filter.md)
- [sort](../../items/organization/sort.md)
- [list](../../items/views/list.md)
- [table](../../items/views/table.md)

[Back to Productivity and collaboration flows](index.md)
