Files
PaperClipAI/maps/agent-access-map/cases.md
T
Dotta 4553c2396b refactor(test): prune 483 redundant nightly soak test suites (keep 105 canonical) (#22831)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Over recent sprints, `scripts/ci/nightly-only-suites.json`
accumulated 588 real-clock soak, recovery, lease, and maintenance test
files totaling ~326k LOC and ~307 CPU-minutes on `master`,
`release-verify`, and `full-ci` runs.
> - Most of those files are overlapping single-PR regression soaks whose
failure modes are already covered by canonical suites, driving up
maintenance cost, typecheck load, and post-merge verification runtime
without adding distinct coverage.
> - Following `.agents/skills/test-audit/SKILL.md`, this pull request
prunes 483 redundant/overlapping soak files (`-158,485` net LOC, ~180
CPU-min saved) while retaining 105 canonical, high-signal nightly suites
covering every distinct failure mode and 100% of suites referenced by CI
workflows, benchmarks, Slack eval manifests, lifecycle inventories, or
tsconfigs.
> - All timing manifests and feature/agent-access maps are updated
cleanly to remove stale references.
> - The benefit is a ~59% reduction in nightly soak CPU time and ~158.5k
fewer lines of duplicate test code to compile, typecheck, and maintain
while preserving full invariant and canonical soak coverage.

## Linked Issues or Issue Description

Refs #22804

**What existing behavior does this improve?**
Test suite maintainability, typecheck scope, and
nightly/post-merge/full-CI runtime across
`scripts/ci/nightly-only-suites.json` and `server/src/`.

**Subsystem affected**
server/ — REST API & orchestration services

**Current behavior**
`scripts/ci/nightly-only-suites.json` contains 588 standalone soak test
files (~307 CPU-min total), with hundreds of overlapping one-PR
recovery, lease, and idle-maintenance soak suites duplicating canonical
coverage.

**Proposed behavior**
Retain 105 canonical high-signal nightly suites covering every distinct
failure mode and every hard-referenced suite, delete 483 redundant soak
files, and keep `nightly-only-suites.json`,
`general-server-shard-durations.json`, and `maps/` 100% synchronized.

## What Changed

- **Pruned 483 redundant nightly soak files (`-158,916 / +431` LOC =
`-158,485` net LOC, ~59% of nightly soak CPU):**
- Retained **105 canonical high-signal nightly suites** covering every
distinct failure mode and 100% of hard-referenced suites
(`scripts/run-vitest-stable.mjs`, `runner-chaos-evals.yml`,
`ci-work-benchmark.yml`, `tests/lifecycle-baseline/inventory.mjs`,
`stress-workflow-traceability.json`,
`packages/plugins/examples/slack/evals/cases.json`, and
`tsconfig*.json`), including the 6 focused suites restored after review
(`idle-database-backup-sync`, `isolated-remote-workspace-source-lock`,
`agent-chat-response-recovery`, `chat-slack-receipts`,
`heartbeat-slack-invitation`, `ephemeral-migration-service`).
- **Updated manifests and maps:**
- `scripts/ci/nightly-only-suites.json`: 588 → 105 suites (0 missing, 0
duplicates, 0 protected invariants demoted).
- `scripts/general-server-shard-durations.json`: 2,138 → 1,655 entries
(`coverage: { measured: 1573, withSetup: 1573, inventory: 1655 }`,
pruned all 483 deleted paths).
- Updated all affected `maps/{agent-access-map,feature-map}/*.md` files
with zero dangling references.

## Verification

- `node scripts/check-test-budget.mjs --base origin/master` — **PASS**
(105 nightly suites validated, 0 invariant violations)
- `node scripts/check-maps.mjs` — **PASS** (35 areas, 192 capability IDs
aligned)
- `node packages/plugins/examples/slack/evals/run-regressions.mjs
--list` — **PASS**
- `node --test scripts/__tests__/run-vitest-stable-shard.test.mjs
scripts/__tests__/run-vitest-stable-pr-mode.test.mjs
scripts/check-test-budget.test.mjs
scripts/ci/test-selection-pr-timings.test.mjs
scripts/ci/test-selection-timings.test.mjs
tests/lifecycle-baseline/report.test.mjs
.github/scripts/tests/ci-plan.test.mjs` — **102/102 PASS**
- Repo-wide scan confirmed 0 test-to-test imports and 0 dangling
references in `scripts/`, `.github/`, `maps/`, `tsconfig*.json`,
`packages/plugins/examples/slack/evals/cases.json`, or
`tests/lifecycle-baseline/inventory.mjs`.

## Risks

- Low risk: every deleted file was already nightly-only (not running on
ordinary PRs) and every distinct failure mode plus every core
control-plane invariant remains covered by PR suites and the 105
retained canonical nightly suites.

## Model Used

- Google Gemini (Antigravity agent swarm) with extended reasoning, tool
use, and local test execution (`server-prune`, `verifier`,
`ci-pipeline`).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
2026-11-24 17:30:47 -06:00

14 KiB

Cases and structured work records — agent access

Product map: Cases and structured work records.

Feature ID: cases.

Review date: 2026-10-12. Source commit: f981fa3cc10cb8663a87dec60345fbff46d54d0a.

This is a source-reviewed baseline of representative operations and known gaps. Each capability needs operation-level review before its entire scope can be qualified. Scoped working-tree and live evidence is recorded below; it does not qualify every operation in the baseline tables. Follow the map contract for format, permission checks, evidence and maintenance.

browse

Capability ID: cases/browse.

Review: baseline.

API: present — representative operation IDs:

  • GET /api/companies/{companyId}/cases (search/status/type/project filters, sortField=updated|created|title|status|type, sortDir=asc|desc, groupBy=none|status|type|project, and offset after authorization). Sorting and group ordering apply to the full authorized result before pagination. Defaults retain newest-updated ordering; status uses lifecycle order and project groups use stable project IDs with unassigned cases last.
  • GET /api/companies/{companyId}/cases/types (distinct types from accessible standalone cases).

Agent access: available — REST / native call_api; dedicated native read_case for an authorized standalone case or the task's primary case; agent cases reference.

Native read_case has bounded UTF-8 JSON paging through the same authorized case GET (agentRead=true). Small cases remain structured; large cases and section: "fields" expose exact readPage.text chunks. Continuations require offsetBytes and the returned snapshot; a changed case/task version or selected projection returns 409. Every successful page retains handoff/task versions. Generic call_api remains optional and is not needed to recover large fields. section: "document" with documentKey reads a historical case-owned document; adding documentIssueId selects a current primary or linked task document. Bodies use the same bounded JSON pages without generic API tools. Each page rechecks source-task access and linkage, excludes system/quarantined documents, and binds the snapshot to the selected document identity, revision and body.

Policy: enableCases gate; company/case/task boundaries, active run where required, source trust, and checked-out mutation ownership.

Evidence: source-only — implementation at the reviewed commit above.

Verification: not-run — exercise a listed permitted operation with actual agent credentials/run context; inspect its result and applicable persistence/attribution. Assert the relevant denied actor, owner, company or mode from Policy. Review the remaining operations before qualifying the whole capability.

Gaps: No dedicated production list_cases binding is required because the REST fallback exists. Case pages are read-only; this does not remove agent mutation APIs.

structure

Capability ID: cases/structure.

Review: baseline.

API: present — representative operation IDs:

  • POST /api/companies/{companyId}/cases.
  • PATCH /api/cases/{id}.

Agent access: available — REST / native call_api; native create_case creates a fresh case and its first task through required kickoff and workflow_document_text; new-case handoff API calls require the same text. It is saved verbatim as ordinary task document workflow before delivery, with create-only revision semantics and task mutation authority when binding. Tool prompts, API schema descriptions and the case guide recommend both a Mermaid stateDiagram-v2 map and prose defining transition triggers, evidence, next agents, human waits and correction/escalation rules. Diagram labels are advisory. initialDocuments writes ordinary task documents before dispatch. update_case changes title, summary and whole-object fields. Reads/updates default to the primary workflow case and retain REST authorization. Standard read_document / write_document operate on the active task; rollup references identify other accessible tasks and their authenticated REST read paths. Native read_case document selection can open those references without call_api.

Policy: enableCases gate; company/case/task boundaries, active run where required, source trust, and checked-out mutation ownership.

Evidence: source-only — implementation at the reviewed commit above.

Verification: not-run — exercise a listed permitted operation with actual agent credentials/run context; inspect its result and applicable persistence/attribution. Assert the relevant denied actor, owner, company or mode from Policy. Review the remaining operations before qualifying the whole capability.

Gaps: Structured case data is supported; grouping/rendering is presentation, not a new endpoint requirement.

Dedicated native CRUD is standard-mode/enableCases gated and has strict schemas; fact updates cannot change status, routing or permissions. Update receipts are run-scoped; creation always delegates to the principal-scoped handoff receipt. Missing kickoff or workflow text is rejected before any writes. Workflow text and other seeds share a bounded budget; extra seeds cannot replace the workflow key. Later transfers use ordinary revision tools for edits. Documents use ordinary task revision checks. Historical case-document REST/storage remains compatible, but separate native case-document tools are retired. Deterministic production-boundary tests are in native case tools and the assembled native journey; the real-provider campaign local-2026-10-19T19-57-00-135Z also passed all 12 receipt workflow checks using the dedicated tools. This scoped evidence does not qualify every generic case REST operation or subsequent tool replacements. The newer create_case/initialDocuments/task-rollup implementation has its own scoped deterministic verification in that record, including native creation and authenticated HTTP replay/denial tests. The later campaign local-2026-10-19T21-39-45-440Z passed all 13 live workflow checks using seeded ordinary task documents and task-document reads/writes. Its returning builder reused its own persisted session. Kickoff was initiated through the harness API; provider-generated native create_case kickoff remains deterministically verified rather than live-provider qualified. See the verification record.

The subsequent required workflow-document contract has authenticated HTTP, real-database/API schema and assembled native-runner coverage. Receiving context prioritizes its authorized reference, and fresh-session recovery keeps workflow text reference-only as well. These controlled-provider tests verify required creation, atomic task document persistence, replay and no automatic body injection; the earlier live campaign predates this requirement and is not requalified.

history

Capability ID: cases/history.

Review: baseline.

API: present — representative operation IDs:

  • GET /api/cases/{id}/events.
  • GET /api/cases/{id}/documents/{key}/revisions.
  • GET /api/issues/{id}/documents/{key}/revisions for task-owned rollup documents.

Agent access: available — REST / native call_api.

Policy: enableCases gate; company/case/task boundaries, active run where required, source trust, and checked-out mutation ownership.

Evidence: source-only — implementation at the reviewed commit above.

Verification: not-run — exercise a listed permitted operation with actual agent credentials/run context; inspect its result and applicable persistence/attribution. Assert the relevant denied actor, owner, company or mode from Policy. Review the remaining operations before qualifying the whole capability.

Gaps: Source-backed access only; case visibility and document locks still apply.

Capability ID: cases/task-links.

Review: baseline.

API: present — representative operation IDs:

  • POST /api/cases/{id}/links.
  • GET /api/issues/{issueId}/cases.

Agent access: available — REST / native call_api.

Policy: enableCases gate; company/case/task boundaries, active run where required, source trust, and checked-out mutation ownership.

Evidence: source-only — implementation at the reviewed commit above.

Verification: not-run — exercise a listed permitted operation with actual agent credentials/run context; inspect its result and applicable persistence/attribution. Assert the relevant denied actor, owner, company or mode from Policy. Review the remaining operations before qualifying the whole capability.

Gaps: Case/task association exists; source trust and issue visibility must be tested with agent credentials.

handoffs

Capability ID: cases/handoffs.

Reusable workflow extension (2026-10-21): GET/POST /api/companies/{companyId}/workflows and GET/PATCH /api/workflows/{id} expose company-scoped metadata/Markdown prompts. Native list_workflows, read_workflow, create_workflow, update_workflow use the optional Cases group, including with generic API tools disabled. Writes use existing run/source-trust fences and mutation receipts. Bounded prompt reads use the native API JSON text paging path; every page checks current company access. Continuation pages require the first page's content snapshot; edits return 409 and require restarting the read, so pages cannot silently combine definitions. Kickoff accepts either a workflow ID or inline text. Agent handoffs omit the ID to preserve, explicitly name an ID to adopt/refresh, or pass null to detach. Acceptance snapshots the prompt; transfer checks its task-document base revision before atomically adopting workflow/phase/instructions. Generic case updates cannot alter routing. Repeated visits and captured names remain in handoff history. The real-database/native-tool tests prove reuse, refresh, conflict/cancel/restart, cross-company denial, stopped writes, flag-off execution, and inline compatibility. Configured-provider acceptance of the extended journey is recorded separately.

Review: baseline.

API: present — POST /api/companies/{companyId}/case-handoffs; GET /api/cases/{id}/handoffs; POST /api/cases/{id}/handoffs/{handoffId}/retry and /cancel.

Agent access: available — live native handoff_case, native API discovery/call_api, and authenticated agent REST. Initial kickoff creates or explicitly binds an ordinary task; subsequent calls reuse it.

Terminal destination: to: "done" records closure intent for an existing primary task, using case read/mutation and normal task mutation authority. It does not assign, wake, yield, or satisfy completion evidence. Normal accepted task completion atomically closes the case; a current execution's Stop, task cancellation, or reassignment invalidates the intent. Run-scoped Stop preserves newer work; cancelling terminal intent without a source run requires fenced current task ownership. Waiting on review or user input preserves it. Ordinary completion without a terminal intent leaves case status unchanged.

Retention: whole-company deletion removes case history before dependent tasks/agents. Individual agent purge returns 409 agent_case_history_retained when handoffs reference the agent; termination preserves its attribution.

Policy: enableCases; standard mode; ordinary task creation/assignment authority; agents transfer only their own work; current case/task versions; company and retained task/project access intersection; existing review, Stop, budget, and workspace gates. Idempotency belongs to the authenticated principal, not a provider run. Cancellation remains available while the feature is disabled.

Delayed assignment rechecks the original caller's current assignment authority using internal, server-derived provenance. The context is not returned by history or recovery APIs. Missing historical provenance fails closed. After an assignment is applied, delivery checks recipient admission rather than requiring the former assignee to retain task access.

Cloud-user transfers confirm current stack membership through the uncached tenant portfolio API before taking task locks. The short-lived proof is bound to the original user and configured stack identity. Owner elevation also requires the current managed feature setting. Missing membership, a viewer role, an unavailable lookup, or a changed configuration holds the transfer. No Cloud role or administrator grant is stored in the handoff context.

Evidence: verified — 2026-10-19 working-tree implementation. The assembled native integration passed with actual runnerd and a controlled provider, alongside case handoffs and real-database authority/recovery tests. The later API-key campaign local-2026-10-19T19-14-18-642Z completed four real native runs and terminal case closure. The earlier subscription HTTP 429 remains recorded as a failed attempt; it was not regraded. See the verification record.

Verification: passed — deterministic boundaries include native tool acceptance/yield, process settlement, same-task successor context, authenticated HTTP replay, denied private sources, version conflicts, review gates and restart/acknowledgment recovery. The configured-provider correction round trip passed using API credentials. The latest local-2026-10-19T21-39-45-440Z campaign passed 13 checks with task-owned documents, four nonoverlapping runs, same-task transfers, returning-builder session reuse and terminal case closure. The earlier local-2026-10-19T21-32-43-612Z campaign remains failed because the task revision API omitted stored writer-run attribution; the subsequent authorized projection fix was qualified by the new campaign. Compact context content/omission assertions retain separate deterministic evidence.

Gaps: Full provider qualification is recorded separately from source presence and deterministic service tests.