-
Notifications
You must be signed in to change notification settings - Fork 0
fix(readiness): supported API paths to clear ADR-079 readiness findings #658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3845075
feat(db): re-derive choiceTokens source_facts on paragraph text edit
thewrz f4c0b41
feat(db): add paragraph acknowledgement to clear note/object findings
thewrz 5f60a74
feat(db): add comment-closure toggle; close comment on accept-as-note
thewrz ab7c865
feat(api): expose acknowledgement and comment-closure endpoints
thewrz 20bc123
feat(mcp): expose acknowledge_paragraph and set_comment_closed tools
thewrz 79a7b97
docs(api): document acknowledgement/comment-closure in openapi.yaml
thewrz 63ac08f
test(api): end-to-end readiness-clearance coverage for #545
thewrz 66374ac
test(mcp): exercise acknowledge_paragraph and set_comment_closed thro…
thewrz 98bcf97
fix(db): make migration 055 down actually reversible
thewrz 7d2b2d4
fix(ast): stop acknowledgement being stripped and from bypassing othe…
thewrz 5638bc8
fix(openapi): document the four ADR-079 history ops; gate the lockste…
thewrz 21d1378
Merge origin/main into fix/issue-545
thewrz dcfe8e8
test(contract): response-verify the two clearance ops instead of allo…
thewrz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import type { Request, Response } from 'express'; | ||
| import { z } from 'zod'; | ||
| import { PatchAcknowledgementBodySchema } from '../ast/index.js'; | ||
| import { setParagraphAcknowledged } from '../db/index.js'; | ||
| import { gateErrorResponse } from './edit-gate-response.js'; | ||
| import { logger } from '../lib/logger.js'; | ||
|
|
||
| /** | ||
| * PATCH /specs/:id/paragraphs/:nodeId/acknowledgement — per-node | ||
| * acknowledgement (#545, ADR-079 follow-on). `{ acknowledged: true }` clears | ||
| * the readiness gate's `specifier_note_present` / `body_object_present` | ||
| * finding for a `note` or `textBox` `object` node WITHOUT removing or hiding | ||
| * the content — it still renders exactly as before. Only `note` nodes and | ||
| * `textBox`-kind `object` nodes are acknowledgeable; every other node type | ||
| * (including a `table`-kind object, ADR-072) is rejected 422. The toggle is | ||
| * idempotent — a no-op returns the node unchanged without bumping any | ||
| * version. Passes the composed edit gate (ADR-018): archived/upstream-locked | ||
| * → 409. Mirrors removeParagraphHandler's structure exactly. | ||
| */ | ||
| export async function acknowledgeParagraphHandler(req: Request, res: Response): Promise<void> { | ||
| const specId = z.uuid().safeParse(req.params['id']); | ||
| if (!specId.success) { | ||
| res.status(400).json({ success: false, error: 'invalid spec id' }); | ||
| return; | ||
| } | ||
| const nodeId = z.uuid().safeParse(req.params['nodeId']); | ||
| if (!nodeId.success) { | ||
| res.status(400).json({ success: false, error: 'invalid node id' }); | ||
| return; | ||
| } | ||
| const body = PatchAcknowledgementBodySchema.safeParse(req.body); | ||
| if (!body.success) { | ||
| res.status(400).json({ success: false, error: 'acknowledged must be a boolean' }); | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| const result = await setParagraphAcknowledged( | ||
| specId.data, | ||
| nodeId.data, | ||
| body.data.acknowledged, | ||
| body.data.actorLabel | ||
| ); | ||
| switch (result.status) { | ||
| case 'not-found': | ||
| res.status(404).json({ success: false, error: 'paragraph not found' }); | ||
| return; | ||
| case 'wrong-spec': | ||
| res.status(403).json({ success: false, error: 'paragraph does not belong to this spec' }); | ||
| return; | ||
| case 'not-acknowledgeable': | ||
| res.status(422).json({ | ||
| success: false, | ||
| error: `node type "${result.nodeType}" cannot be acknowledged — only note nodes and textBox objects are`, | ||
| }); | ||
| return; | ||
| case 'updated': | ||
| res.status(200).json({ success: true, data: result.node }); | ||
| return; | ||
| } | ||
| } catch (err) { | ||
| const gate = gateErrorResponse(err); | ||
| if (gate) { | ||
| res.status(gate.status).json(gate.body); | ||
| return; | ||
| } | ||
| logger.error({ err }, 'acknowledge paragraph failed'); | ||
| res.status(500).json({ success: false, error: 'internal server error' }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import type { Router as RouterType } from 'express'; | ||
| import { acknowledgeParagraphHandler } from './paragraph-acknowledgement.js'; | ||
| import { | ||
| patchEditabilityHandler, | ||
| reclassifyHandler, | ||
| acceptAsNoteHandler, | ||
| closeCommentHandler, | ||
| } from './editability.js'; | ||
|
|
||
| /** | ||
| * Wires the editability/comment-resolution and readiness-finding-clearing | ||
| * routes onto the shared router instance — extracted out of router.ts to | ||
| * keep it under the enforced ESLint `max-lines: 400` (project override, | ||
| * CLAUDE.md), mirroring `registerCheckpointRoutes`'s identical extraction. | ||
| * The last two routes are new in #545 (ADR-079 follow-on) — acknowledgement | ||
| * and comment closure, the two remaining supported paths to clear a | ||
| * readiness finding. Registers directly on `router` (never a mounted | ||
| * sub-router) so `expressRouteManifest` | ||
| * (src/test-utils/contract/validate-response.js), which only walks one level | ||
| * of `router.stack`, still sees every route. | ||
| */ | ||
| export function registerParagraphClearanceRoutes(router: RouterType): void { | ||
| router.patch('/specs/:id/paragraphs/:nodeId/editability', patchEditabilityHandler); | ||
| router.post('/specs/:id/reclassify', reclassifyHandler); | ||
| router.post('/specs/:id/paragraphs/:nodeId/comments/:index/accept-as-note', acceptAsNoteHandler); | ||
| router.patch('/specs/:id/paragraphs/:nodeId/acknowledgement', acknowledgeParagraphHandler); | ||
| router.patch('/specs/:id/paragraphs/:nodeId/comments/:index/closure', closeCommentHandler); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.