📘

AI-Powered-Documentation-Workspace

🎯

Mission (canonical, v1.3.0 — project-final polish). The whole application is an AI-powered professional documentation workspace. Its main purpose is to help users create, organize, improve, rewrite, summarize, publish, and maintain professional documentation with the help of ChatGPT / AI. Think of it as a modern AI-powered documentation platform with productivity quality on par with the best in the category — built as an original high-end product. This mission block is verbatim canonical and must be mirrored at the top of docs/PRODUCT_OVERVIEW.md, CLAUDE.md, and .claude/RULES.md. AI is the core surface of this product, not a side feature: every page, block, comment, database row, file and template participates in the AI + RAG loop.

🧩

Integrated STV sub-pack (v1.3.0, project-final). This pack is physically nested as a sub-page of the parent master hub AI Coding Agent Workspace — Spec Pack (SPEC-HUB v1.4.0+). The project ships two product lines under one master hub with one §SoT system, one Spec Registry, one CHANGELOG_AI, one reviewer pool. The two product lines remain conceptually distinct (AI Coding Agent platform vs. AI-Powered Documentation Workspace — different end users, different domain objects, different sync target trees) so contributors keep mental clarity, but governance is unified. See §9 of the parent hub for the integrated product-line identity matrix, the cross-pollination path, and §10 of the parent hub for the production-ready Claude Code build prompt that drives both product lines.

📘

This is the master specification pack for the AI-Powered Professional Documentation Workspace (internal codename: StevoApp) — a scalable, AI-first professional documentation platform. It is the single source of truth for product, architecture, database, editor system, AI/RAG, search, mobile/desktop UX, sharing/permissions, version history, files, import/export, activity log, admin, scalability, API and security. Every sub-page mirrors 1:1 into a docs/ folder in the codebase. The pack is governed by the §SoT system of the parent project (which also hosts it as a sub-pack) — every page is a versioned spec with owner, authority, sync targets, conflict rule and change policy.

🚫

Forbidden in StevoApp. Business logic in frontend · AI provider keys in frontend or in .env exposed to client · controllers over 200 LOC · unsigned URLs for private files · SELECT * on hot paths · loading the full workspace tree without pagination or lazy expand · storing a full duplicate page snapshot per edit (use event-based versioning or smart diffs) · raw HTML from the editor without sanitization · file uploads without MIME + size validation · public share links without a tokenized URL · using Notion's branding, logo, exact UI, proprietary design, colors, design tokens, icon set, or any copyrighted elements · directly calling OpenAI / Anthropic from JavaScript or Swift · putting Filament in the end-user surface · using PHP-FPM, Nginx default config, or PostgreSQL-as-default (MySQL/MariaDB is the SQL source of truth).

📱

Posture. Desktop-optimized, mobile-responsive from day one. Native iPhone app is post-v1; mobile web must be excellent before any native client ships.

0 · Executive summary

This product is an AI-powered professional documentation workspace. Its purpose is to help users create, organize, improve, rewrite, summarize, publish, and maintain professional documentation with the help of ChatGPT / AI — a modern AI-first documentation platform with productivity quality on par with the best in the category, built as an original high-end product (no Notion branding, logo, exact UI, proprietary design, colors, or copyrighted elements). Users create workspaces, organize pages and subpages with unlimited nesting, edit with a block-based editor (28 block types), build flexible databases with table / board / list / gallery / calendar views, use a library of professional templates, run AI text transforms on selection, query a RAG knowledge base scoped to their workspace, search globally with Cmd/Ctrl + K, share pages privately or via tokenized public link, and audit every important action. The product is desktop-optimized and mobile-responsive from v1 on a clean Laravel core with a thin Livewire UI. Filament powers admin only.

0.5 · Design principles & professional posture

Twelve principles, ordered. Each is a tie-breaker for design disagreements: when two implementation choices would both satisfy the spec, the higher-numbered principle wins. New contributors should read these once and refer back when a design call feels ambiguous.

  1. Documentation is the product. Every UX decision is evaluated by whether it makes a documentation-author faster, calmer, and more confident. Editor speed beats feature count. Latency budgets in §15 are non-negotiable.
  1. AI is a peer, not a side feature. Every text surface, every block, every cell, every comment participates in the AI + RAG loop. There is no "AI tab" — the AI lives inline, contextually, with citations.
  1. Preview before apply. AI never writes user content without an explicit human confirmation. This is non-negotiable across web, mobile-web, and the future native client. Auto-apply is a security and trust regression.
  1. Workspace-scoped everything. RAG never crosses workspace boundaries. Search never crosses workspace boundaries. Templates marked global are read-only and curated by admins. Cross-workspace leakage is a SEV-1 incident.
  1. Mobile-web before native. The mobile-web experience must be fluent before a SwiftUI app ships. No feature is "desktop-only" without an explicit mobile_omitted note in the Registry row and a one-line justification.
  1. Lazy load by default. The page tree, the editor block list, the database row set, and the search result list all paginate. Loading a workspace must not load a workspace. Cursor pagination on every hot list.
  1. Original product, original UI. No Notion branding, logo, exact UI, design tokens, icon set, or proprietary patterns. Inspiration is fine; pixel imitation is forbidden. The CI lint ui-originality-check keeps a regex denylist of visual tells (specific class names, exact hex colors, exact iconography).
  1. One brain, two surfaces. The Laravel API is the single backend; the web client and the future SwiftUI client are both consumers. Domain logic never lives in either client. The parity test asserts this.
  1. Event-based history wins over snapshots. Page versions are diffs, not full payloads. Restore is a deterministic replay. Storage cost is bounded by edit count, not page size.
  1. Sanitization at the edge. All user-provided HTML, Markdown, and AI output passes through SanitizerService before persistence. There are no "trusted blocks" — even server-generated content is sanitized on write.
  1. Idempotent jobs. Every queued operation (RAG reindex, export, file commit, AI transform persistence) is keyed by a content hash and is safe to retry. Failed jobs auto-retry with capped exponential backoff; the cap is documented in §15.
  1. Audit everything mutable. Every state change writes one row to activity_logs. The audit log is append-only, includes actor + IP + user-agent, and ships with the export bundle. No silent state changes.

1 · Product vision

A documentation operating system powered by AI, not a simple editor. The seven canonical verbs are first-class capabilities, each backed by concrete services in this pack:

VerbWhere it lives
CreateBlock-based editor (SPEC-STV-04), templates (SPEC-STV-06), AI generate (SPEC-STV-08 §2 generate_*).
OrganizeWorkspaces, page tree, databases + views (SPEC-STV-05), tags, favorites, search (SPEC-STV-09).
ImproveAI selection actions improve, expand, make_professional, make_longer (SPEC-STV-08 §2); mobile select-to-edit (SPEC-STV-13 §6).
RewriteAI rewrite, simplify, make_shorter, translate (SPEC-STV-08 §2); preview gate is mandatory (SPEC-STV-08 §3).
SummarizeAI summarize, generate_meeting_summary, generate_outline (SPEC-STV-08 §2); RAG-cited (SPEC-STV-07).
PublishPer-user shares, workspace visibility, tokenized public links with password + expiry, premium mobile public-page reader (SPEC-STV-11 §2–4, SPEC-STV-13 §11).
MaintainEvent-based version history + restore (SPEC-STV-04 §8), RAG re-index pipeline (SPEC-STV-07 §6), activity log (SPEC-STV-12 §2), CHANGELOG_AI (SPEC-STV-12 §7), import/export (SPEC-STV-12 §3–4).

Every document, page, block, database row, file, comment, version, AI transformation, share link and permission is modeled cleanly and scalably. The architecture supports:

  • single-user → small team → large team scaling without rewrite,
  • desktop web, tablet, mobile web, and a future SwiftUI client,
  • workspace-scoped AI with RAG that cites internal pages,
  • a templating system covering SOPs, product specs, API docs, wikis, roadmaps, meeting notes, knowledge bases.

2 · Architecture overview

flowchart LR
	Web(["Web client<br>Livewire 3 + Alpine + Tailwind"]) -->|HTTPS + Reverb WS| API["Laravel API + Web"]
	Mob(["Mobile web / future SwiftUI"]) -->|HTTPS + SSE| API
	Adm(["Admin operator<br>Filament panel"]) -->|HTTPS| API
	API --> Pages["PageService"]
	API --> Blocks["BlockService"]
	API --> DBs["DatabaseService"]
	API --> Search["SearchService"]
	API --> AI["AiTransformService"]
	API --> RAG["RagService"]
	API --> Share["ShareService"]
	API --> Files["FileService"]
	API --> Activity["ActivityLogService"]
	AI --> Providers{"Provider"}
	Providers -->|OpenAI| OAI["OpenAI"]
	Providers -->|Claude| CLA["Anthropic"]
	RAG --> Index["RagIndexer<br>(queued)"]
	Index --> Store[("rag_chunks<br>(MySQL JSON / pgvector opt-in)")]
	Files --> S3[("S3-compatible storage")]
	API --> Cache[("Redis<br>cache / locks / queues / Horizon / Reverb")]
	API --> DB[("MySQL / MariaDB")]

3 · Tech stack (locked)

LayerChoiceWhy
FrameworkLaravel 11 (12 when GA)Mature HTTP / queue / auth / events.
SQLMySQL 8 / MariaDB 11.4+Default; JSON columns for block content + cell values.
Cache / queues / locks / pub-subRedis 7Horizon, Reverb, atomic locks, cached permissions.
Job runnerLaravel HorizonObservable workers for indexing, exports, AI.
RealtimeLaravel Reverb (WS) + SSEWS for presence/autosave; SSE for AI token streaming.
Web UILivewire 3 + Alpine.js + TailwindSSR-first with reactive islands.
AdminFilament v3Admin / control panel only.
APIREST + Sanctum tokensMobile + future SwiftUI.
SearchLaravel Scout + Meilisearch (v1); MySQL FULLTEXT fallbackFast typo-tolerant search; pluggable later.
StorageS3-compatible (AWS S3 / R2 / MinIO)Signed URLs for private files.
AIOpenAI + Anthropic via app/Services/Ai/*Provider-agnostic; streaming where useful.
RAGEmbeddings in rag_chunks (MySQL JSON default; pgvector opt-in)Workspace-scoped retrieval with citations.
AuthSession (web) + Sanctum (API)Mobile-friendly.

4 · The 24 modules (canonical catalogue)

#ModuleOwner specOne-liner
1Workspace SystemSPEC-STV-01Workspaces, members, roles, settings, storage limits.
2Page SystemSPEC-STV-01Pages with unlimited nesting, icon, cover, status, favorites.
3Block-Based EditorSPEC-STV-0428 block types, JSON content, nested blocks, indexed by (page_id, position).
4Editor UXSPEC-STV-04Slash menu, drag handle, floating toolbar, autosave, mobile/desktop modes.
5Databases / TablesSPEC-STV-05Properties, rows, cell values, views (table/board/list/gallery/calendar).
6TemplatesSPEC-STV-06Reusable, categorized, save-as / duplicate / preview.
7AI Writing AssistantSPEC-STV-08Select → ask → preview → replace / insert / copy / discard.
8RAG Knowledge BaseSPEC-STV-07Workspace-scoped index, citations, incremental reindex, stale detection.
9SearchSPEC-STV-09Cmd/Ctrl + K palette across pages/blocks/files/comments/databases.
10Mobile + Desktop UXSPEC-STV-10Sidebar/tree/editor/context on desktop; drawer + bottom-nav on mobile.
11Sharing & PermissionsSPEC-STV-11Roles: owner / admin / editor / commenter / viewer. Tokenized public links.
12Comments & CollaborationSPEC-STV-12Page + block comments, mentions, resolve, activity feed.
13Version HistorySPEC-STV-04Event-based versioning + smart snapshots; restore, compare later.
14File & Media LibrarySPEC-STV-02Images, PDFs, videos (embed), signed URLs, usage tracking.
15Import / ExportSPEC-STV-12Markdown / HTML in; Markdown / PDF / HTML / JSON out. Queued.
16Activity & Audit LogSPEC-STV-12Append-only activity_logs table, indexed by actor + entity.
17Admin / Control CenterSPEC-STV-11Users, workspaces, plans, AI/RAG status, queue health, audit.
18ScalabilitySPEC-STV-11Lazy load, indexed hot paths, queued heavy ops, cached permissions.
19Database DesignSPEC-STV-0223 tables (see §5).
20API DesignSPEC-STV-03REST + Sanctum, paginated, mobile-friendly.
21TestingSPEC-STV-12Pest feature + unit tests; policy & API contract.
22SecuritySPEC-STV-11Policies, signed URLs, sanitization, rate limit, secret hygiene.
23DocumentationSPEC-STV-1213 docs/*.md files + 6 .cursor/rules/*.mdc.
24Acceptance CriteriaSPEC-STV-HUBSee §11 of this hub.

5 · Database plan (23 tables, schema overview)

Every table: PK id (bigint unsigned), created_at / updated_at, soft-delete where relevant, FK with restrictOnDelete or cascadeOnDelete as noted. JSON columns are validated by service-layer schema. Hot-path indexes are listed inline.

#TablePurposeKey columnsHot indexes
1usersApp users.email (uniq), name, avatar_url, locale, last_seen_atemail
2workspacesTop-level container.name, slug (uniq), icon, cover_url, owner_id, default_language, storage_limit_bytes, ai_settings JSON, rag_settings JSONslug, owner_id
3workspace_membersUser ↔ workspace ↔ role.workspace_id, user_id, role (owner|admin|editor|commenter|viewer), invited_at, joined_atuniq (workspace_id, user_id)
4pagesPage tree node.workspace_id, parent_page_id (nullable), path (materialized), title, icon, cover_url, sort_position, visibility (private|workspace|shared|public), status (draft|live|archived), author_id, last_edited_by, favorite_for JSON, seo JSON, archived_at(workspace_id, parent_page_id, sort_position), (workspace_id, status), (path) (prefix)
5page_blocksBlock instances.page_id, parent_block_id (nullable), type, content JSON, position (fractional or integer), metadata JSON, created_by, updated_by(page_id, position), (parent_block_id, position), type
6page_versionsEvent-based version history.page_id, version_number, author_id, op (title|block_add|block_update|block_delete|move|restore), payload JSON (compact diff), snapshot_hash, created_at(page_id, version_number), (page_id, created_at)
7documentation_databasesA database object (≠ MySQL database).page_id (host), workspace_id, name, default_view_idworkspace_id, page_id
8database_propertiesColumn schema for a database.database_id, name, type (text|number|select|multi_select|date|checkbox|user|file|url|email|phone|status|relation|formula), config JSON, position(database_id, position)
9database_rowsRow in a database (≠ page_blocks).database_id, position, created_by, archived_at(database_id, position)
10database_cell_valuesPolymorphic cell storage.row_id, property_id, value JSON, value_text (denormalized for search), value_number (denorm), value_date (denorm)uniq (row_id, property_id), (property_id, value_text)
11database_viewsView configuration.database_id, name, type (table|board|list|gallery|calendar|timeline), config JSON (filters, sort, group), sort_position(database_id, sort_position)
12commentsPage or block comments.workspace_id, page_id, block_id (nullable), parent_comment_id (thread), author_id, body, body_html (sanitized), resolved_at, resolved_by(page_id, created_at), (block_id), resolved_at
13mentions@user mentions inside comments / blocks.workspace_id, source_type (comment|block), source_id, user_id, read_at(user_id, read_at)
14filesUploaded file objects.workspace_id, uploader_id, disk, path, mime, size_bytes, original_name, checksum, attached_count, deletable_atworkspace_id, checksum
15templatesReusable page or database templates.workspace_id (nullable for global), category, name, description, payload JSON (page + blocks), preview_image_url, created_by(workspace_id, category)
16tagsFree-form tags.workspace_id, name (uniq per workspace), coloruniq (workspace_id, name)
17sharesPer-user share grants.workspace_id, page_id, user_id, role, granted_by, granted_atuniq (page_id, user_id)
18share_linksTokenized public links.page_id, token (uniq), mode (view|comment), password_hash (null), expires_at, created_byuniq token, (page_id)
19permissionsCompiled effective permissions cache.workspace_id, page_id, user_id, role_effective, source (workspace|share|link), computed_atuniq (page_id, user_id)
20activity_logsAudit trail.workspace_id, actor_id, entity_type, entity_id, action, payload JSON, ip, ua, created_at(workspace_id, created_at), (actor_id, created_at), (entity_type, entity_id)
21ai_text_transformationsEvery AI run on selection.workspace_id, user_id, action, model, input_text, output_text, applied (bool), tokens_in, tokens_out, cost_usd, created_at(workspace_id, created_at), (user_id)
22rag_chunksEmbedded chunks for RAG.workspace_id, source_type (page|block|comment|file|template|db_row), source_id, chunk_index, text, embedding JSON, content_hash, indexed_at(workspace_id), (source_type, source_id), content_hash
23settingsPer-workspace and global config.workspace_id (nullable for global), key, value JSON, updated_byuniq (workspace_id, key)

6 · API surface (REST + Sanctum)

All responses paginated (?per_page capped at 100). Cursor pagination on hot lists. Every endpoint goes through a Policy; never trust the client.

ResourceEndpoints (sample)Notes
AuthPOST /api/v1/auth/login, /logout, /me, /tokensSanctum personal access tokens.
WorkspacesGET/POST /api/v1/workspaces, GET/PATCH/DELETE /api/v1/workspaces/{id}, GET /members, POST /membersOwner-only destructive.
PagesGET /api/v1/workspaces/{ws}/pages?parent=…, POST, PATCH /pages/{id}, POST /pages/{id}/archive, POST /pages/{id}/restore, POST /pages/{id}/moveCursor-paginate children.
BlocksGET /api/v1/pages/{id}/blocks?after=…, POST /blocks, PATCH /blocks/{id}, POST /blocks/{id}/move, DELETE /blocks/{id}Bulk patch supported.
DatabasesPOST /api/v1/databases, GET /databases/{id}/rows?view=…, POST /databases/{id}/rows, PATCH /rows/{id}/cells, POST /databases/{id}/viewsView config controls filter/sort/group server-side.
TemplatesGET /api/v1/templates?category=…, POST /templates/{id}/instantiate, POST /pages/{id}/save_as_templateGlobal templates seeded.
SearchGET /api/v1/search?q=…&types=page,block,file,database&workspace=…Meilisearch-backed.
CommentsGET /api/v1/pages/{id}/comments, POST /comments, POST /comments/{id}/resolveMentions broadcast a notification.
FilesPOST /api/v1/files/presign, POST /files/commit, GET /files/{id}/signed-urlDirect-to-S3 upload, server commits metadata.
SharingPOST /api/v1/pages/{id}/share-link, DELETE /share-links/{token}, GET /public/{token}Public read endpoint rate-limited.
AIPOST /api/v1/ai/transform (SSE stream), POST /ai/generateSelection-scoped, never auto-applies.
RAGPOST /api/v1/rag/query, POST /rag/reindex (admin), GET /rag/statusAnswers cite source pages.
ActivityGET /api/v1/workspaces/{id}/activity?entity=…Read-only.
SettingsGET /api/v1/workspaces/{id}/settings, PATCH /settings/{key}Admin gated.

7 · Implementation phases (P0 → P6)

PhaseGoalScope (must-haves)Out of scope
P0Foundationusers, workspaces, workspace_members, pages, page_blocks (paragraph + h1-h3 + bullet/numbered/checklist + divider), auth, autosave, mobile shell.Templates, AI, RAG, databases, comments.
P1Full editorAll 28 block types (incl. callout, code, image, video embed, file, toggle, TOC, breadcrumb, link preview), slash menu, floating toolbar, drag handle, page_versions (event-based), mobile editor polish.Synced blocks, database views inline, AI block.
P2Databasesdocumentation_databases, database_properties, database_rows, database_cell_values, database_views (table/board/list/gallery/calendar). Views surface as block types inside pages.Formulas, relations, rollups, timeline.
P3Collaborationcomments, mentions, shares, share_links, permissions cache, activity_logs, Filament admin (users, workspaces, audit).Realtime cursors, live presence.
P4AI + RAGai_text_transformations, AI selection editor (preview gate), rag_chunks, indexer queue, /api/v1/ai/*/api/v1/rag/*, citations to source pages, ON/OFF per workspace.Agents, runs, multi-step tool calls.
P5Templates + I/Otemplates (global + workspace), import (MD/HTML/CSV → database), export (MD/PDF/HTML/JSON), file_versions queued.DOCX, PDF text extraction.
P6Admin + scalequeue health, failed jobs panel, storage limits enforcement, public-page rate limit, permissions cache invalidation, Meilisearch tuning.SwiftUI client (separate spec when ready).

Policy: each phase ships its own migrations, services, Livewire components, Filament resources (if applicable), tests, and docs/ updates. No phase merges without green CI + a CHANGELOG_AI.md entry.

8 · Test plan

LayerExamples
Feature (HTTP + DB)workspace create/invite, page CRUD, nested page move, block reorder, share link redeem, public page rate limit, AI transform happy + denial, RAG query returns citations, version restore.
UnitBlockService position math, PermissionsResolver, SanitizerService, RagChunker, ExportRenderer.
Policyviewer cannot edit, commenter cannot create block, IDOR across workspaces, archived page is read-only.
API contractOpenAPI snapshot test; mobile-shape responses (pagination meta, ISO timestamps, signed URLs).
Browser (Dusk, optional)slash menu opens, drag handle reorders, autosave indicator transitions, command-K search jumps to page.
QueueRAG reindex idempotent on same content_hash; export job finishes; failed jobs retry capped.

9 · Docs plan

13 mandatory docs/*.md files + 6 .cursor/rules/*.mdc. Each doc carries a SoT spec header (mirrored from its Notion page).

#FileOwner specBrief
1docs/PRODUCT_OVERVIEW.mdSPEC-STV-00Vision, scope, non-goals, arch lock.
2docs/ARCHITECTURE.mdSPEC-STV-01Modules, service map, diagrams.
3docs/DATABASE_SCHEMA.mdSPEC-STV-02All 23 tables, columns, indexes, FK, JSON shapes.
4docs/API_ENDPOINTS.mdSPEC-STV-03Every endpoint, auth, abilities, request/response.
5docs/EDITOR_SYSTEM.mdSPEC-STV-04Block model, autosave, version history, UX rules.
6docs/BLOCK_TYPES.mdSPEC-STV-04All 28 block types with content JSON shape.
7docs/TEMPLATE_SYSTEM.mdSPEC-STV-06Template payload, categories, instantiate flow.
8docs/RAG_SYSTEM.mdSPEC-STV-07Sources, chunking, embedding, retrieval, secret exclusion.
9docs/AI_ASSISTANT.mdSPEC-STV-08Actions, prompts, preview gate, abilities.
10docs/MOBILE_UX.mdSPEC-STV-10Responsive rules, mobile-only flows.
11docs/SECURITY.mdSPEC-STV-11Threat model, policies, signed URLs, sanitization.
12docs/SCALABILITY.mdSPEC-STV-11Pagination, caching, queues, indexes.
13docs/CHANGELOG_AI.mdSPEC-STV-12Append-only log of AI-assisted changes.

Cursor rules: .cursor/rules/project-overview.mdc, database.mdc, editor.mdc, security.mdc, rag.mdc, mobile.mdc.

10 · §SoT · STV sub-registry (mirrored into parent master §SoT.5)

This is the STV sub-registry of the parent project. The rows below are the canonical list for the STV product line and are pointed to from the parent master §SoT.5 (single source of truth: this section). Conflict ladder within STV: SPEC-STV-HUB > Architecture-tier (-01, -02) > Specification-tier (-03 … -11, -13) > Reference-tier (-12). Cross-product-line conflicts: parent SPEC-HUB v1.4.0+ wins (it defined the §SoT system).

Spec IDTitleVersionStatusAuthorityPriorityOwner rolePrimary sync targets
SPEC-STV-HUBAI-Powered Professional Documentation Workspace — STV sub-pack root (this page, nested under parent SPEC-HUB)1.3.0ApprovedConstitutionalP0Product architectdocs/PRODUCT_OVERVIEW.md lock block, docs/SPEC_REGISTRY.md
SPEC-STV-00Product Overview & Goals1.1.0ApprovedSpecificationP0Product architectdocs/PRODUCT_OVERVIEW.md
SPEC-STV-01Architecture & Modules1.0.0ApprovedArchitectureP0Backend architectdocs/ARCHITECTURE.md, app/Services/**
SPEC-STV-02Database Schema1.0.0ApprovedArchitectureP0Database architectdatabase/migrations/**, docs/DATABASE_SCHEMA.md
SPEC-STV-03API Endpoints1.0.0ApprovedSpecificationP0Backend architectroutes/api.php, app/Http/Controllers/Api/**, docs/API_ENDPOINTS.md
SPEC-STV-04Editor System & Block Types1.0.0ApprovedSpecificationP0Frontend leadresources/js/editor/**, app/Services/Blocks/**, docs/EDITOR_SYSTEM.md, docs/BLOCK_TYPES.md
SPEC-STV-05Databases / Tables1.0.0ApprovedSpecificationP1Backend architectapp/Services/Databases/**, docs/DATABASE_SCHEMA.md (db tables section)
SPEC-STV-06Template System1.0.0ApprovedSpecificationP1Frontend leadapp/Services/Templates/**, docs/TEMPLATE_SYSTEM.md
SPEC-STV-07RAG Knowledge Base1.0.0ApprovedSpecificationP0RAG engineerapp/Services/Rag/**, docs/RAG_SYSTEM.md
SPEC-STV-08AI Writing Assistant1.0.0ApprovedSpecificationP0AI workflow leadapp/Services/Ai/**, resources/js/ai-selection/**, docs/AI_ASSISTANT.md
SPEC-STV-09Search1.0.0ApprovedSpecificationP1Backend architectapp/Services/Search/**, Meilisearch config
SPEC-STV-10Mobile & Desktop UX1.0.0ApprovedSpecificationP0Frontend leadresources/views/**, resources/js/ui/**, docs/MOBILE_UX.md
SPEC-STV-11Sharing, Permissions, Security, Scalability, Admin1.0.0ApprovedSpecificationP0Security leadapp/Policies/**, app/Filament/**, docs/SECURITY.md, docs/SCALABILITY.md
SPEC-STV-12Comments, Activity Log, Import/Export, Testing, Docs, CHANGELOG1.0.0ApprovedReferenceP1Docs leadapp/Services/Activity/**, docs/CHANGELOG_AI.md, .cursor/rules/**
SPEC-STV-13Mobile Gestures & Text Selection Editor1.0.0ApprovedSpecificationP0Frontend lead (mobile)docs/MOBILE_GESTURES_AND_TEXT_SELECTION_EDITOR.md, resources/js/editor/mobile/**, resources/js/ai-selection/mobile/**, .cursor/rules/mobile.mdc

11 · Acceptance criteria (project is shippable when)

  1. User can sign up, create a workspace, invite a member with a role.
  1. User can create pages and subpages with unlimited nesting.
  1. Block editor supports all 28 types; slash menu, drag handle, floating toolbar work on desktop and mobile.
  1. Autosave is visible and reliable; no edit is lost on tab close.
  1. Version history records every meaningful edit and supports restore.
  1. User can create a database, define properties, add rows, switch between table / board / list / gallery / calendar views, filter and sort server-side.
  1. Templates: instantiate from library; save page as template; preview before instantiate.
  1. AI selection editor: select text → ask → preview → replace / insert below / copy / discard. Never auto-applies. Rate-limited.
  1. RAG: workspace-scoped index runs in queue; AI Q&A cites internal pages; ON/OFF per workspace.
  1. Global search via Cmd/Ctrl + K: pages, blocks, files, comments, databases, templates.
  1. Sharing: private / workspace / per-user / tokenized public link. View, comment, edit modes. Public pages rate-limited.
  1. Comments + mentions + activity feed work; admin sees full audit log.
  1. Mobile web is fluent: editor, search, share, AI, RAG all usable on phone.
  1. All 13 docs/*.md mirror their Notion specs and pass claude-rules-lint + spec-registry-lint.
  1. Pest test suite green; API contract test green; policy tests green.
  1. No secret value reachable through any response, doc, or RAG chunk.
  1. UI is clean, modern, fast, and original (no Notion branding or copyrighted assets).

12 · Open questions (carry into next refactor pass)

  1. Self-host vs SaaS pricing model — affects storage limits + plans table shape (not in v1 schema).
  1. Realtime cursors (Yjs / Tiptap collab) — defer until P3 post-launch.
  1. pgvector opt-in or stay JSON-only for v1? Default: JSON; opt-in flag in rag_settings.
  1. Meilisearch managed (cloud) vs self-host — both supported by Scout.
  1. Block-level encryption for sensitive workspaces — gated to enterprise tier.
  1. Native iPhone (SwiftUI) cut-in — only after mobile-web parity is signed off.
  1. AI provider default — OpenAI gpt-4.1 vs Claude 3.7-sonnet; per-workspace setting.
  1. Public share password protection + expiration — design ready, ship in P5.

13 · Sub-pages (live, nested under this hub)

The 13 STV sub-specs are now physically nested under this hub so the tree reads master hub → STV-HUB → STV-XX cleanly. The canonical list is:

14 · Cross-cutting non-functional requirements

The 24 modules of §4 each pass through these gates. Treat them as horizontal contracts: any module that fails one of these is not shippable, regardless of which phase landed it. A regression on any §14 gate opens a Hardening (P11) or Performance (P12) ticket in the same edit pass.

§14.1 · Accessibility (WCAG 2.2 AA target)

  • Keyboard parity for every editor interaction (slash menu, drag handle, floating toolbar, version restore, slash actions, public reader navigation).
  • Focus rings on every interactive element; prefers-reduced-motion respected on every animation.
  • Color contrast ≥ 4.5:1 for body, ≥ 3:1 for large text; tested in light + dark themes.
  • Screen-reader names for icons (aria-label or visually-hidden text); no icon-only buttons without labels.
  • Skip-to-content links on every page; sensible heading order (no skipped levels) inside the editor.

§14.2 · Internationalization

  • All UI strings flow through __() (Laravel) or the JS equivalent; no hard-coded English in views or components.
  • Date and number formatting via Intl APIs and Laravel formatLocalized(); never toLocaleString() without an explicit locale.
  • RTL layout supported in the editor and the public reader (mirrored toolbars, mirrored drag handles, mirrored block menus, mirrored slash menu anchor).
  • Content language is per-page (used by AI prompts and search analyzers); UI language is per-user (used by the chrome).

§14.3 · Observability

  • Every queued job emits a start and end log line with workspace_id, actor_id, entity_type, entity_id, duration_ms.
  • Every AI call records provider, model, tokens_in, tokens_out, cost_usd in ai_text_transformations.
  • Failed jobs panel in Filament admin; Sentry breadcrumbs scoped to workspace_id (never user PII).
  • Slow-query log on MySQL / MariaDB ≥ 200 ms; weekly review by Backend architect.
  • A workspace-scoped /admin/observability dashboard (Filament) surfaces queue depth, search latency, AI cost, RAG freshness.

§14.4 · Privacy & data handling

  • PII columns explicitly listed in docs/SECURITY.md; the export pipeline scrubs PII for public exports.
  • RAG ingestion excludes any block whose ancestry contains a private:true marker; verified by an indexer test.
  • Audit log retention: 365 days default, configurable per workspace.
  • A user-initiated workspace deletion runs a queued, fully-audited purge job; tombstones land in activity_logs with a purge action.
  • All exports of personal content require a fresh password challenge; tokens minted for export are single-use and expire in 15 minutes.

15 · Performance budgets & SLOs

These are aspirational v1 budgets; tightening is a SPEC-STV-HUB minor bump. Failing any budget for two consecutive weeks opens a Hardening or Performance ticket against the offending module.

SurfaceMetricBudgetSource of truth
Page load (first paint)P75 over 7d< 1.5 s desktop, < 2.5 s mobile-webWeb Vitals beacon → activity_logs
Block insert latencyP95 keystroke-to-render< 50 msEditor instrumentation
Autosave round tripP95< 350 ms LAN, < 800 ms mobile-webReverb ping/pong
AI selection round tripP95 first token< 1.2 sai_text_transformations.duration_ms
RAG queryP95< 600 ms at k=5RagService log
Search (Cmd/Ctrl + K)P95< 250 ms typo-tolerantScout / Meilisearch log
Public page renderP95< 1.0 s cachedLSCache hit log
Queue worker depthSteady-state< 100 jobs per workspaceHorizon metrics
Storage per workspaceDefault cap10 GB free tier; configurable per planworkspaces.storage_limit_bytes
Error budget30-day0.5% non-2xx on /api/v1/** (excl. 401/403)LSWS access log

16 · STV-side glossary

TermMeaning
WorkspaceTop-level container; one billing / storage unit; one tenant in v1.
PageA document node in the tree; can host blocks and a database.
BlockThe atomic editable unit. 28 types in v1. Stored as JSON in page_blocks.
Database (STV)A schema'd collection of rows attached to a page; not a MySQL database.
ViewA saved filter + sort + group configuration on a database (table / board / list / gallery / calendar).
TemplateA reusable page-and-blocks payload; global or per-workspace.
ShareA per-user grant of a role on a single page.
Share linkA tokenized URL granting read or comment access without an account.
RAG chunkAn indexed, embedded fragment of workspace content.
AI transformationOne run of a selection-scoped AI action; logged in ai_text_transformations.
Preview gateThe mandatory accept / replace / insert / discard step before any AI edit lands.
Activity logAppend-only audit trail in activity_logs, indexed by actor + entity.
Public pageA page exposed via /public/{token}, rate-limited, optionally password-gated.
Premium readerThe mobile-first read-only renderer for public pages (SPEC-STV-13 §11).
Workspace memberA users row joined to a workspaces row via workspace_members.
RoleOne of owner / admin / editor / commenter / viewer.

🔗

Back to parent. AI Coding Agent Workspace — Spec Pack — master hub (SPEC-HUB v1.4.0+), §9 hosts the integrated product-line matrix and §10 hosts the production-ready Claude Code build prompt that drives both product lines including this STV sub-pack.