-
Notifications
You must be signed in to change notification settings - Fork 0
CON-188: add per-post Notes entity (post_notes) #103
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
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| @baseUrl = http://localhost:9001 | ||
|
|
||
| # Per-post Notes CRUD (CON-188). A note is a small standalone record attached to | ||
| # a post: a draft thesis, an image prompt, or a free-form note. | ||
| # | ||
| # All endpoints require authentication. | ||
| # Run "Login" from sessions/sessions.http first — the HTTP client stores and | ||
| # sends the cookie automatically on subsequent requests to the same host. | ||
| # | ||
| # Prerequisites: | ||
| # - A post ID stored in {{postId}} (run posts/posts.http → createPost) | ||
| # | ||
| # Notes are returned draft_thesis-first, then oldest-first by created_at. | ||
| # `type` — draft_thesis | image_prompt | note (validated in Go; the set grows) | ||
| # `origin` — manual (REST) | assistant | content_plan (server-stamped, read-only) | ||
|
|
||
| ### List a post's notes [protected] | ||
| GET {{baseUrl}}/api/posts/{{postId}}/notes | ||
| Accept: application/json | ||
|
|
||
| ### Create note — free-form note [protected] | ||
| # @name createNote | ||
| POST {{baseUrl}}/api/posts/{{postId}}/notes | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "type": "note", | ||
| "title": "Fact-check", | ||
| "body": "Verify the Q3 revenue figure before publishing." | ||
| } | ||
|
|
||
| > {% client.global.set("noteId", response.body.id) %} | ||
|
|
||
| ### Create note — image prompt (no title) [protected] | ||
| POST {{baseUrl}}/api/posts/{{postId}}/notes | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "type": "image_prompt", | ||
| "body": "A photorealistic ripe banana on a neon-lit desk, shallow depth of field." | ||
| } | ||
|
|
||
| ### Create note — missing body (expects 400) [protected] | ||
| POST {{baseUrl}}/api/posts/{{postId}}/notes | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "type": "note", | ||
| "title": "Empty" | ||
| } | ||
|
|
||
| ### Create note — invalid type (expects 400) [protected] | ||
| POST {{baseUrl}}/api/posts/{{postId}}/notes | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "type": "nonsense", | ||
| "body": "This should be rejected." | ||
| } | ||
|
|
||
| ### Get note by ID [protected] | ||
| GET {{baseUrl}}/api/posts/{{postId}}/notes/{{noteId}} | ||
| Accept: application/json | ||
|
|
||
| ### Update note — edit the body [protected] | ||
| PATCH {{baseUrl}}/api/posts/{{postId}}/notes/{{noteId}} | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "body": "Verify the Q3 AND Q4 revenue figures before publishing." | ||
| } | ||
|
|
||
| ### Update note — reclassify as an image prompt [protected] | ||
| PATCH {{baseUrl}}/api/posts/{{postId}}/notes/{{noteId}} | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "type": "image_prompt" | ||
| } | ||
|
|
||
| ### Update note — empty patch (expects 400) [protected] | ||
| PATCH {{baseUrl}}/api/posts/{{postId}}/notes/{{noteId}} | ||
| Content-Type: application/json | ||
|
|
||
| {} | ||
|
|
||
| ### Delete note [protected] | ||
| DELETE {{baseUrl}}/api/posts/{{postId}}/notes/{{noteId}} | ||
|
|
||
| ### Delete note — non-existent ID (expects 404) [protected] | ||
| DELETE {{baseUrl}}/api/posts/{{postId}}/notes/nonexistent |
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,2 @@ | ||
| -- CON-188: drop the per-post Notes table. | ||
| DROP TABLE IF EXISTS post_notes; |
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,23 @@ | ||
| -- CON-188: per-post Notes. A note is a small standalone record (draft thesis, | ||
| -- image prompt, or free-form note) attached to a post, so ancillary content | ||
| -- lives here instead of in the post body. Tenant-scoped from the start (CON-97). | ||
| -- | ||
| -- `type` has no CHECK constraint on purpose: the vocabulary is expected to grow | ||
| -- and is validated in Go (models.PostNoteType). `origin` is a stable, closed | ||
| -- set, so it carries a CHECK. | ||
| CREATE TABLE post_notes ( | ||
| id TEXT PRIMARY KEY, | ||
| post_id TEXT NOT NULL REFERENCES posts (id) ON DELETE CASCADE, | ||
| type TEXT NOT NULL, | ||
| title TEXT NOT NULL DEFAULT '', | ||
| body TEXT NOT NULL, | ||
| origin TEXT NOT NULL DEFAULT 'manual' | ||
| CHECK (origin IN ('manual', 'assistant', 'content_plan')), | ||
| tenant_id TEXT NOT NULL REFERENCES tenants (id), | ||
| created_by TEXT NOT NULL REFERENCES users (id) ON DELETE CASCADE, | ||
| created_at TIMESTAMPTZ NOT NULL DEFAULT now(), | ||
| updated_at TIMESTAMPTZ NOT NULL DEFAULT now() | ||
| ); | ||
|
|
||
| CREATE INDEX idx_post_notes_post_id ON post_notes (post_id); | ||
| CREATE INDEX idx_post_notes_tenant_id ON post_notes (tenant_id); |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Align the generated-field contract.
persistOnenow treatsDraftPost.Bodyas a bullet-point thesis.src/genkit/flows/content_plan/types.gostill instructs the model to generate “Complete post copy adapted to the platform”.The model can generate publishable copy, but this flow stores it as
draft_thesisand leavesPost.Contentempty. Update theDraftPost.BodyJSON schema description and the content-plan prompt to request a thesis consistently.Proposed contract update
🤖 Prompt for AI Agents