.github/9
ISSUE_TEMPLATE/3bug_report.md config.yml feature_request.md
workflows/3ci.yml clean-clone.yml release.yml
CODEOWNERS dependabot.yml pull_request_template.md
apps/630
api/250
src/243
common/30
__tests__/3authorize.test.ts bigint-serialization.interceptor.test.ts files-limits.test.ts
filters/1all-exceptions.filter.ts
guards/3auth.guard.ts internal-service.guard.ts rate-limit.guard.ts
interceptors/2actor-context.interceptor.ts bigint-serialization.interceptor.ts
middleware/2idempotency.test.ts idempotency.ts
pipes/1zod-validation.pipe.ts
actor-context.ts audit.service.ts cache.test.ts cache.ts cookies.ts core.module.ts deprecation.ts email.service.ts errors.ts event-bus.ts log-scrubber.test.ts log-scrubber.ts logger.ts permission-cache-bridge.ts prisma.service.ts redis.service.ts trace-metadata.ts types.ts
config/1env.ts
lib/11
__tests__/5crypto.test.ts filter-builder.test.ts jwt.test.ts pagination.test.ts positions.test.ts
authorize.ts crypto.ts filter-builder.ts jwt.ts pagination.ts positions.ts
modules/197
ai/28
__tests__/4ai-writing.test.ts database-ai.test.ts generate-executor.test.ts prompts.test.ts
generator/4executor.ts generate.controller.ts generate.dto.ts generate.service.ts
ai-chat.service.ts ai-rate-limit.ts ai-writing.controller.ts ai-writing.dto.ts ai-writing.service.ts ai.controller.ts ai.module.ts ai.service.ts budget-guard.service.ts database-ai.controller.ts database-ai.dto.ts database-ai.service.ts db-prompts.ts dto.ts gateway-provider.ts ledger.service.ts prompts.ts rag.controller.ts rag.dto.ts rag.service.ts
api-keys/3api-keys.controller.ts api-keys.module.ts api-keys.service.ts
audit/2audit-log.controller.ts audit.module.ts
auth/4auth.controller.ts auth.module.ts auth.service.ts dto.ts
automations/5automations.controller.ts automations.module.ts automations.service.ts dto.ts webhook-incoming.controller.ts
blocks/5
__tests__/1batch-version-cas.test.ts
block.service.ts blocks.controller.ts blocks.module.ts dto.ts
comments/4comments.controller.ts comments.module.ts comments.service.ts dto.ts
databases/9
__tests__/3normalize-select-options.test.ts option-id-canonicalization.test.ts record-open-query-shape.test.ts
database.service.ts databases.controller.ts databases.module.ts dto.ts property-cache-schema.ts query.service.ts
docs/2docs.controller.ts docs.module.ts
files/10
__tests__/1quota.test.ts
dto.ts files.controller.ts files.module.ts files.service.ts quota.ts record.ts s3.ts uploads.controller.ts uploads.service.ts
forms/18debug.controller.ts form.dto.ts forms.controller.ts forms.module.ts forms.service.ts markdown.test.ts markdown.ts optional-auth.guard.ts public-forms.controller.ts public-forms.service.ts question.dto.ts questions.service.ts rate-limit.ts recaptcha.ts slug.ts submissions.controller.ts submissions.service.ts submit-schema.ts
health/3health.controller.ts health.module.ts health.service.ts
integrations/3integrations.controller.ts integrations.module.ts integrations.service.ts
internal/12
__tests__/2flush-query-shape.test.ts internal.endpoints.test.ts
ai-test-seam.controller.ts ai-test-seam.dto.ts ai-test-seam.service.ts internal.controller.ts internal.dto.ts internal.module.ts internal.service.ts test-seam.controller.ts test-seam.dto.ts test-seam.service.ts
notifications/3notifications.controller.ts notifications.module.ts notifications.service.ts
oauth/6
__tests__/1oauth.scopes.test.ts
oauth.controller.ts oauth.module.ts oauth.service.ts scopes.ts token-keys.ts
org/15audit.service.ts embed-preview.controller.ts guards.ts members.service.ts org-admin.controller.ts org-policy.service.ts org.module.ts overview.service.ts policy-effective.controller.ts policy.schema.ts policy.test.ts retention.service.ts totp.test.ts totp.ts two-factor.service.ts
orgs/5dto.ts orgs.controller.ts orgs.module.ts orgs.service.ts util.ts
pages/4dto.ts page.service.ts pages.controller.ts pages.module.ts
scim/15
__tests__/3email-mapping.test.ts etag.test.ts filters.test.ts
etag.ts filters.ts groups.service.ts schemas.ts scim-admin.controller.ts scim-admin.service.ts scim-auth.guard.ts scim-auth.service.ts scim-errors.ts scim.controller.ts scim.module.ts users.service.ts
search/4
__tests__/1search.service.test.ts
search.controller.ts search.module.ts search.service.ts
sessions/3sessions.controller.ts sessions.module.ts sessions.service.ts
share/3share.controller.ts share.module.ts share.service.ts
sso/16
__tests__/4enforcement.test.ts oidc.verify.test.ts provisioning.test.ts saml.validate.test.ts
enforcement.ts oidc.controller.ts oidc.service.ts oidc.ts provisioning.service.ts saml.controller.ts saml.ts schemas.ts sso-admin.controller.ts sso-admin.service.ts sso-secrets.ts sso.module.ts
teams/4dto.ts teams.controller.ts teams.module.ts teams.service.ts
users/4dto.ts users.controller.ts users.module.ts users.service.ts
webhooks/3webhooks.controller.ts webhooks.module.ts webhooks.service.ts
workspaces/4dto.ts workspaces.controller.ts workspaces.module.ts workspaces.service.ts
types/1xmldom.d.ts
app.module.ts constants.ts main.ts
_probe_rawbody.cjs .env.example Dockerfile package.json README.md tsconfig.json vitest.config.ts
realtime/33
src/17auth.ts comments.ts config.ts event-source.ts http-store.ts index.ts metrics.ts notifications.ts page-updated-source.ts presence.ts prisma-store.ts protocol.ts rate-limit.ts room-key.ts rooms.ts server.ts update-log.ts
test/11auth.test.ts config.test.ts event-source.test.ts http-store.test.ts metrics-merge.test.ts page-updated-source.test.ts presence.test.ts protocol.test.ts rate-limit.test.ts rooms.test.ts task-0094-builders.test.ts
.env.example Dockerfile package.json README.md tsconfig.json
web/255
src/244
app/45
__tests__/1theme-tokens.test.ts
(app)/26
w/25
[workspace]/25
ask/1page.tsx
databases/1
[id]/1page.tsx
favorites/1page.tsx
files/1page.tsx
notifications/1page.tsx
page/4
[id]/4
[block]/1page.tsx
share/1page.tsx
layout.tsx page.tsx
search/1page.tsx
settings/10
appearance/1page.tsx
automations/3
[id]/1page.tsx
new/1page.tsx
page.tsx
billing/1page.tsx
developers/1page.tsx
members/1page.tsx
permissions/1page.tsx
teams/1page.tsx
page.tsx
shared/1page.tsx
templates/1page.tsx
trash/1page.tsx
layout.tsx page.tsx
layout.tsx
(auth)/4
login/1page.tsx
register/1page.tsx
reset-password/1page.tsx
layout.tsx
api/2
metrics/1route.ts
v1/1
health/1route.ts
f/1
[slug]/1page.tsx
health/1
ready/1route.ts
org/2
[orgId]/2
admin/2
integrations/1page.tsx
page.tsx
share/1
[id]/1page.tsx
error.tsx global-error.tsx globals.css layout.tsx not-found.tsx page.tsx providers.tsx
components/118
admin/10
org-admin/8ApiKeysTab.tsx AuditTab.tsx MembersTab.tsx OverviewTab.tsx PoliciesTab.tsx RetentionTab.tsx WebhooksTab.tsx WorkspacePicker.tsx
ScimCard.tsx SsoTabs.tsx
ai/6ai-panel.tsx ask-ai-submenu.tsx db-ai-dialog.tsx generate-page-dialog.tsx writing-actions-menu.tsx writing-diff.tsx
automations/5action-editor.tsx condition-editor.tsx lib.ts run-history.tsx trigger-editor.tsx
collaboration/6CursorLayer.tsx OfflineBanner.tsx PresenceBar.tsx README.md ReviewFailedDialog.tsx StatusChip.tsx
comments/3comment-panel.tsx comment-thread.tsx mention-input.tsx
database/27
__tests__/2cell-editor.test.tsx cell-renderer.test.tsx
AiExtractDialog.tsx AiFormulaDialog.tsx AiGenerateDialog.tsx board-view.tsx buttons-panel.tsx calendar-view.tsx cell-editor.tsx cell-renderer.tsx chart-view.tsx database-page-view.tsx database-toolbar.tsx database-view-renderer.tsx db-embedded.tsx filter-builder.tsx form-builder-view.tsx formula-editor.tsx gallery-view.tsx group-builder.tsx list-view.tsx property-editor.tsx record-header.tsx record-panel.tsx sort-builder.tsx table-view.tsx timeline-view.tsx
dialogs/7
__tests__/1move-to-dialog.test.tsx
create-dialog.tsx dialog.tsx file-permissions-dialog.tsx invite-dialog.tsx move-to-dialog.tsx share-dialog.tsx
editor/19
__tests__/3code-block-text.test.ts code-block.test.tsx expandable.test.tsx
block-card.tsx block-renderer.tsx block-save-queue.ts block-toolbar.tsx context-menu.tsx expandable.tsx history-popover.tsx inline-editor.tsx insert-dialog.tsx page-canvas.tsx page-spinner.tsx page-view.tsx selection-toolbar.tsx slash-menu.tsx template-dialog.tsx type-menu.tsx
files/4FileBlock.tsx FileBrowser.tsx FilePicker.tsx PreviewModal.tsx
form/4form-field.tsx form-renderer.tsx form-responses-view.tsx form-view.tsx
layout/8
__tests__/1page-tree-icon.test.tsx
command-palette.tsx factory-logo.tsx page-tree-node.tsx sidebar.tsx theme-provider.tsx topbar.tsx workspace-shell.tsx
mentions/3
__tests__/1mention-model.test.ts
mention-model.ts MentionPopup.tsx
search/3ask-ai-search.tsx results-list.tsx search-dialog.tsx
settings/10
api-keys/4ApiKeyCreateDialog.tsx ApiKeyRevealDialog.tsx ApiKeyTable.tsx ScopesBadge.tsx
webhooks/5CurlExamples.tsx DeliveryInspector.tsx EventExplorer.tsx OverviewTab.tsx WebhooksTab.tsx
settings-shell.tsx
ui/3confirm-dialog.tsx form.tsx toaster.tsx
hooks/21
__tests__/4realtime-frame-handler.test.ts use-blocks.test.ts use-database-options.test.ts use-workspace.test.tsx
realtime-frame-handler.ts use-ai-stream.ts use-auth.ts use-blocks.ts use-database.ts use-db-ai-stream.ts use-forms.ts use-members.ts use-mention-sources.ts use-notifications.ts use-offline-status.ts use-pages.ts use-presence-announcer.ts use-presence-toasts.ts use-presence.ts use-realtime.ts use-workspace.ts
lib/50
__tests__/21ai-database.test.ts ai-generate.test.ts ai-sse.test.ts ai-writing.test.ts api-keys.test.ts api-members.test.ts auth-refresh.test.ts auth-store.test.ts batch-queue-drop.test.ts block-content.test.ts clipboard-import.test.ts code-highlight.test.ts offline-status.test.ts presence-announcer.test.ts presence-color.test.ts presence-cursor.test.ts presence-emitter.test.ts realtime-url.test.ts search.test.ts utils.test.ts writing-diff.test.ts
files/7
__tests__/2picker.test.ts upload.test.ts
api.ts picker.ts upload-store.ts upload.ts use-file-uploads.ts
ai-database.ts ai.ts api-keys.ts api.ts auth-store.ts batch-queue.ts block-content.ts clipboard-import.ts code-highlight.ts constants.ts offline-status.ts org-admin.ts presence-announcer.ts presence-color.ts presence-cursor.ts presence-editor-views.ts presence-emitter.ts query-client.ts realtime.ts search.ts types.ts utils.ts
stores/8
__tests__/1block-patch-store.test.ts
block-patch-store.ts comment-pill-store.ts database-store.ts editor-store.ts offlineQueue.ts presence-store.ts ui-store.ts
instrumentation.ts middleware.ts
.env.example Dockerfile next-env.d.ts next.config.mjs package.json postcss.config.mjs README.md tailwind.config.ts tsconfig.json tsconfig.tsbuildinfo vitest.config.ts
worker/92
src/87
__tests__/13ai-embedding.test.ts ai-request.test.ts ai-usage-budget.test.ts audit-export.test.ts email-decision.test.ts encrypt.test.ts health-search-index-lag.test.ts mime.test.ts retention.test.ts s3-sign.test.ts search-index.test.ts smtp.test.ts webhook-sign.test.ts
health/1server.ts
lib/12
__tests__/1clamav.test.ts
clamav.ts encrypt.ts job-otel.ts mime.ts notify.ts prisma.ts redis-stream.ts redis.ts s3.ts sharp.ts smtp.ts
processors/56
automations/28
__tests__/3condition-evaluator.spec.ts executors.spec.ts run-pipeline.spec.ts
executors/17assign-user.ts call-integration.ts change-status.ts classify.ts create-notification.ts create-page.ts email-cap.ts helpers.ts integration-registry.ts permission.ts record-write.ts registry.ts run-ai-action.ts send-email.ts send-webhook.ts types.ts update-record.ts
condition-evaluator.ts dead-letter.ts log.ts matcher.ts pipeline.ts run-state.ts schedule.ts watchdog.ts
files/15
__tests__/4errors.test.ts scan-gate.test.ts status.test.ts temp.test.ts
steps/4finalize.ts metadata.ts scan.ts thumbnails.ts
cleanup.ts errors.ts generateThumbs.ts processor.ts status.ts temp.ts types.ts
search-index/4builders.ts grants.ts index.ts processor.ts
ai-embedding.ts ai.processor.ts audit-export.ts automations.processor.ts email-decision.processor.ts email.processor.ts maintenance.processor.ts retention.ts webhooks.processor.ts
config.ts events.ts index.ts logger.ts queues.ts
.env.example Dockerfile package.json README.md tsconfig.json
docs/73
api/17ai.md authentication.md automations.md blocks.md comments.md databases.md files.md forms.md openapi.yaml org-admin.md pages.md scim.md search.md sso.md versioning.md webhooks.md workspaces.md
architecture/10ai-architecture.md automation.md backend-architecture.md database-architecture.md frontend-architecture.md realtime-architecture.md search-architecture.md security-architecture.md storage.md system-architecture.md
database/2database-architecture.md redis-keys.md
development/8admin-guide.md coding-standards.md deployment.md development-guide.md files-pipeline.md perf-report.md performance.md testing.md
product/4functional-requirements.md non-functional-requirements.md product-requirements.md ux-requirements.md
requirements/1requirements-matrix.md
security/5audit-report.md files.md forms.md license-allowlist.md security-architecture.md
tasks/16phase-00-foundation.md phase-01-authentication.md phase-02-workspace.md phase-03-pages.md phase-04-editor.md phase-05-databases.md phase-06-relations.md phase-07-collaboration.md phase-08-search.md phase-09-files.md phase-10-forms.md phase-11-automation.md phase-12-ai.md phase-13-api.md phase-14-enterprise.md phase-15-production.md
ui/9ai.md automations.md design-system.md developers.md files.md forms.md org-admin.md scim.md sso.md
support-matrix.md
infrastructure/71
caddy/1Caddyfile
docker/6
init/101-extensions.sql
opensearch/1init-indices.json
.env.docker docker-compose.yml opensearch-init.sh README.md
kubernetes/40
observability/20
alertmanager/1alertmanager.yaml
grafana/8
dashboards/6ai.json api-overview.json infra.json realtime.json search.json workers-queues.json
provisioning/2
dashboards/1dashboards.yaml
datasources/1datasource.yaml
prometheus/3alerts.yaml recording-rules.yaml scrape.yaml
scripts/1sync-sources.mjs
alertmanager.yaml grafana.yaml kustomization.yaml namespace.yaml node-exporter.yaml otel-collector.yaml prometheus.yaml
postgres/7configmap.yaml cronjob-backup.yaml cronjob-opensearch-snapshot.yaml pgbouncer.yaml replica.yaml statefulset.yaml walg-iam-policy.yaml
api.yaml configmap.yaml ingress.yaml kustomization.yaml namespace.yaml networkpolicy.yaml pdb.yaml README.md realtime.yaml redis.yaml secret.example.yaml web.yaml worker.yaml
nginx/2nginx.conf README.md
observability/14
alertmanager/1alertmanager.yaml
grafana/8
dashboards/6ai.json api-overview.json infra.json realtime.json search.json workers-queues.json
provisioning/2
dashboards/1dashboards.yaml
datasources/1datasource.yaml
prometheus/3alerts.yaml recording-rules.yaml scrape.yaml
scripts/1dashboard-completeness.mjs
README.md
terraform/8compute.tf data.tf main.tf network.tf outputs.tf README.md security.tf variables.tf
packages/289
ai/24
src/20
providers/7anthropic.ts google.ts http.ts index.ts openai-compatible.ts rag.test.ts writing.test.ts
schemas/2database.ts generate.ts
adapters.test.ts config.test.ts config.ts gateway.test.ts gateway.ts index.ts tools.test.ts tools.ts types.ts usage.test.ts usage.ts
package.json README.md tsconfig.json vitest.config.ts
auth/11
src/7index.ts passwords.test.ts passwords.ts sessions.test.ts sessions.ts tokens.test.ts tokens.ts
package.json README.md tsconfig.json vitest.config.ts
collaboration/17
src/13awareness.ts codec.test.ts codec.ts index.ts lww.test.ts lww.ts mapping.ts offline.ts outbox.test.ts outbox.ts provider.test.ts provider.ts types.ts
package.json README.md tsconfig.json vitest.config.ts
config/7
src/4eslint.base.js index.ts prettier.base.json tsconfig.base.json
package.json README.md tsconfig.json
database-client/5
src/2index.test.ts index.ts
package.json README.md tsconfig.json
database-engine/33
src/29
filter/2filter.test.ts index.ts
formula/8evaluator.ts formula.test.ts functions.ts index.ts lexer.ts parser.ts types.ts validate.ts
query/6group.ts index.ts paginate.ts pivot.ts query.test.ts sort.ts
relations/2index.ts relations.test.ts
rollups/2index.ts rollups.test.ts
values/5dates.ts index.ts registry.ts types.ts values.test.ts
views/3buttons.ts index.ts views.test.ts
index.ts
package.json README.md tsconfig.json vitest.config.ts
editor/25
src/21
marks/1highlight.ts
nodes/2equation.ts mention.ts
autosave.test.ts autosave.ts clipboard.test.ts clipboard.ts codec.test.ts codec.ts context-menu.test.ts context-menu.ts diff.test.ts diff.ts factory.ts history.test.ts history.ts index.ts positions.ts slash.test.ts slash.ts types.ts
package.json README.md tsconfig.json vitest.config.ts
observability/20
src/16
__tests__/8db-redis-metrics.test.ts metrics.test.ts otel.test.ts pino-otel.test.ts prometheus.test.ts resource.test.ts scrubber.test.ts traceparent.test.ts
index.ts metrics.ts otel.ts pino-otel.ts prometheus.ts resource.ts scrubber.ts traceparent.ts
package.json README.md tsconfig.json vitest.config.ts
permissions/11
src/7index.ts levels.test.ts levels.ts resolve.test.ts resolve.ts rules.test.ts rules.ts
package.json README.md tsconfig.json vitest.config.ts
search/22
src/18chunking.test.ts chunking.ts client.test.ts client.ts embeddings.test.ts embeddings.ts hybrid.test.ts hybrid.ts index.ts indexer.test.ts indexer.ts mapping.test.ts mapping.ts queries.test.ts queries.ts rrf.test.ts rrf.ts types.ts
package.json README.md tsconfig.json vitest.config.ts
shared/61
src/57
dto/17ai.dto.ts auth.dto.test.ts auth.dto.ts block.dto.ts browser-safety.test.ts comment.dto.ts database.dto.test.ts database.dto.ts file.dto.ts formula-ast.ts index.ts notification.dto.ts page.dto.ts search.dto.ts share.dto.ts webhook.dto.ts workspace.dto.ts
events/8audit-catalog.test.ts audit-catalog.ts audit-csv.test.ts audit-csv.ts audit-scope.test.ts audit-scope.ts catalog.test.ts catalog.ts
realtime/6comment-events.ts frames.test.ts frames.ts notification-policy.ts notification-prefs.ts task-0094.test.ts
automation.test.ts automation.ts constants.ts crypto.test.ts crypto.ts env.ts errors.ts events.test.ts events.ts forms.test.ts forms.ts index.ts markdown.test.ts markdown.ts mentions.test.ts mentions.ts net.test.ts net.ts positions.test.ts positions.ts presence.test.ts presence.ts security-headers.ts webhook-delivery.test.ts webhook-delivery.ts webhook-events.ts
package.json README.md tsconfig.json vitest.config.ts
storage/16
src/12client.test.ts client.ts index.ts keys.test.ts keys.ts mime.test.ts mime.ts presign.test.ts presign.ts thumbnails.test.ts thumbnails.ts types.ts
package.json README.md tsconfig.json vitest.config.ts
ui/37
src/33
components/19avatar.tsx badge.tsx button.tsx checkbox.tsx command.tsx context-menu.tsx dialog.tsx dropdown-menu.tsx empty-state.tsx index.ts popover.tsx separator.tsx skeleton.tsx slider.tsx spinner.tsx switch.tsx tabs.tsx toast.tsx tooltip.tsx
color.ts command-filter.test.ts command-filter.ts focus.test.ts focus.ts formatters.test.ts formatters.ts index.ts theme.test.ts theme.ts toast-store.test.ts toast-store.ts tokens.test.ts tokens.ts
package.json README.md tsconfig.json vitest.config.ts
prisma/16
migrations/13
20260927000000_init/1migration.sql
20260928000000_search_documents_content_hash/1migration.sql
20260929000000_workspace_usage_storage_bytes/1migration.sql
20260930000000_form_submitted_notification_type/1migration.sql
20261001000000_ai_phase12/1migration.sql
20261002000000_webhooks_secret_encrypted_dlq/1migration.sql
20261002111436_webhook_delivery_latency/1migration.sql
20261002120000_org_admin_2fa_retention_unique/1migration.sql
20261002215124_audit_export/1migration.sql
20261003210000_perf_indexes_hot_paths/1migration.sql
20261004004500_perf_indexes_hot_paths_2/1migration.sql
migration_lock.toml README.md
schema.prisma seed.ts verify.ts
scripts/7backup-health.ts docs-completeness.mjs generate-openapi.mjs minio-init.ts opensearch-reindex.ts storage-orphans.ts verify-clean-clone.sh
tests/169
e2e/63
.auth/1user.json
fixtures/7
files/6clip.mp4 clip.wav clip.webm hero-1400.png note.docx note.txt
realtime.ts
mocks/2oidc-issuer.ts saml-idp.ts
playwright-report/3
data/2a6557bae9c2714a658968d4eb8534195c08ebda8.png e3092d07d00a16063e46385c02a559a9054fa847.webm
index.html
reports/1files-security.json
specs/34ai-database.spec.ts ai-generate.spec.ts ai-rag.spec.ts ai-security.spec.ts ai-writing.spec.ts ai.spec.ts api-keys.spec.ts appearance-theme.spec.ts auth.spec.ts automation.spec.ts collab-two-tab.spec.ts comments.spec.ts databases.spec.ts default-workspace-alias.spec.ts developers.spec.ts editor.spec.ts files.spec.ts final-flow.spec.ts forms.spec.ts oauth.spec.ts org-admin.spec.ts pages.spec.ts performance.spec.ts presence-cursors.spec.ts qa-paste-toggle.spec.ts realtime.spec.ts scim.spec.ts search-index-lag.spec.ts search.spec.ts sharing.spec.ts sso.spec.ts task-0094-comments-notifications.spec.ts webhooks.spec.ts workspace.spec.ts
test-results-final-flow/3
final-flow-Release-v1-0-fi-6c06b-w-state-carries-sequential--chromium-desktop/2test-failed-1.png trace.zip
.last-run.json
utils/4api.ts dnd.ts search-lag.ts wait.ts
.gitignore fixtures.ts global-setup.ts package.json playwright.config.ts playwright.final-flow.config.ts README.md tsconfig.json
fixtures/1
files/1make-sparse.ts
integration/60
ai-capability/2ai-app.capability.test.ts gateway.capability.test.ts
drill/2seed-drill.mjs verify-restore.mjs
fixtures/5
files/5clip.mp4 clip.wav doc.pdf hero-1400.png note.txt
helpers/3api.ts containers.ts seed.ts
realtime/11control-channel.test.ts convergence.test.ts flush-rebase-http.test.ts handshake.test.ts heartbeat-limits.test.ts lifecycle.test.ts presence.test.ts rebase.test.ts resume.test.ts rt-helpers.ts task-0094-fanout.test.ts
ai-chat.integration.test.ts ai-database.integration.test.ts ai-generate.integration.test.ts ai-rag.integration.test.ts ai-writing.integration.test.ts api-keys.integration.test.ts audit-completeness.integration.test.ts audit-export-s3.integration.test.ts auth.integration.test.ts automation-pipeline.integration.test.ts automations.integration.test.ts blocks.integration.test.ts cache-invalidation.integration.test.ts comments.integration.test.ts databases.integration.test.ts files-lifecycle.integration.test.ts files-pipeline.integration.test.ts files-security.integration.test.ts files.integration.test.ts forms-responses.integration.test.ts forms.integration.test.ts oauth.integration.test.ts openapi.contract.test.ts org-admin.integration.test.ts package.json pages.integration.test.ts permissions.integration.test.ts README.md replica-routing.integration.test.ts retention-engine.integration.test.ts scim.integration.test.ts search.integration.test.ts sso.integration.test.ts tsconfig.json vitest.config.ts webhooks.integration.test.ts workspace.integration.test.ts
performance/28
fixtures/1search-100k.ts
helpers/2seed-100k.mjs seed-1k-load.mjs
reports/7api-load-smoke.json database-load-smoke.json editor-local.json realtime-load.json search-full.json search-last.json search-reduced.json
api-load.js api.js archive.tar database-load.js database.js editor-local.mjs extract-100k-env.mjs package.json README.md realtime-1k.js realtime-load.js realtime.js run-realtime-load.sh search-search.k6.js search-summary.json seed-100k.mjs threshold-breach-demo.js verify-zero-op-loss.mjs
security/16
helpers/1app.ts
audit-report.test.ts auth-paths.test.ts deps.test.ts formula-fuzz.test.ts gitleaks-config.test.ts headers.test.ts images.test.ts oracle.ts package.json permission-fuzz.test.ts rate-limits.test.ts README.md tsconfig.json upload-abuse.test.ts vitest.config.ts
README.md
.dockerignore .env .env.bak-task0125 .env.example .eslintrc.json .gitignore .npmrc .prettierignore .prettierrc.json AGENTS.md ARCHITECTURE.md CHANGELOG.md CONTRIBUTING.md gitleaks.toml LICENSE package.json pnpm-lock.yaml pnpm-workspace.yaml PRODUCT-SPEC.md README.md ROADMAP.md SECURITY.md tsconfig.json turbo.json
phase-08-search.mddocs/tasks/phase-08-search.md← tasks53,242 B← Back to the app

Phase 8 — Search (Task Specs)

Purpose

Phase 8 delivers workspace-wide search: an event-driven indexer that mirrors visible content into OpenSearch, a permission-filtered full-text search API, and a global search UI. It also lays the hybrid (keyword + semantic) foundation — vector mapping, chunker wiring, and a stubbed embedding pipeline — so Phase 12 (AI/RAG) can plug in without re-indexing the platform.

Phase Exit Criteria (from ROADMAP.md § Phase 8)

Tasks

ID Title Estimate
TASK-0096 Search indexing pipeline (events → OpenSearch + mirror + reconciliation) L
TASK-0097 Full-text search API (POST /api/v1/search) L
TASK-0098 Global search UI (/search) M
TASK-0099 Hybrid AI search foundation (vector mapping + chunker + embedding stub) M
TASK-0100 Search performance verification (index lag, query p95, E2E) M

Phase 8 Notes — recorded decisions & conflicts (AGENTS.md rule 29)

Decisions are recorded as slices land; the authoritative record is docs/architecture/search-architecture.md § 0 (Implementation Notes).

Phase Completion Checklist

Status / Resume Point (2026-09-29 — TASK-0100 CLOSED; PHASE 8 CLOSED; NEXT: Phase 9 — Files):

TASK-0100 (the Phase-8 exit verification) is complete across S0–S9 (all committed). The Phase-8 exit criteria are met: index lag < 30 s (measured in the 10-run E2E — create-side mean 3.7 s / max 4.3 s, delete-side 2.1 s); query p95 < 500 ms @ 100k (full k6 profile p95 49.9 ms / p99 92.8 ms — a ~10× margin, run on a machine smaller than the DoD reference env); permission-filtered results proven by the integration test (tenant isolation

  • non-member workspaceId → 404 no-leak) and live (the e2e test 3: a second user finds 0 private-page rows, the creator finds theirs). The "Full CI green" checklist box stays open (CI-gated — pending the first green CI run, mirroring the Phase-7 close-out convention).

Finding recorded (TASK-0096 ↔ TASK-0100 interaction): the 100k perf fixture is seeded directly into OpenSearch (no search_documents mirror rows), but the worker's reconcile sweep (TASK-0096, 15-min backstop, plus the per-page reindex path) rebuilds a workspace's docs from the mirror — so any reindex/reconcile of the perf-search-* workspaces deletes the fixtures as "orphans" (observed live: the 10-run e2e loop triggered worker reconciles that wiped the 100k docs). The CI perf-search lane is unaffected: it boots the API only (no worker → no reconcile sweep) and seeds immediately before the run. Local runs must re-seed after any worker reindex, or the seeder should write mirror rows (a follow-up, not a Phase-8 gap — the CI lane, which is the DoD's gating environment, is deterministic).

Handoff to Phase 9 (Files): the file indexer path (f.uploadedBy → creator-implicit-viewer, S5 §8) is the model the Phase-9 file search docs should follow; the file fixture type (15,726 docs) is already exercised by the 100k perf suite.


TASK-0096

Title

Search indexing pipeline: domain events → OpenSearch indexer, search_documents mirror, reconciliation job

Objective

Make every searchable object (page, block, database, record, comment, file, user) appear in OpenSearch within 30 s of its domain event, with a permission snapshot per document, and keep the PostgreSQL search_documents mirror and the OpenSearch index consistent via a 15-minute reconciliation job.

Background

packages/search provides the OpenSearch client (packages/search/src/client.ts), a query builder (src/query-builder.ts), RRF fusion (src/rrf.ts), and a content chunker (src/chunker.ts). The worker already has scaffolded processors under apps/worker/src/processors/ including search-index and maintenance. Domain events are published to Redis streams with names from @factory/shared/events (packages/shared/src/events/index.ts): page.created|updated|deleted|shared, database.created|updated, record.created|updated, comment.created, form.submitted, automation.executed, file.uploaded, api_key.created, user.login|logout|register, permission.changed, workspace.created. The Prisma schema already defines SearchDocument (prisma/schema.prisma, table search_documents: id, workspaceId, type, refId, title, body, permissions Json, metadata Json, indexedAt, unique [type, refId]). OpenSearch is provisioned by the Phase-0 Docker environment.

Requirements

  1. Implement apps/worker/src/processors/search-index/processor.ts consuming the Redis stream consumer group from the shared event bus, handling the events: page.created|updated|deleted|shared, database.created|updated, record.created|updated, comment.created, file.uploaded, permission.changed, user.register|login (user docs are created on register, refreshed on login for lastSeen), workspace.created.
  2. Document shape (one OpenSearch doc per type + refId): { id: "<type>:<refId>", workspaceId, type: "page"|"block"|"database"|"record"|"comment"|"file"|"user", title, body, permissions: { granteeType[], granteeId[], levels[], scope, isPrivate }, metadata: { teamId?, parentId?, pageId?, databaseId?, blockId?, createdBy?, updatedBy?, createdAt, updatedAt, icon?, size?, mimeType? } }.
  3. Body composition rules: page body = concatenated text of all descendant blocks (read via the block repository, depth-first, capped at 1000 blocks per page); record body = record title + rendered property values (all DatabaseProperty types; relations rendered as linked-record titles); comment body = comment text; file body = file name + mime type; database body = database title + property names; user body = display name + email.
  4. Permission snapshot: computed by packages/permissions (inherit workspace role → team grants → explicit Permission rows, granteeType user/team/role, levels NONE/VIEW/COMMENT/EDIT/FULL_ACCESS) and stored on the doc as a compact snapshot: { scope: "private"|"workspace"|"team"|"public", teamId?, grantees: [{type, id, level}] }. permission.changed events must re-index every affected doc (resolved via Permission rows + descendant pages for page grants).
  5. Delete semantics: page.deleted (soft/trash) removes the doc; a page re-indexed after restore re-adds it. Record archive (soft) removes; purge removes from mirror too. block-level deletes are handled by re-indexing the parent page (blocks are indexed as part of page body, plus a separate block doc per block containing rich text > 0 chars for block-level hits).
  6. Every index operation writes/updates the search_documents mirror row (upsert on [type, refId], indexedAt = now). The mirror is the reconciliation source of truth.
  7. Reconciliation: apps/worker/src/processors/maintenance/ repeatable BullMQ job search:reconcile (every 15 min, repeat: { pattern: "*/15 * * * *" }): for each workspace, count search_documents rows per type vs. OpenSearch _count per type; on drift > 0, re-index the affected type in batches of 500 (log per-batch progress to search:reconcile:<workspaceId> metric + structured log).
  8. Idempotency: events are at-least-once; index upserts keyed by <type>:<refId> must be safe to replay. Poison events (missing source rows, e.g. purged before indexing) are logged, counted, and acked after 5 dead-letter attempts to search-index:dlq.

Acceptance Criteria

Backend Changes

Frontend Changes

None (indexer is worker-side; UI is TASK-0098).

Database Changes

API Changes

None (internal worker pipeline; public API is TASK-0097).

Tests

Security

Documentation

Dependencies

Definition of Done


TASK-0097

Title

Full-text search API: POST /api/v1/search with permission filtering, filters, cursor pagination, highlights

Objective

Provide the search endpoint used by the UI and (in Phase 13) the public API: BM25 multi_match + prefix + fuzzy matching over the 7 doc types, with type/workspace/team/updated-date/creator filters, query-time permission filtering via the doc permission snapshot, cursor pagination, and highlight snippets — response shape per docs/api/search.md.

Background

The indexer (TASK-0096) publishes docs with workspaceId, type, title, body, permissions snapshot, metadata (incl. teamId, createdBy, updatedAt, pageId, databaseId). packages/search/src/query-builder.ts scaffolds the OpenSearch DSL builder; src/rrf.ts is reserved for Phase 12 hybrid fusion (not used by this endpoint yet). The NestJS search module scaffold lives in apps/api/src/modules/search/. Auth middleware and the @factory/shared error model (404 vs 403 semantics per docs/api/authentication.md) are Phase 1. LIMITS.MAX_SEARCH_LIMIT = 50 (packages/shared/src/constants.ts) caps page size.

Requirements

  1. Endpoint: POST /api/v1/search (NestJS controller apps/api/src/modules/search/search.controller.ts, service search.service.ts, zod DTOs in dto/search.dto.ts). Auth required (session JWT or — Phase 13 — API key).
  2. Request body: { query: string (1..200 chars, trimmed), types?: ("page"|"block"|"database"|"record"|"comment"|"file"|"user")[], workspaceId?: string, teamId?: string, updatedAfter?: ISO-8601, updatedBefore?: ISO-8601, createdBy?: userId, scope?: "workspace"|"team", cursor?: string, limit?: 1..50 (default 20) }. Validate with zod; reject unknown types values.
  3. Query construction (packages/search/src/query-builder.ts): bool query — must: multi_match on [title^3, body] (best_fields) combined with a prefix sub-query (minimum should 1) and a fuzzy sub-query (fuzziness: AUTO, prefix_length: 1) on title (boost 2); filter: term workspaceId (default: all workspaces the caller is a member of — never a single implicit one), term metadata.teamId when teamId set, range metadata.updatedAt for the date window, term metadata.createdBy, and the permission filter (see §5).
  4. Cursor pagination: response nextCursor = base64 of { score, id } (search_after on [score, _id]); limit ≤ LIMITS.MAX_SEARCH_LIMIT; track_total_hits capped at 10 000.
  5. Permission filtering at query time: build a bool should filter from the caller's identities — caller's user id, the user's team ids per requested workspace scope, and workspace role — matched against doc fields permissions.granteeId, permissions.granteeType, permissions.teamId, permissions.scope: scope:"public" → always visible; scope:"workspace" + caller is a member → visible; scope:"team" + doc permissions.teamId ∈ caller teams → visible; scope:"private" + grantee entry (user/team/role) matching caller with level ≥ VIEW → visible. minimum_should_match: 1 on that should group. No doc-level application of permissions in the UI (server is the source of truth).
  6. Response shape (documented in docs/api/search.md): { results: [ { id, type, workspaceId, title, snippet (HTML with <mark> from OpenSearch highlight on body, 160 chars), icon?, metadata: { pageId?, blockId?, databaseId?, recordId?, teamId?, updatedAt, createdBy, size?, mimeType? }, permissions: { level: caller's effective level } } ], total: number, nextCursor: string | null, tookMs: number }. Snippet for block hits links back via metadata.blockId (+ page id).
  7. tookMs is measured server-side (query time only). Structured log per request: workspaceId set, types, tookMs, total, query hash (no raw query text in logs beyond 64 chars).
  8. Errors: 401 unauthenticated; 422 invalid body (zod); 503 with error code SEARCH_UNAVAILABLE when OpenSearch is down (do not leak backend details).

Acceptance Criteria

Backend Changes

Frontend Changes

None (endpoint only; UI is TASK-0098).

Database Changes

None (reads OpenSearch; no Prisma writes).

API Changes

Tests

Security

Documentation

Dependencies

Definition of Done


TASK-0098

Title

Global search UI: /search page with grouped results, deep links, keyboard navigation, recents, suggestions

Objective

Ship the global search experience: a debounced search page that groups results by type with icons and highlighted snippets, deep-links each hit to the right place (block → page + scroll to block, record → database + row), supports full keyboard navigation, remembers the last 20 searches per user in Redis, and shows suggestions while typing.

Background

The API exists per TASK-0097 (POST /api/v1/search), plus a lightweight suggestions endpoint implemented in the same module (POST /api/v1/search/suggestions: prefix completions over title with completion/prefix query, max 8, same permission filter). Recent searches are stored server-side: GET/PUT /api/v1/search/recent backed by a Redis list search:recent:{userId} (cap 20, newest first, 30-day TTL per entry). The web app is Next.js 14 under apps/web/; the sidebar (Phase 2) has a Search entry; the Cmd/Ctrl+K binding (Phase 4/7 editor keymap) routes to /search and focuses the input. Route structure follows existing app-router conventions in apps/web/src/app/.

Requirements

  1. Page: apps/web/src/app/(workspace)/search/page.tsx (client component) + apps/web/src/components/search/ (SearchInput.tsx, ResultGroup.tsx, ResultItem.tsx, RecentSearches.tsx, SuggestionList.tsx, search-state.ts reducer). Debounce input 250 ms; cancel in-flight requests (AbortController); ignore responses out of order.
  2. Results grouped by type in fixed order: Pages, Databases & Records, Files, Comments, Users; each group collapsible with a count badge; icons per type (reuse @factory/ui icon set: page, database, file, comment, user). Each item: title (highlight <mark> rendered as <mark> styling), snippet (max 2 lines, ellipsis), metadata line (parent page / database name / updated relative time / author avatar).
  3. Deep links: page → /p/{pageId}; block hit → /p/{pageId}#block-{blockId} (editor scrolls + flashes the block, Phase-4 scroll anchor); database → /p/{pageId}?view={table}; record → /p/{pageId}?view={table}&row={recordId} (row flash); file → file preview route /files/{fileId} (TASK-0103); comment → /p/{pageId}#comment-{commentId}; user → member profile popover. Clicking a result records it in recent searches.
  4. Keyboard navigation: ↑/↓ move active result across groups (group order = render order), Enter opens active result, Esc clears/focuses input, / focuses the input when on the page, type-ahead filters visible groups. Active state announced via aria-activedescendant + visible focus ring; every clickable result reachable and operable via keyboard (WAI-ARIA listbox pattern).
  5. Recent searches: on empty input, show the last 20 (from GET /api/v1/search/recent) with a clock icon + per-item clear (×) + "Clear all"; clicking runs that query; recording happens server-side on result click and on Enter.
  6. Suggestions: while typing (after 2 chars, 250 ms), a dropdown above results with up to 8 title completions (from /search/suggestions), each with type icon; arrow keys navigate the dropdown first, then results; Tab/Enter fills the query.
  7. States: loading (skeleton rows, input spinner, "Searching…"), empty ("No results for '<q>'" + tips: check spelling, try fewer words, filter by type), error (inline banner with retry button; do not clear input), rate-limited (429 → "Too many searches, slow down" toast).
  8. Type filter chips (All / Pages / Databases / Files / Comments / Users) toggling the types param; selected chip persisted in the URL (?type=page) for shareable links; workspace/team/date filters are out of scope for Phase 8 UI (API supports them; UI in Phase 13 search settings) — note recorded in the task file.
  9. Mobile: full-width input, groups stacked, snippet 2 lines, touch targets ≥ 44 px; no horizontal scroll; keyboard nav degrades gracefully.

Acceptance Criteria

Backend Changes

Frontend Changes

Database Changes

None (Redis only; no Prisma changes).

API Changes

Tests

Security

Documentation

Dependencies

Definition of Done


TASK-0099

Title

Hybrid AI search foundation: dense_vector mapping, chunker wiring, stubbed embedding pipeline (RAG in Phase 12)

Objective

Prepare the search stack for hybrid (keyword + semantic) search without changing Phase-8 behavior: add a bodyVector dense_vector field to the OpenSearch mapping, wire the existing chunker into the indexer, and stub the embedding pipeline as a job in the worker ai queue — so Phase 12 only implements the embedding provider call and the RAG endpoint.

Background

packages/search already scaffolds a chunker (src/chunker.ts) and RRF fusion (src/rrf.ts); the OpenSearch mapping lives in packages/search/src/mapping.ts (created by TASK-0096). The worker ai queue is scaffolded (apps/worker/src/processors/ai/); packages/ai is the future provider-agnostic AI gateway (Phase 12). Prisma has AiEmbedding (ai_embeddings: model/workspace-level cache of embeddings — verify fields when implementing; reuse, do not duplicate). This task deliberately does NOT ship semantic search: no UI, no query path change.

Requirements

  1. Mapping: add to factory-{env} index mapping: bodyVector: { type: "dense_vector", dims: 1536, index: true, similarity: "cosine" } + chunkId: keyword + chunkIndex: integer + chunkModel: keyword (embedding model tag, e.g. text-embedding-3-small). Index settings: HNSW m: 16, ef_construction: 100 (documented, tunable via env SEARCH_KNN_M/SEARCH_KNN_EF_CONSTRUCTION).
  2. Reindex compatibility: dims is immutable — the migration path is a new alias rollout: create factory-{env}-v2 with the new mapping, alias factory-{env} → v2, backfill from the search_documents mirror (reuse TASK-0096 reconcile path), then delete v1. Implement as a one-off script scripts/opensearch-reindex.ts + pnpm search:reindex (documented, idempotent, resumable in 500-doc batches).
  3. Chunker wiring: during indexing (TASK-0096 mappers), split page/record bodies with chunker.ts (target 800 tokens, 15% overlap; chunks < 100 tokens merged with the next) and store chunk metadata on the doc (metadata.chunks: [{ chunkId, charStart, charEnd }] — chunk text itself stays in the body field for keyword search; vector docs are separate: one OpenSearch doc per chunk { id: "<type>:<refId>:chunk:<chunkId>", type: "chunk", ...parent fields, body: chunkText, chunkId, chunkIndex } with the same permission snapshot. Chunk docs are excluded from keyword search results (type: "chunk" never in the public types filter — keyword search over whole-doc body stays unchanged).
  4. Embedding stub: apps/worker/src/processors/ai/embedding-pipeline.ts consuming queue ai, job embed:chunks { workspaceId, docType, refId, chunkIds[] }: the stub (a) validates the payload, (b) writes an AiEmbedding cache placeholder row only if a real provider is configured (env AI_EMBEDDING_PROVIDER absent → log "embedding disabled (Phase 12)" and skip), (c) leaves bodyVector null. Phase 12 replaces step (b) with the gateway call.
  5. KNN query path stub: packages/search/src/query-builder.ts gains buildHybridQuery(keyword, vector, weights) using rrf.ts (reciprocalRankFusion(keywordHits, knnHits, k=60)) — fully unit-tested with synthetic hits, but NOT wired into POST /api/v1/search (that wiring is Phase 12 behind a capability flag).
  6. Config: env additions in .env.example — SEARCH_KNN_M, SEARCH_KNN_EF_CONSTRUCTION, AI_EMBEDDING_PROVIDER (empty by default), AI_EMBEDDING_MODEL (default text-embedding-3-small), validated by @factory/config zod.

Acceptance Criteria

Backend Changes

Frontend Changes

None (explicitly no UI in Phase 8 for semantic search).

Database Changes

API Changes

None (no endpoint change; hybrid query exposed in Phase 12).

Tests

Security

Documentation

Dependencies

Definition of Done


TASK-0100

Title

Search performance verification: index lag < 30 s, query p95 < 500 ms @ 100k docs, create→find E2E

Objective

Prove the Phase-8 performance exit criteria with repeatable suites: end-to-end index lag under 30 s, query p95 under 500 ms with 100k indexed documents, and the canonical E2E (create a page with a unique phrase → searchable within 30 s → click → correct page).

Background

TASKS-0096…0099 ship the pipeline, API, UI, and hybrid foundation. tests/performance/ is the home for k6/Artillery suites (Phase-0 bootstrap); tests/e2e/ hosts Playwright. The Docker dev environment provides OpenSearch/Redis/Postgres/MinIO. 100k-doc fixture generation must be fast enough for CI (target: seed in < 10 min) and resettable.

Requirements

  1. Index lag measurement: E2E helper that (a) records t0 before creating a page (via API) whose body contains a globally unique phrase (perf-<runId>-<uuid>), (b) polls POST /api/v1/search every 2 s, (c) passes when the page appears in results, failing if not found within 30 s; reports actual lag. Same helper asserts a deleted page disappears from results within 30 s.
  2. Query performance suite: tests/performance/search-search.k6.js (k6) — dataset: 100k docs seeded via tests/performance/fixtures/search-100k.ts (10k pages × 7 types mix: 40% pages, 25% records, 15% files, 10% comments, 5% databases, 5% users; realistic body sizes 200–2000 chars; 2 workspaces, 200 users, permission mix 50% workspace / 25% team / 25% private). Load profile: 100 VUs, 5 min, Poisson arrivals 50 req/s; assertions: p95 < 500 ms, p99 < 1 s, error rate < 0.1%; measured query tookMs also logged server-side for cross-check.
  3. Seed/reset tooling: pnpm perf:seed:search (idempotent: drops perf-* fixtures first) and pnpm perf:reset:search; fixtures excluded from normal test DBs (tagged perf, separate workspace ids) so unit/integration runs stay fast.
  4. E2E scenario (tests/e2e/search.spec.ts, scenario "index lag + click through"): logged-in user creates a page (UI) titled "Perf Probe {uuid}", body one sentence with the unique phrase; within 30 s the search box finds it (assert result row); clicking it lands on the page and the page title matches; delete the page → within 30 s no longer returned.
  5. Baseline + regression gating: store the last run's p95/p99/lag in tests/performance/reports/search-last.json (committed on demand by a maintainer, not per-PR); CI runs the k6 suite with a reduced profile (10 VUs × 60 s) on merge to main, full profile nightly; a p95 regression

20% vs. baseline fails the nightly with a report link.

  1. OpenSearch tuning notes: record the measured index refresh interval (default 1 s — keep; do NOT tune to 30 s for the lag SLA) and any JVM heap/thread_pool settings required to hit p95 at 100k, in docs/architecture/search.md "Performance" section.

Acceptance Criteria

Backend Changes

Frontend Changes

Database Changes

API Changes

Tests

Security

Documentation

Dependencies

Definition of Done