Skip to content

D08b: Suggestion routes: list, apply (hash-guarded), dismiss - #870

Merged
LinuxDevil merged 3 commits into
mainfrom
fb-d08b-suggestion-routes
Nov 7, 2026
Merged

LinuxDevil merged 3 commits into
mainfrom
fb-d08b-suggestion-routes

Conversation

@LinuxDevil

Copy link
Copy Markdown
Owner

What changed

  • server/routes/suggestionRoutes.ts (new): GET /agents/:id/suggestions (prompt_edit records only, open first then createdAt desc; 404 LOUSHO_AGENT_NOT_FOUND), POST .../:sid/apply and POST .../:sid/dismiss. :sid is checked against SUGGESTION_ID_RE (400 LOUSHO_SUGGESTION_ID_INVALID); a missing record or a portability analysis is 404 LOUSHO_SUGGESTION_NOT_FOUND; a settled one is 409 LOUSHO_SUGGESTION_NOT_OPEN.
  • Apply runs inside withAgentLock(id): reconcile external edit → read spec → instructions not a string → 409 LOUSHO_SUGGESTION_UNSUPPORTED → prompt hash mismatch or oldText occurring other than once (indexOf loop, no regex) → record marked conflict + 409 LOUSHO_SUGGESTION_CONFLICT → literal replace(old, () => newText) → schema check (400 LOUSHO_SPEC_INVALID) → writeSpec → versions.capture({ kind: 'update', source: 'suggestion' }) → 201 VersionListItem, record applied, agent.changed reason version.
  • server/app.ts: registers the routes (per the workspace seam, handlers read workspaceOf(req).repo/.versions/.suggestions — no deps or singleton store) + route-list doc comment.
  • src/runtime/runtimeClient.ts: listSuggestions(id), applySuggestion(id, sid): Promise<VersionListItem>, dismissSuggestion(id, sid): Promise<void>.

How tested

  • New server/__tests__/suggestionRoutes.test.ts (10 tests, seeds via new SuggestionStore(repo).save(...)) and a RuntimeClient suggestion methods block in src/runtime/__tests__/runtimeClient.test.ts (4 tests).
  • npm run typecheck + npm run typecheck:server (apps/agent-forge): pass. Studio suites: 972 client + 1141 server tests pass.
  • Root npx tsc --noEmit, npm run lint: clean. Studio eslint: 0 errors (31 pre-existing warnings).
  • npm run test:coverage: 7190 pass; the only failures are 6 known environmental CRLF template-README assertions (unrelated to this diff); coverage 96.94/90.67/96.35/96.94, above thresholds. npm run fallow (0 above threshold), docs:ratchet (at baseline), api:check, docs:llms:check, size-check: all pass.

Acceptance criteria

  • A seeded open suggestion applies: instructions changed once, version written with source: 'suggestion', status applied.
  • After a PUT changing the instructions, apply → 409 conflict and status conflict.
  • oldText present twice → 409 conflict.
  • oldText containing $& or .* is replaced literally (the replacer function form).
  • Applying twice → second is 409 LOUSHO_SUGGESTION_NOT_OPEN.
  • Portability records never appear in the list.

Generated with Devin

LinuxDevil and others added 2 commits November 4, 2026 06:38
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@LinuxDevil
LinuxDevil changed the base branch from fb-d05-suggestion-store to main November 7, 2026 13:20
…utes

# Conflicts:
#	apps/agent-forge/server/__tests__/workspaceSeam.test.ts
#	apps/agent-forge/server/app.ts
#	apps/agent-forge/server/workspace/__tests__/middleware.test.ts
#	apps/agent-forge/server/workspace/context.ts
@LinuxDevil
LinuxDevil merged commit 07afd50 into main Nov 7, 2026
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant