spine-framework 0.3.144 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +76 -0
- package/.framework/.spine-manifest.json +19 -0
- package/.framework/cli/commands/agents.ts +61 -33
- package/.framework/cli/commands/auth.ts +60 -28
- package/.framework/cli/commands/create-app.ts +212 -80
- package/.framework/cli/commands/dev.ts +184 -68
- package/.framework/cli/commands/doctor.ts +324 -152
- package/.framework/cli/commands/generate.ts +119 -68
- package/.framework/cli/commands/init.ts +141 -242
- package/.framework/cli/commands/install-app.ts +1336 -314
- package/.framework/cli/commands/items.ts +31 -29
- package/.framework/cli/commands/migrate.ts +299 -156
- package/.framework/cli/commands/migrations.ts +62 -30
- package/.framework/cli/commands/pipelines.ts +31 -29
- package/.framework/cli/commands/status.ts +105 -45
- package/.framework/cli/commands/system.ts +47 -42
- package/.framework/cli/commands/test.ts +161 -102
- package/.framework/cli/commands/upgrade.ts +260 -0
- package/.framework/cli/commands/validate-app.ts +517 -161
- package/.framework/cli/context.ts +117 -85
- package/.framework/cli/env-loader.ts +74 -43
- package/.framework/cli/index.ts +70 -46
- package/.framework/cli/lib/project-files.ts +404 -0
- package/.framework/docs/guides/testing-guide.md +1 -1
- package/.framework/docs/runtime-types.md +72 -72
- package/.framework/functions/_shared/access.ts +84 -0
- package/.framework/functions/_shared/agent-runner.ts +5051 -1026
- package/.framework/functions/_shared/app-manifest.ts +214 -94
- package/.framework/functions/_shared/ast.ts +214 -0
- package/.framework/functions/_shared/audit.ts +91 -55
- package/.framework/functions/_shared/cil.ts +368 -127
- package/.framework/functions/_shared/db.ts +337 -68
- package/.framework/functions/_shared/funnel.ts +228 -0
- package/.framework/functions/_shared/geo.ts +105 -0
- package/.framework/functions/_shared/hash-api-key.ts +94 -17
- package/.framework/functions/_shared/index.ts +22 -224
- package/.framework/functions/_shared/kb.ts +832 -58
- package/.framework/functions/_shared/llm.ts +118 -18
- package/.framework/functions/_shared/logging.ts +317 -19
- package/.framework/functions/_shared/middleware.ts +701 -131
- package/.framework/functions/_shared/notify.ts +70 -0
- package/.framework/functions/_shared/outcomes.ts +34 -19
- package/.framework/functions/_shared/permissions.ts +501 -315
- package/.framework/functions/_shared/pipeline-runner.ts +704 -155
- package/.framework/functions/_shared/principal.ts +436 -263
- package/.framework/functions/_shared/rate-limit.ts +233 -0
- package/.framework/functions/_shared/resolve-credentials.ts +86 -19
- package/.framework/functions/_shared/resolve-ids.ts +203 -139
- package/.framework/functions/_shared/retry-deliveries.ts +51 -16
- package/.framework/functions/_shared/schema-utils.ts +602 -521
- package/.framework/functions/_shared/security.ts +345 -0
- package/.framework/functions/_shared/testing.ts +197 -172
- package/.framework/functions/_shared/tracing.ts +351 -21
- package/.framework/functions/_shared/trigger-engine.ts +425 -136
- package/.framework/functions/_shared/webhook-registration.ts +71 -70
- package/.framework/functions/_shared/webhook-registry.ts +126 -83
- package/.framework/functions/account-nodes.ts +30 -30
- package/.framework/functions/adapters/generic-webhook-inbound.ts +49 -16
- package/.framework/functions/adapters/generic-webhook-outbound.ts +17 -17
- package/.framework/functions/adapters/openai-outbound.ts +15 -16
- package/.framework/functions/admin-data.ts +596 -173
- package/.framework/functions/admin-funnel.ts +64 -60
- package/.framework/functions/admin-install-funnel.ts +84 -66
- package/.framework/functions/admin-signals.ts +69 -51
- package/.framework/functions/ai-agents.ts +431 -106
- package/.framework/functions/ai-interactions.ts +186 -112
- package/.framework/functions/api-keys.ts +107 -107
- package/.framework/functions/apps.ts +154 -136
- package/.framework/functions/auth.ts +83 -65
- package/.framework/functions/cil-agent-ingest.ts +189 -232
- package/.framework/functions/cil-agent.ts +433 -177
- package/.framework/functions/cil-callmap.ts +642 -430
- package/.framework/functions/cil-config.ts +139 -135
- package/.framework/functions/cil-context.ts +214 -127
- package/.framework/functions/cil-doc.ts +587 -458
- package/.framework/functions/cil-embeddings.ts +453 -364
- package/.framework/functions/cil-graph.ts +427 -142
- package/.framework/functions/cil-ingest.ts +1418 -1154
- package/.framework/functions/cil-pipeline.ts +276 -21
- package/.framework/functions/cil-project.ts +659 -132
- package/.framework/functions/cil-validate.ts +198 -164
- package/.framework/functions/debug-auth.ts +57 -55
- package/.framework/functions/deliveries.ts +80 -21
- package/.framework/functions/embeddings.ts +1023 -318
- package/.framework/functions/eval-harness.ts +146 -108
- package/.framework/functions/integration-outbound.ts +205 -75
- package/.framework/functions/integration-routes.ts +128 -23
- package/.framework/functions/integrations.ts +125 -100
- package/.framework/functions/invites.ts +1095 -460
- package/.framework/functions/item-progress.ts +158 -102
- package/.framework/functions/kb.ts +34 -10
- package/.framework/functions/logs.ts +133 -133
- package/.framework/functions/observability.ts +152 -122
- package/.framework/functions/pipeline-executions.ts +147 -132
- package/.framework/functions/pipelines.ts +134 -119
- package/.framework/functions/prompt-configs.ts +96 -80
- package/.framework/functions/roles.ts +112 -82
- package/.framework/functions/security.ts +450 -0
- package/.framework/functions/system-cron.ts +117 -80
- package/.framework/functions/system.ts +158 -98
- package/.framework/functions/tests.ts +29 -29
- package/.framework/functions/timers.ts +94 -95
- package/.framework/functions/trigger-scheduler.ts +10 -0
- package/.framework/functions/triggers.ts +179 -149
- package/.framework/functions/types.ts +137 -125
- package/.framework/mcp/index.ts +133 -0
- package/.framework/mcp/load-env.ts +60 -0
- package/.framework/mcp/shared/app-manifest.ts +275 -0
- package/.framework/mcp/shared/db.ts +477 -0
- package/.framework/mcp/shared/kb.ts +118 -0
- package/.framework/mcp/tools/architect.ts +431 -0
- package/.framework/mcp/tools/cil/context.ts +345 -0
- package/.framework/mcp/tools/cil/graph.ts +242 -0
- package/.framework/mcp/tools/cil/ingest.ts +1217 -0
- package/.framework/mcp/tools/cil/pipeline-orchestrator.ts +693 -0
- package/.framework/mcp/tools/cil/pipeline.ts +767 -0
- package/.framework/mcp/tools/cil/project.ts +791 -0
- package/.framework/mcp/tools/cil/retrieval.ts +336 -0
- package/.framework/mcp/tools/cil/search-core.ts +454 -0
- package/.framework/mcp/tools/cil/search.ts +97 -0
- package/.framework/mcp/tools/cil/suggest.ts +186 -0
- package/.framework/mcp/tools/cil/validate.ts +1369 -0
- package/.framework/mcp/tools/kb/delete.ts +139 -0
- package/.framework/mcp/tools/kb/index.ts +52 -0
- package/.framework/mcp/tools/kb/ingest.ts +84 -0
- package/.framework/mcp/tools/kb/list-types.ts +102 -0
- package/.framework/mcp/tools/kb/publish.ts +100 -0
- package/.framework/mcp/tools/kb/reindex.ts +86 -0
- package/.framework/mcp/tools/kb/revoke.ts +85 -0
- package/.framework/mcp/tools/kb/search.ts +101 -0
- package/.framework/mcp/tools/kb/upsert.ts +125 -0
- package/.framework/mcp/tools/observability.ts +510 -0
- package/.framework/migrations/001_core_schema.sql +15 -0
- package/.framework/migrations/002_core_rls_and_functions.sql +15 -0
- package/.framework/migrations/003_core_system_data.sql +16 -1
- package/.framework/migrations/004_core_rpc_and_broker.sql +17 -1
- package/.framework/migrations/005_core_observability.sql +17 -1
- package/.framework/migrations/006_security_hardening_rls.sql +15 -0
- package/.framework/migrations/007_kb_article_list.sql +17 -1
- package/.framework/migrations/008_items_target.sql +15 -0
- package/.framework/migrations/009_roles_slug_unique.sql +15 -0
- package/.framework/migrations/010_auth_user_trigger.sql +15 -0
- package/.framework/migrations/011_spine_system_account.sql +16 -0
- package/.framework/migrations/012_service_role_grants.sql +16 -0
- package/.framework/migrations/013_get_account_apps_role_filter.sql +15 -0
- package/.framework/migrations/014_apps_required_roles.sql +16 -0
- package/.framework/migrations/015_types_kind_slug_unique.sql +20 -0
- package/.framework/migrations/016_cil_types.sql +281 -0
- package/.framework/migrations/017_cil_stable_ids.sql +37 -0
- package/.framework/migrations/018_runtime_tables.sql +129 -0
- package/.framework/migrations/019_agent_prompt_columns.sql +56 -0
- package/.framework/migrations/020_schema_reconciliation.sql +67 -0
- package/.framework/migrations/021_kb_embedding_lifecycle.sql +31 -0
- package/.framework/migrations/032_cil_status_migration.sql +73 -0
- package/.framework/migrations/033_cil_versioning.sql +73 -0
- package/.framework/migrations/034_match_embeddings_knn.sql +115 -0
- package/.framework/migrations/035_rate_limits.sql +55 -0
- package/.framework/migrations/036_demo_record_flags.sql +72 -0
- package/.framework/migrations/037_kb_types_canonical.sql +244 -0
- package/.framework/migrations/038_drop_demo_record_flags.sql +38 -0
- package/.framework/migrations/042_registration_hierarchy.sql +309 -0
- package/.framework/migrations/043_policy_actor_cleanup.sql +39 -0
- package/.framework/migrations/044_match_embeddings_filtered_knn.sql +151 -0
- package/.framework/migrations/045_security_critical_rls.sql +139 -0
- package/.framework/migrations/046_security_missing_rls.sql +79 -0
- package/.framework/migrations/047_people_updated_by.sql +27 -0
- package/.framework/migrations/048_watcher_last_seen_at.sql +24 -0
- package/.framework/migrations/049_security_blocklist.sql +148 -0
- package/.framework/migrations/050_notifications.sql +49 -0
- package/.framework/migrations/051_message_agent_fields.sql +74 -0
- package/.framework/migrations/052_registration_security.sql +421 -0
- package/.framework/migrations/053_builtin_action_seeds.sql +66 -0
- package/.framework/migrations/054_kb_ingest_lease.sql +157 -0
- package/.framework/migrations/055_type_id_drift_reconciliation.sql +33 -0
- package/.framework/migrations/056_slug_column_reconciliation.sql +38 -0
- package/.framework/migrations/057_pipelines_slug_identity.sql +14 -0
- package/.framework/migrations/058_account_data_field_declarations.sql +53 -0
- package/.framework/migrations/059_registration_placement_fixes.sql +269 -0
- package/.framework/migrations/060_account_person_record_permissions.sql +38 -0
- package/.framework/migrations/061_fk_dedup.sql +32 -0
- package/.framework/public/spine-logo.svg +10 -3
- package/.framework/scripts/app-install-cli.ts +190 -93
- package/.framework/scripts/assemble-frontend.sh +127 -44
- package/.framework/scripts/assemble-functions.sh +128 -30
- package/.framework/scripts/boundary-check.sh +6 -2
- package/.framework/scripts/build-manifest.sh +24 -68
- package/.framework/scripts/check-core-integrity.sh +15 -76
- package/.framework/scripts/checksum-manifest.mts +343 -0
- package/.framework/scripts/cil-migrate-markers.ts +403 -0
- package/.framework/scripts/fix-cil-markers.mjs +176 -0
- package/.framework/scripts/verify-integrity.sh +21 -57
- package/.framework/scripts/verify-manifest.mts +305 -0
- package/.framework/seeds/types/funnel_signal_use.json +74 -21
- package/.framework/seeds/types/spine_instance.json +73 -21
- package/.framework/src/App.tsx +118 -72
- package/.framework/src/apps/admin/index.tsx +855 -58
- package/.framework/src/components/AppWrapper.tsx +43 -45
- package/.framework/src/components/CustomAppLoader.tsx +160 -116
- package/.framework/src/components/admin/AdminListPage.tsx +46 -44
- package/.framework/src/components/admin/AdminSidebar.tsx +57 -47
- package/.framework/src/components/admin/AdminStatsCard.tsx +46 -44
- package/.framework/src/components/admin/PageInstructions.tsx +98 -2
- package/.framework/src/components/admin/SortableTableHeader.tsx +44 -45
- package/.framework/src/components/app-shell/GenericAppShell.tsx +64 -65
- package/.framework/src/components/app-shell/GenericDetailPage.tsx +44 -47
- package/.framework/src/components/app-shell/GenericListPage.tsx +45 -49
- package/.framework/src/components/app-sidebar.tsx +42 -45
- package/.framework/src/components/auth/ProtectedRoute.tsx +48 -41
- package/.framework/src/components/auth/TurnstileWidget.tsx +27 -0
- package/.framework/src/components/kb/KBArticleEditor.tsx +231 -22
- package/.framework/src/components/kb/KBArticleList.tsx +251 -10
- package/.framework/src/components/layout/AppShell.tsx +51 -45
- package/.framework/src/components/layout/Header.tsx +42 -43
- package/.framework/src/components/layout/Layout.tsx +46 -46
- package/.framework/src/components/layout/Sidebar.tsx +196 -96
- package/.framework/src/components/runtime/DataDetailHeader.tsx +55 -30
- package/.framework/src/components/runtime/DataDetailPage.tsx +31 -269
- package/.framework/src/components/runtime/DataFilters.tsx +49 -74
- package/.framework/src/components/runtime/DataHeader.tsx +53 -32
- package/.framework/src/components/runtime/DataListPage.tsx +51 -155
- package/.framework/src/components/runtime/DataStats.tsx +66 -44
- package/.framework/src/components/runtime/DataTable.tsx +49 -149
- package/.framework/src/components/runtime/SchemaDetailForm.tsx +45 -75
- package/.framework/src/components/runtime/index.ts +119 -16
- package/.framework/src/components/search-form.tsx +46 -29
- package/.framework/src/components/shared/AgentView.tsx +65 -48
- package/.framework/src/components/shared/FieldRenderer.tsx +144 -50
- package/.framework/src/components/shared/InviteManager.tsx +207 -97
- package/.framework/src/components/shared/MemberList.tsx +97 -0
- package/.framework/src/components/shared/SchemaFields.tsx +107 -86
- package/.framework/src/components/ui/DataTable.tsx +80 -68
- package/.framework/src/components/ui/Form.tsx +157 -146
- package/.framework/src/components/ui/ItemCard.tsx +74 -67
- package/.framework/src/components/ui/ItemListView.tsx +73 -68
- package/.framework/src/components/ui/LoadingSpinner.tsx +43 -48
- package/.framework/src/components/ui/Modal.tsx +78 -68
- package/.framework/src/components/ui/RichTextEditor.tsx +89 -69
- package/.framework/src/components/ui/accordion.tsx +85 -86
- package/.framework/src/components/ui/alert-dialog.tsx +197 -184
- package/.framework/src/components/ui/alert.tsx +105 -94
- package/.framework/src/components/ui/aspect-ratio.tsx +57 -43
- package/.framework/src/components/ui/avatar.tsx +122 -107
- package/.framework/src/components/ui/badge.tsx +60 -55
- package/.framework/src/components/ui/breadcrumb.tsx +127 -128
- package/.framework/src/components/ui/button-group.tsx +86 -72
- package/.framework/src/components/ui/button.tsx +71 -50
- package/.framework/src/components/ui/calendar.tsx +72 -57
- package/.framework/src/components/ui/card.tsx +136 -129
- package/.framework/src/components/ui/carousel.tsx +226 -107
- package/.framework/src/components/ui/chart.tsx +252 -147
- package/.framework/src/components/ui/checkbox.tsx +43 -44
- package/.framework/src/components/ui/collapsible.tsx +86 -71
- package/.framework/src/components/ui/combobox.tsx +282 -249
- package/.framework/src/components/ui/command.tsx +158 -146
- package/.framework/src/components/ui/context-menu.tsx +239 -240
- package/.framework/src/components/ui/dialog.tsx +174 -157
- package/.framework/src/components/ui/direction.tsx +72 -56
- package/.framework/src/components/ui/drawer.tsx +168 -169
- package/.framework/src/components/ui/dropdown-menu.tsx +254 -223
- package/.framework/src/components/ui/empty.tsx +131 -120
- package/.framework/src/components/ui/field.tsx +205 -173
- package/.framework/src/components/ui/hover-card.tsx +71 -72
- package/.framework/src/components/ui/input-group.tsx +148 -133
- package/.framework/src/components/ui/input-otp.tsx +99 -86
- package/.framework/src/components/ui/input.tsx +43 -41
- package/.framework/src/components/ui/item.tsx +207 -185
- package/.framework/src/components/ui/kbd.tsx +57 -56
- package/.framework/src/components/ui/label.tsx +45 -41
- package/.framework/src/components/ui/menubar.tsx +268 -236
- package/.framework/src/components/ui/native-select.tsx +85 -86
- package/.framework/src/components/ui/navigation-menu.tsx +166 -156
- package/.framework/src/components/ui/pagination.tsx +131 -141
- package/.framework/src/components/ui/popover.tsx +125 -128
- package/.framework/src/components/ui/progress.tsx +47 -44
- package/.framework/src/components/ui/radio-group.tsx +60 -55
- package/.framework/src/components/ui/resizable.tsx +85 -72
- package/.framework/src/components/ui/scroll-area.tsx +57 -58
- package/.framework/src/components/ui/select.tsx +182 -169
- package/.framework/src/components/ui/separator.tsx +42 -43
- package/.framework/src/components/ui/sheet.tsx +170 -159
- package/.framework/src/components/ui/sidebar.tsx +395 -398
- package/.framework/src/components/ui/skeleton.tsx +42 -43
- package/.framework/src/components/ui/slider.tsx +61 -44
- package/.framework/src/components/ui/sonner.tsx +44 -44
- package/.framework/src/components/ui/spinner.tsx +47 -42
- package/.framework/src/components/ui/switch.tsx +56 -42
- package/.framework/src/components/ui/table-primitives.tsx +272 -132
- package/.framework/src/components/ui/table.tsx +140 -142
- package/.framework/src/components/ui/tabs.tsx +110 -93
- package/.framework/src/components/ui/textarea.tsx +43 -44
- package/.framework/src/components/ui/toggle-group.tsx +87 -71
- package/.framework/src/components/ui/toggle.tsx +56 -56
- package/.framework/src/components/ui/tooltip.tsx +99 -85
- package/.framework/src/contexts/AppContext.tsx +166 -114
- package/.framework/src/contexts/AuthContext.tsx +232 -137
- package/.framework/src/hooks/use-mobile.ts +43 -44
- package/.framework/src/hooks/useApi.ts +185 -172
- package/.framework/src/hooks/useAppPath.ts +31 -29
- package/.framework/src/hooks/useApps.ts +77 -42
- package/.framework/src/hooks/useEntityList.ts +66 -29
- package/.framework/src/hooks/useEntityRecord.ts +76 -32
- package/.framework/src/hooks/useForm.ts +62 -30
- package/.framework/src/hooks/useListSchema.ts +60 -43
- package/.framework/src/hooks/useSchemaRecord.ts +115 -95
- package/.framework/src/lib/api.ts +258 -134
- package/.framework/src/lib/registration.ts +181 -0
- package/.framework/src/lib/supabase.ts +118 -81
- package/.framework/src/lib/utils.ts +266 -266
- package/.framework/src/main.tsx +43 -44
- package/.framework/src/pages/DashboardPage.tsx +44 -43
- package/.framework/src/pages/NoAppPage.tsx +50 -0
- package/.framework/src/pages/NotFoundPage.tsx +32 -29
- package/.framework/src/pages/SetupPage.tsx +34 -33
- package/.framework/src/pages/admin/AIAgentDetailPage.tsx +69 -58
- package/.framework/src/pages/admin/AIAgentsPage.tsx +43 -40
- package/.framework/src/pages/admin/APIKeyDetailPage.tsx +63 -55
- package/.framework/src/pages/admin/APIKeysPage.tsx +44 -42
- package/.framework/src/pages/admin/AlertsConfigPage.tsx +117 -94
- package/.framework/src/pages/admin/AppDetailPage.tsx +48 -42
- package/.framework/src/pages/admin/AppsPage.tsx +45 -42
- package/.framework/src/pages/admin/DeliveriesPage.tsx +49 -17
- package/.framework/src/pages/admin/DesignedPage.tsx +31 -30
- package/.framework/src/pages/admin/EmbeddingDetailPage.tsx +58 -0
- package/.framework/src/pages/admin/EmbeddingsPage.tsx +49 -0
- package/.framework/src/pages/admin/ExtendedShadcnTestPage.tsx +31 -29
- package/.framework/src/pages/admin/IncrementalShadcnTestPage.tsx +46 -29
- package/.framework/src/pages/admin/IntegratedDashboard.tsx +32 -29
- package/.framework/src/pages/admin/IntegrationDetailPage.tsx +68 -55
- package/.framework/src/pages/admin/IntegrationsPage.tsx +45 -42
- package/.framework/src/pages/admin/InvitesPage.tsx +60 -44
- package/.framework/src/pages/admin/LogsPage.tsx +87 -137
- package/.framework/src/pages/admin/MinimalShadcnTestPage.tsx +31 -29
- package/.framework/src/pages/admin/ObservabilityDashboard.tsx +150 -89
- package/.framework/src/pages/admin/PipelineDetailPage.tsx +77 -104
- package/.framework/src/pages/admin/PipelineExecutionsPage.tsx +44 -43
- package/.framework/src/pages/admin/PipelinesPage.tsx +59 -145
- package/.framework/src/pages/admin/PromptConfigDetailPage.tsx +53 -42
- package/.framework/src/pages/admin/PromptConfigsPage.tsx +47 -117
- package/.framework/src/pages/admin/ProperlyDesignedPage.tsx +31 -44
- package/.framework/src/pages/admin/RoleDetailPage.tsx +49 -92
- package/.framework/src/pages/admin/RolesPage.tsx +47 -164
- package/.framework/src/pages/admin/SecurityPage.tsx +310 -0
- package/.framework/src/pages/admin/SelectTestPage.tsx +30 -32
- package/.framework/src/pages/admin/ShadcnTestPage.tsx +37 -44
- package/.framework/src/pages/admin/SimpleDashboard.tsx +32 -44
- package/.framework/src/pages/admin/TestRunDetailPage.tsx +97 -44
- package/.framework/src/pages/admin/TestingDashboard.tsx +126 -71
- package/.framework/src/pages/admin/TimerDetailPage.tsx +67 -55
- package/.framework/src/pages/admin/TimersPage.tsx +44 -42
- package/.framework/src/pages/admin/TriggerDetailPage.tsx +47 -42
- package/.framework/src/pages/admin/TriggersPage.tsx +58 -57
- package/.framework/src/pages/admin/TypeDetailPage.tsx +91 -55
- package/.framework/src/pages/admin/TypesPage.tsx +45 -42
- package/.framework/src/pages/admin/cil/CILAgentPage.tsx +258 -128
- package/.framework/src/pages/admin/cil/CILChunkDetailPage.tsx +127 -123
- package/.framework/src/pages/admin/cil/CILDashboardPage.tsx +308 -235
- package/.framework/src/pages/admin/cil/CILFileListPage.tsx +159 -110
- package/.framework/src/pages/admin/cil/CILFileSelectPage.tsx +432 -0
- package/.framework/src/pages/admin/cil/CILGraphPage.tsx +200 -178
- package/.framework/src/pages/admin/cil/CILIngestionPage.tsx +286 -239
- package/.framework/src/pages/admin/cil/CILProjectsPage.tsx +211 -90
- package/.framework/src/pages/admin/cil/CILSearchPage.tsx +156 -143
- package/.framework/src/pages/admin/cil/CILSuggestionsPage.tsx +379 -0
- package/.framework/src/pages/admin/cil/CILVersionsPage.tsx +337 -0
- package/.framework/src/pages/admin/cil/FlexiblePipelinePage.tsx +219 -214
- package/.framework/src/pages/admin/kb/KBAdminPage.tsx +64 -0
- package/.framework/src/pages/auth/AuthConfirmPage.tsx +135 -65
- package/.framework/src/pages/auth/ForgotPasswordPage.tsx +39 -31
- package/.framework/src/pages/auth/LoginPage.tsx +38 -32
- package/.framework/src/pages/auth/PendingApprovalPage.tsx +31 -28
- package/.framework/src/pages/auth/RegisterPage.tsx +429 -155
- package/.framework/src/pages/spine-framework/APIPage.tsx +33 -30
- package/.framework/src/pages/spine-framework/CLIPage.tsx +32 -30
- package/.framework/src/types/auth.ts +101 -93
- package/.framework/src/types/types.ts +283 -262
- package/.framework/templates/project.json +87 -0
- package/.framework/templates/spine.config.neutral.json +7 -0
- package/.framework/tests/api/api-surface.test.ts +381 -0
- package/.framework/tests/fixtures/seed.ts +427 -0
- package/.framework/tests/fixtures/teardown.ts +228 -0
- package/.framework/tests/reporter.ts +351 -0
- package/.framework/tests/setup.ts +135 -0
- package/.framework/tests/ui/ui-sweep.ts +278 -0
- package/.framework/tests/unit/admin-data-logger.test.ts +310 -0
- package/.framework/tests/unit/agent-runner.test.ts +2389 -0
- package/.framework/tests/unit/ai-interactions.test.ts +81 -0
- package/.framework/tests/unit/app-manifest.test.ts +359 -0
- package/.framework/tests/unit/assembly-scripts.test.ts +172 -0
- package/.framework/tests/unit/cil-determinism.test.ts +85 -0
- package/.framework/tests/unit/core-isolation.test.ts +153 -0
- package/.framework/tests/unit/funnel-signals.test.ts +135 -0
- package/.framework/tests/unit/install-app.test.ts +1759 -0
- package/.framework/tests/unit/invites-security.test.ts +572 -0
- package/.framework/tests/unit/kb-ingest-lease.test.ts +287 -0
- package/.framework/tests/unit/kb-search.test.ts +119 -0
- package/.framework/tests/unit/migrate.test.ts +509 -0
- package/.framework/tests/unit/notify.test.ts +136 -0
- package/.framework/tests/unit/permissions.test.ts +269 -0
- package/.framework/tests/unit/pipeline-runner.test.ts +755 -0
- package/.framework/tests/unit/principal-cache.test.ts +138 -0
- package/.framework/tests/unit/retrieval-golden.test.ts +520 -0
- package/.framework/tests/unit/runtime-isolation.test.ts +642 -0
- package/.framework/tests/unit/schema-utils.test.ts +225 -0
- package/.framework/tests/unit/trigger-engine.test.ts +513 -0
- package/.framework/tests/unit/validate-app.test.ts +527 -0
- package/README.md +34 -3
- package/bin/spine-framework.cjs +1 -0
- package/config/tailwind.config.cjs +7 -0
- package/config/tsconfig.functions.json +42 -0
- package/config/tsconfig.json +37 -9
- package/config/vite.config.ts +31 -2
- package/netlify.toml +31 -3
- package/package.json +46 -29
- package/scripts/assemble-frontend.sh +127 -44
- package/scripts/assemble-functions.sh +127 -29
- package/scripts/boundary-check.sh +6 -2
- package/scripts/build-manifest.sh +24 -68
- package/scripts/checksum-manifest.mts +345 -0
- package/scripts/dev-clean.sh +86 -0
- package/scripts/dev-netlify.sh +49 -0
- package/scripts/netlify-dev-wrapper.sh +2 -0
- package/scripts/verify-install.ts +358 -0
- package/scripts/verify-integrity.sh +21 -57
- package/scripts/verify-manifest.mts +305 -0
- package/templates/project/gitignore +45 -0
- package/{config → templates/project}/package-lock.json +22335 -9366
- package/vitest.config.ts +46 -0
- package/.framework/public/spine.config.json +0 -91
- package/config/deno.lock +0 -108
- package/config/tsconfig.node.tsbuildinfo +0 -1
- package/config/tsconfig.tsbuildinfo +0 -1
- package/config/vite.config.d.ts +0 -2
- package/custom/.devin/AGENT.md +0 -357
- package/custom/.devin/skills/install-app/SKILL.md +0 -39
- package/custom/.devin/skills/spine-workbench-discovery/SKILL.md +0 -39
- package/custom/.devin/skills/spine-workbench-idea/SKILL.md +0 -36
- package/custom/.devin/skills/spine-workbench-implement/SKILL.md +0 -46
- package/custom/.devin/skills/spine-workbench-initiative/SKILL.md +0 -28
- package/custom/.devin/skills/spine-workbench-plan/SKILL.md +0 -38
- package/custom/.devin/workflows/app-install.yaml +0 -83
- package/custom/README.md +0 -79
- package/docs/README.md +0 -15
- package/scripts/app-install-cli.ts +0 -286
- package/scripts/check-core-integrity.sh +0 -82
- package/scripts/ingest-chunks.cjs +0 -202
- package/scripts/kb-chunk-parser.cjs +0 -312
- package/scripts/kb-chunk-parser.ts +0 -330
- package/scripts/kb-ingest-docs.ts +0 -203
- package/scripts/load-test-app-install.ts +0 -484
- package/scripts/test-login.js +0 -33
- package/spine.config.json +0 -91
|
@@ -1,8 +1,32 @@
|
|
|
1
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:MAP_SOURCE_STATUS:constant" type="constant" identity="MAP_SOURCE_STATUS" parent="~/.framework/functions/cil-callmap.ts"]
|
|
2
|
+
// CIL[DOC-MACRO purpose="Define source file status mapping for CIL callmap pass transitions"]
|
|
3
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Provide the prior and target statuses that qualify files for mapping"]
|
|
4
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="constant" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
5
|
+
// CIL[DOC-CONTRACT inputs="none" outputs="Record of first/second pass status transitions" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
6
|
+
// CIL[DOC-MICRO logic_summary="Maps 'first' and 'second' pass statuses to prior and target FileStatus values" notable_decisions="[]"]
|
|
7
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
8
|
+
// CIL[DOC-STABILITY stability="stable"]
|
|
1
9
|
|
|
2
|
-
const MAP_SOURCE_STATUS: Record<'first' | 'second', { prior:
|
|
3
|
-
first: { prior: '6-
|
|
4
|
-
second: { prior: '
|
|
10
|
+
const MAP_SOURCE_STATUS: Record<'first' | 'second', { prior: FileStatus; target: FileStatus }> = {
|
|
11
|
+
first: { prior: '6-enriched', target: '7-embedded-mapped' },
|
|
12
|
+
second: { prior: '6-enriched', target: '7-embedded-mapped' },
|
|
5
13
|
}
|
|
14
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Define source file status mapping for CIL callmap pass transitions'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
15
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
16
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
17
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
18
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
19
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
20
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:MAP_SOURCE_STATUS:constant"]
|
|
21
|
+
|
|
22
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:getMapSourceFilePaths:function" type="function" identity="getMapSourceFilePaths" parent="~/.framework/functions/cil-callmap.ts"]
|
|
23
|
+
// CIL[DOC-MACRO purpose="Filter project file statuses to find files eligible for mapping"]
|
|
24
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Return the list of file paths whose current status matches the mapping prior status"]
|
|
25
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
26
|
+
// CIL[DOC-CONTRACT inputs="projectItem, secondPass flag" outputs="string[] of file paths" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
27
|
+
// CIL[DOC-MICRO logic_summary="Reads project file statuses and returns paths whose status equals the configured prior status" notable_decisions="[]"]
|
|
28
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
29
|
+
// CIL[DOC-STABILITY stability="stable"]
|
|
6
30
|
|
|
7
31
|
function getMapSourceFilePaths(projectItem: any, secondPass: boolean): string[] {
|
|
8
32
|
const fileStatuses: Record<string, string> = projectItem?.data?.file_statuses || {}
|
|
@@ -11,34 +35,43 @@ function getMapSourceFilePaths(projectItem: any, secondPass: boolean): string[]
|
|
|
11
35
|
.filter(([, status]) => status === prior)
|
|
12
36
|
.map(([filePath]) => filePath)
|
|
13
37
|
}
|
|
14
|
-
|
|
15
|
-
// CIL[
|
|
16
|
-
// CIL[DOC-
|
|
17
|
-
// CIL[DOC-
|
|
18
|
-
// CIL[DOC-CONTEXT module="cortex.functions.custom_cil-callmap" layer="function" related_files="[\".framework/migrations/015_simplify_apps_table.sql\",\"custom/apps/cortex/pages/operations/OperationsDashboard.tsx\",\"custom/apps/portal/pages/ContentPage.tsx\",\".framework/src/components/ui/table-primitives.tsx\",\".framework/src/pages/admin/TypeDetailPage.tsx\",\"\\\"]"]
|
|
19
|
-
// CIL[DOC-CONTRACT inputs="none" outputs="module exports and side effects" errors="none" side_effects="none"]
|
|
20
|
-
// CIL[DOC-MICRO logic_summary="Declares module scope, imports dependencies, and exports public surface of cortex.functions.custom_cil-callmap" notable_decisions="[]"]
|
|
21
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.95" flags="none"]
|
|
22
|
-
// CIL[DOC-STABILITY stability="stable"]
|
|
23
|
-
// CIL[DOC-AUDIENCE audience="developer"]
|
|
24
|
-
// CIL[DOC-VECTOR type="context" content="Layer: function. Direct callers: 0. Direct calls: 0. Related files: .framework/migrations/015_simplify_apps_table.sql, custom/apps/cortex/pages/operations/OperationsDashboard.tsx, custom/apps/portal/pages/ContentPage.tsx, .framework/src/components/ui/table-primitives.tsx, .framework/src/pages/admin/TypeDetailPage.tsx, \."]
|
|
25
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 0. Total affected: 0."]
|
|
26
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
27
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
38
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Filter project file statuses to find files eligible for mapping'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
39
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
40
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
41
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
28
42
|
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
29
43
|
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
44
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:getMapSourceFilePaths:function"]
|
|
45
|
+
|
|
30
46
|
|
|
31
47
|
|
|
32
48
|
|
|
33
49
|
|
|
34
50
|
|
|
51
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:module_header:module_header" type="module_header" identity="module_header" parent="~/.framework/functions/cil-callmap.ts"]
|
|
52
|
+
// CIL[DOC-MACRO purpose="Import dependencies and set module context for the .framework/functions/cil-callmap Netlify function"]
|
|
53
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Load shared middleware, database, admin-data, CIL helpers and path utilities for the callmap handler"]
|
|
54
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="module_header" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts"]
|
|
55
|
+
// CIL[DOC-CONTRACT inputs="none" outputs="none" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
56
|
+
// CIL[DOC-MICRO logic_summary="Imports createHandler, adminDb, resolve-ids, admin-data CRUD, CIL status helpers, fs and path for the handler" notable_decisions="[]"]
|
|
57
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
58
|
+
// CIL[DOC-STABILITY stability="stable"]
|
|
59
|
+
// CIL[DOC-AUDIENCE audience="maintainer"]
|
|
60
|
+
|
|
35
61
|
import { createHandler } from './_shared/middleware'
|
|
36
62
|
import { adminDb } from './_shared/db'
|
|
37
|
-
import {
|
|
63
|
+
import { resolveLinkTypeIds } from './_shared/resolve-ids'
|
|
38
64
|
import { create as adminCreate, update as adminUpdate } from './admin-data'
|
|
39
65
|
import { FileStatus, FileTreeNode, isSelectedPath, getFileStatus, updateTreeNodeStatus, saveProjectTree } from './_shared/cil'
|
|
40
66
|
import * as fs from 'fs'
|
|
41
67
|
import * as path from 'path'
|
|
68
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Import dependencies and set module context for the .framework/functions/cil-callmap Netlify function'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
69
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
70
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
71
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
72
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
73
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
74
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:module_header:module_header"]
|
|
42
75
|
|
|
43
76
|
|
|
44
77
|
|
|
@@ -48,67 +81,209 @@ import * as path from 'path'
|
|
|
48
81
|
|
|
49
82
|
|
|
50
83
|
|
|
51
|
-
// CIL[
|
|
52
|
-
// CIL[
|
|
53
|
-
// CIL[DOC-
|
|
54
|
-
// CIL[DOC-
|
|
55
|
-
// CIL[DOC-
|
|
56
|
-
// CIL[DOC-
|
|
57
|
-
// CIL[DOC-
|
|
58
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.
|
|
59
|
-
|
|
60
|
-
// CIL[DOC-VECTOR type="context" content="Layer: function. Direct callers: 0. Direct calls: 0. Related files: .framework/src/pages/admin/TypeDetailPage.tsx, .framework/functions/_shared/principal.ts, custom/apps/cortex/functions/custom_cil-embeddings.ts, .framework/src/pages/admin/IntegrationsPage.tsx, custom/apps/portal/pages/ContentPage.tsx, \."]
|
|
61
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 0. Total affected: 0."]
|
|
62
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
63
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
64
|
-
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
65
|
-
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
84
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:STATUS_RANK:constant" type="constant" identity="STATUS_RANK" parent="~/.framework/functions/cil-callmap.ts"]
|
|
85
|
+
// CIL[DOC-MACRO purpose="Define numeric ordering for CIL pipeline file statuses"]
|
|
86
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Provide a rank lookup for comparing CIL file status progression"]
|
|
87
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="constant" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
88
|
+
// CIL[DOC-CONTRACT inputs="none" outputs="Record<string, number>" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
89
|
+
// CIL[DOC-MICRO logic_summary="Maps each pipeline status string to an integer rank for ordering comparisons" notable_decisions="[]"]
|
|
90
|
+
// CIL[DOC-STABILITY stability="internal"]
|
|
91
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
92
|
+
|
|
66
93
|
const STATUS_RANK: Record<string, number> = {
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
|
|
77
|
-
'pass2_complete': 4,
|
|
78
|
-
'pass3_complete': 5,
|
|
79
|
-
'pass4_complete': 6,
|
|
80
|
-
'pass4b_complete': 7,
|
|
81
|
-
'pass6_complete': 8,
|
|
82
|
-
'pass7_complete': 9,
|
|
83
|
-
'pass8_complete': 10,
|
|
94
|
+
'0-discovered': 0,
|
|
95
|
+
'1-selected': 1,
|
|
96
|
+
'2-chunked': 2,
|
|
97
|
+
'3-documented': 3,
|
|
98
|
+
'4-chunk-validated': 4,
|
|
99
|
+
'5-doc-validated': 5,
|
|
100
|
+
'6-enriched': 6,
|
|
101
|
+
'7-embedded-mapped': 7,
|
|
102
|
+
'8-published': 8,
|
|
84
103
|
}
|
|
104
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:STATUS_RANK:constant"]
|
|
85
105
|
|
|
86
106
|
// Keep REST URL length under the ~8k character limit for UUID IN clauses.
|
|
107
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:UUID_IN_LIMIT:constant" type="constant" identity="UUID_IN_LIMIT" parent="~/.framework/functions/cil-callmap.ts"]
|
|
108
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Define numeric ordering for CIL pipeline file statuses'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
109
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
110
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
111
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
112
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
113
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
114
|
+
// CIL[DOC-MACRO purpose="Set the maximum UUID count for IN clause link deletions"]
|
|
115
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Limit the size of UUID IN clause batches to keep REST URLs under ~8k"]
|
|
116
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="constant" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
117
|
+
// CIL[DOC-CONTRACT inputs="none" outputs="number" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
118
|
+
// CIL[DOC-MICRO logic_summary="Declares a constant of 100 UUIDs per batched IN clause" notable_decisions="[]"]
|
|
119
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
120
|
+
// CIL[DOC-STABILITY stability="stable"]
|
|
121
|
+
|
|
87
122
|
const UUID_IN_LIMIT = 100
|
|
123
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Set the maximum UUID count for IN clause link deletions'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
124
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
125
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
126
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
127
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
128
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
129
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:UUID_IN_LIMIT:constant"]
|
|
130
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:PAGE_SIZE:constant" type="constant" identity="PAGE_SIZE" parent="~/.framework/functions/cil-callmap.ts"]
|
|
131
|
+
// CIL[DOC-MACRO purpose="Set the page size for batched project record fetching"]
|
|
132
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Limit each adminDb query to 1000 rows for pagination"]
|
|
133
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="constant" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
134
|
+
// CIL[DOC-CONTRACT inputs="none" outputs="number" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
135
|
+
// CIL[DOC-MICRO logic_summary="Declares a constant of 1000 records per page" notable_decisions="[]"]
|
|
136
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
137
|
+
// CIL[DOC-STABILITY stability="stable"]
|
|
88
138
|
|
|
139
|
+
const PAGE_SIZE = 1000
|
|
140
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Set the page size for batched project record fetching'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
141
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
142
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
143
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
144
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
145
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
146
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:PAGE_SIZE:constant"]
|
|
147
|
+
|
|
148
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:fetchAllProjectRecords:function" type="function" identity="fetchAllProjectRecords" parent="~/.framework/functions/cil-callmap.ts"]
|
|
149
|
+
// CIL[DOC-MACRO purpose="Fetch all project records of a given KB type in pages"]
|
|
150
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Return every active item of the requested kb_type for a project"]
|
|
151
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
152
|
+
// CIL[DOC-CONTRACT inputs="projectId, kbType" outputs="any[] of item rows" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
153
|
+
// CIL[DOC-MICRO logic_summary="Paginates through items using offset ranges and accumulates all rows" notable_decisions="[]"]
|
|
154
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
155
|
+
// CIL[DOC-STABILITY stability="stable"]
|
|
89
156
|
|
|
157
|
+
async function fetchAllProjectRecords(
|
|
158
|
+
projectId: string,
|
|
159
|
+
kbType: 'cil_file' | 'cil_chunk'
|
|
160
|
+
): Promise<any[]> {
|
|
161
|
+
const out: any[] = []
|
|
162
|
+
let offset = 0
|
|
163
|
+
while (true) {
|
|
164
|
+
const { data } = await adminDb
|
|
165
|
+
.from('items')
|
|
166
|
+
.select('id, title, data')
|
|
167
|
+
.filter('data->>project_id', 'eq', projectId)
|
|
168
|
+
.filter('data->>kb_type', 'eq', kbType)
|
|
169
|
+
.eq('is_active', true)
|
|
170
|
+
.order('id')
|
|
171
|
+
.range(offset, offset + PAGE_SIZE - 1)
|
|
172
|
+
const rows = data || []
|
|
173
|
+
out.push(...rows)
|
|
174
|
+
if (rows.length < PAGE_SIZE) break
|
|
175
|
+
offset += PAGE_SIZE
|
|
176
|
+
}
|
|
177
|
+
return out
|
|
178
|
+
}
|
|
179
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Fetch all project records of a given KB type in pages'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
180
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
181
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
182
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
183
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
184
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
185
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:fetchAllProjectRecords:function"]
|
|
186
|
+
|
|
187
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:fetchAllProjectChunkNames:function" type="function" identity="fetchAllProjectChunkNames" parent="~/.framework/functions/cil-callmap.ts"]
|
|
188
|
+
// CIL[DOC-MACRO purpose="Fetch all chunk names and IDs for a project"]
|
|
189
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Return chunk id, chunk_name and kb_type for every active cil_chunk"]
|
|
190
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
191
|
+
// CIL[DOC-CONTRACT inputs="projectId" outputs="{id, chunk_name, kb_type}[]" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
192
|
+
// CIL[DOC-MICRO logic_summary="Paginates cil_chunk items and projects minimal fields for name lookup" notable_decisions="[]"]
|
|
193
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
194
|
+
// CIL[DOC-STABILITY stability="stable"]
|
|
90
195
|
|
|
196
|
+
async function fetchAllProjectChunkNames(projectId: string): Promise<{ id: string; chunk_name: string; kb_type: string }[]> {
|
|
197
|
+
const out: any[] = []
|
|
198
|
+
let offset = 0
|
|
199
|
+
while (true) {
|
|
200
|
+
const { data } = await adminDb
|
|
201
|
+
.from('items')
|
|
202
|
+
.select('id, data->>chunk_name, data->>kb_type')
|
|
203
|
+
.filter('data->>project_id', 'eq', projectId)
|
|
204
|
+
.filter('data->>kb_type', 'eq', 'cil_chunk')
|
|
205
|
+
.eq('is_active', true)
|
|
206
|
+
.order('id')
|
|
207
|
+
.range(offset, offset + PAGE_SIZE - 1)
|
|
208
|
+
const rows = data || []
|
|
209
|
+
out.push(...rows)
|
|
210
|
+
if (rows.length < PAGE_SIZE) break
|
|
211
|
+
offset += PAGE_SIZE
|
|
212
|
+
}
|
|
213
|
+
return out
|
|
214
|
+
}
|
|
215
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Fetch all chunk names and IDs for a project'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
216
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
217
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
218
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
219
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
220
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
221
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:fetchAllProjectChunkNames:function"]
|
|
222
|
+
|
|
223
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:fetchFileChunks:function" type="function" identity="fetchFileChunks" parent="~/.framework/functions/cil-callmap.ts"]
|
|
224
|
+
// CIL[DOC-MACRO purpose="Fetch all chunks for a specific file path"]
|
|
225
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Return every active cil_chunk belonging to a file"]
|
|
226
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
227
|
+
// CIL[DOC-CONTRACT inputs="projectId, filePath" outputs="any[] of chunk rows" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
228
|
+
// CIL[DOC-STABILITY stability="internal"]
|
|
229
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
230
|
+
// CIL[DOC-MICRO logic_summary="Paginates cil_chunk items filtered by project and file_path" notable_decisions="[]"]
|
|
231
|
+
|
|
232
|
+
async function fetchFileChunks(projectId: string, filePath: string): Promise<any[]> {
|
|
233
|
+
const out: any[] = []
|
|
234
|
+
let offset = 0
|
|
235
|
+
while (true) {
|
|
236
|
+
const { data } = await adminDb
|
|
237
|
+
.from('items')
|
|
238
|
+
.select('id, title, data')
|
|
239
|
+
.filter('data->>project_id', 'eq', projectId)
|
|
240
|
+
.filter('data->>kb_type', 'eq', 'cil_chunk')
|
|
241
|
+
.filter('data->>file_path', 'eq', filePath)
|
|
242
|
+
.eq('is_active', true)
|
|
243
|
+
.order('id')
|
|
244
|
+
.range(offset, offset + PAGE_SIZE - 1)
|
|
245
|
+
const rows = data || []
|
|
246
|
+
out.push(...rows)
|
|
247
|
+
if (rows.length < PAGE_SIZE) break
|
|
248
|
+
offset += PAGE_SIZE
|
|
249
|
+
}
|
|
250
|
+
return out
|
|
251
|
+
}
|
|
252
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:fetchFileChunks:function"]
|
|
91
253
|
|
|
92
254
|
|
|
93
255
|
|
|
94
|
-
// CIL[
|
|
95
|
-
// CIL[
|
|
96
|
-
// CIL[DOC-
|
|
97
|
-
// CIL[DOC-
|
|
98
|
-
// CIL[DOC-CONTEXT module="cortex.functions.custom_cil-callmap" layer="function" related_files="[\"custom/apps/cortex/functions/custom_cil-embeddings.ts\",\".framework/functions/_shared/principal.ts\",\".framework/src/pages/admin/TypeDetailPage.tsx\",\".framework/src/pages/admin/IntegrationsPage.tsx\",\".framework/migrations/015_simplify_apps_table.sql\",\"\\\"]"]
|
|
99
|
-
// CIL[DOC-CONTRACT inputs="none" outputs="return value from function execution" errors="throws on invalid input or runtime failure" side_effects="none"]
|
|
100
|
-
// CIL[DOC-MICRO logic_summary="Provides rank with rank(status: string | undefined inputs, handling internal flow and returning a result" notable_decisions="[]"]
|
|
101
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.95" flags="none"]
|
|
102
|
-
// CIL[DOC-STABILITY stability="stable"]
|
|
103
|
-
// CIL[DOC-VECTOR type="context" content="Layer: function. Direct callers: 2. Direct calls: 0. Related files: custom/apps/cortex/functions/custom_cil-embeddings.ts, .framework/functions/_shared/principal.ts, .framework/src/pages/admin/TypeDetailPage.tsx, .framework/src/pages/admin/IntegrationsPage.tsx, .framework/migrations/015_simplify_apps_table.sql, \."]
|
|
104
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 2. Total affected: 2."]
|
|
105
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
106
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
256
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Fetch all chunks for a specific file path'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
257
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
258
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
259
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
107
260
|
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
108
261
|
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
262
|
+
|
|
263
|
+
// CIL[DOC-STABILITY stability="internal"]
|
|
264
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
265
|
+
// CIL[DOC-CONTEXT module="unknown" layer="unknown" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:rank:function" type="function" identity="rank" parent="~/.framework/functions/cil-callmap.ts"]
|
|
269
|
+
// CIL[DOC-MACRO purpose="Return numeric rank for a CIL file status"]
|
|
270
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Convert a status string to its position in the pipeline"]
|
|
271
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
272
|
+
// CIL[DOC-CONTRACT inputs="status string or undefined" outputs="number rank" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
273
|
+
// CIL[DOC-MICRO logic_summary="Looks up the status in STATUS_RANK and returns 0 for unknown or missing values" notable_decisions="[]"]
|
|
274
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
275
|
+
// CIL[DOC-STABILITY stability="stable"]
|
|
276
|
+
|
|
109
277
|
function rank(status: string | undefined): number {
|
|
110
278
|
return status ? STATUS_RANK[status] || 0 : 0
|
|
111
279
|
}
|
|
280
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Return numeric rank for a CIL file status'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
281
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
282
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
283
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
284
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
285
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
286
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:rank:function"]
|
|
112
287
|
|
|
113
288
|
|
|
114
289
|
|
|
@@ -118,26 +293,27 @@ function rank(status: string | undefined): number {
|
|
|
118
293
|
|
|
119
294
|
|
|
120
295
|
|
|
121
|
-
// CIL[
|
|
122
|
-
// CIL[
|
|
123
|
-
// CIL[DOC-
|
|
124
|
-
// CIL[DOC-
|
|
125
|
-
// CIL[DOC-
|
|
126
|
-
// CIL[DOC-
|
|
127
|
-
// CIL[DOC-
|
|
128
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.95" flags="none"]
|
|
296
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:ExtractedImport:interface" type="interface" identity="ExtractedImport" parent="~/.framework/functions/cil-callmap.ts"]
|
|
297
|
+
// CIL[DOC-MACRO purpose="Define the shape of an extracted ES import"]
|
|
298
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Declare the fields of a parsed import statement"]
|
|
299
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="interface" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
300
|
+
// CIL[DOC-CONTRACT inputs="none" outputs="TypeScript interface" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
301
|
+
// CIL[DOC-MICRO logic_summary="Declares from_path, symbols and is_default fields" notable_decisions="[]"]
|
|
302
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
129
303
|
// CIL[DOC-STABILITY stability="stable"]
|
|
130
|
-
|
|
131
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 0. Total affected: 0."]
|
|
132
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
133
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
134
|
-
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
135
|
-
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
304
|
+
|
|
136
305
|
interface ExtractedImport {
|
|
137
306
|
from_path: string
|
|
138
307
|
symbols: string[]
|
|
139
308
|
is_default: boolean
|
|
140
309
|
}
|
|
310
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Define the shape of an extracted ES import'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
311
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
312
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
313
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
314
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
315
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
316
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:ExtractedImport:interface"]
|
|
141
317
|
|
|
142
318
|
|
|
143
319
|
|
|
@@ -145,25 +321,26 @@ interface ExtractedImport {
|
|
|
145
321
|
|
|
146
322
|
|
|
147
323
|
|
|
148
|
-
// CIL[
|
|
149
|
-
// CIL[
|
|
150
|
-
// CIL[DOC-
|
|
151
|
-
// CIL[DOC-
|
|
152
|
-
// CIL[DOC-
|
|
153
|
-
// CIL[DOC-
|
|
154
|
-
// CIL[DOC-
|
|
155
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.95" flags="none"]
|
|
324
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:ExtractedCall:interface" type="interface" identity="ExtractedCall" parent="~/.framework/functions/cil-callmap.ts"]
|
|
325
|
+
// CIL[DOC-MACRO purpose="Define the shape of an extracted function call"]
|
|
326
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Declare the fields of a parsed function call"]
|
|
327
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="interface" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
328
|
+
// CIL[DOC-CONTRACT inputs="none" outputs="TypeScript interface" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
329
|
+
// CIL[DOC-MICRO logic_summary="Declares callee_name and is_await fields" notable_decisions="[]"]
|
|
330
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
156
331
|
// CIL[DOC-STABILITY stability="stable"]
|
|
157
|
-
|
|
158
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 0. Total affected: 0."]
|
|
159
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
160
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
161
|
-
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
162
|
-
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
332
|
+
|
|
163
333
|
interface ExtractedCall {
|
|
164
334
|
callee_name: string
|
|
165
335
|
is_await: boolean
|
|
166
336
|
}
|
|
337
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Define the shape of an extracted function call'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
338
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
339
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
340
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
341
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
342
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
343
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:ExtractedCall:interface"]
|
|
167
344
|
|
|
168
345
|
|
|
169
346
|
|
|
@@ -174,21 +351,15 @@ interface ExtractedCall {
|
|
|
174
351
|
|
|
175
352
|
|
|
176
353
|
|
|
177
|
-
// CIL[
|
|
178
|
-
// CIL[
|
|
179
|
-
// CIL[DOC-
|
|
180
|
-
// CIL[DOC-
|
|
181
|
-
// CIL[DOC-
|
|
182
|
-
// CIL[DOC-
|
|
183
|
-
// CIL[DOC-
|
|
184
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.95" flags="none"]
|
|
354
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:extractImports:function" type="function" identity="extractImports" parent="~/.framework/functions/cil-callmap.ts"]
|
|
355
|
+
// CIL[DOC-MACRO purpose="Parse ES import statements from source text"]
|
|
356
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Return a list of extracted imports with named, default and star aliases"]
|
|
357
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
358
|
+
// CIL[DOC-CONTRACT inputs="source string" outputs="ExtractedImport[]" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
359
|
+
// CIL[DOC-MICRO logic_summary="Regex scans import declarations and resolves specifier blocks into symbol lists" notable_decisions="[]"]
|
|
360
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
185
361
|
// CIL[DOC-STABILITY stability="stable"]
|
|
186
|
-
|
|
187
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 0. Total affected: 0."]
|
|
188
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
189
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
190
|
-
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
191
|
-
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
362
|
+
|
|
192
363
|
export function extractImports(source: string): ExtractedImport[] {
|
|
193
364
|
const results: ExtractedImport[] = []
|
|
194
365
|
|
|
@@ -227,29 +398,30 @@ export function extractImports(source: string): ExtractedImport[] {
|
|
|
227
398
|
}
|
|
228
399
|
return results
|
|
229
400
|
}
|
|
401
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:extractImports:function"]
|
|
230
402
|
|
|
231
403
|
|
|
404
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Parse ES import statements from source text'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
405
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
406
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
407
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
408
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
409
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
232
410
|
|
|
233
411
|
|
|
234
412
|
|
|
235
413
|
|
|
236
414
|
|
|
237
415
|
|
|
238
|
-
// CIL[
|
|
239
|
-
// CIL[
|
|
240
|
-
// CIL[DOC-
|
|
241
|
-
// CIL[DOC-
|
|
242
|
-
// CIL[DOC-
|
|
243
|
-
// CIL[DOC-
|
|
244
|
-
// CIL[DOC-
|
|
245
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.95" flags="none"]
|
|
416
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:extractCalls:function" type="function" identity="extractCalls" parent="~/.framework/functions/cil-callmap.ts"]
|
|
417
|
+
// CIL[DOC-MACRO purpose="Parse function calls and symbol references from source text"]
|
|
418
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Return a deduplicated list of extracted calls, filtering keywords and short names"]
|
|
419
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
420
|
+
// CIL[DOC-CONTRACT inputs="source string" outputs="ExtractedCall[]" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
421
|
+
// CIL[DOC-MICRO logic_summary="Regex scans for function call tokens, filters reserved words and context names, and deduplicates" notable_decisions="[]"]
|
|
422
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
246
423
|
// CIL[DOC-STABILITY stability="stable"]
|
|
247
|
-
|
|
248
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 0. Total affected: 0."]
|
|
249
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
250
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
251
|
-
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
252
|
-
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
424
|
+
|
|
253
425
|
export function extractCalls(source: string): ExtractedCall[] {
|
|
254
426
|
const seen = new Set<string>()
|
|
255
427
|
const results: ExtractedCall[] = []
|
|
@@ -274,7 +446,17 @@ export function extractCalls(source: string): ExtractedCall[] {
|
|
|
274
446
|
}
|
|
275
447
|
return results
|
|
276
448
|
}
|
|
449
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Parse function calls and symbol references from source text'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
450
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
451
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
452
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
453
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
454
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
455
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:extractCalls:function"]
|
|
277
456
|
|
|
457
|
+
// CIL[DOC-STABILITY stability="internal"]
|
|
458
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
459
|
+
// CIL[DOC-CONTEXT module="unknown" layer="unknown" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
278
460
|
|
|
279
461
|
|
|
280
462
|
|
|
@@ -282,53 +464,47 @@ export function extractCalls(source: string): ExtractedCall[] {
|
|
|
282
464
|
|
|
283
465
|
|
|
284
466
|
|
|
285
|
-
// CIL[
|
|
286
|
-
// CIL[
|
|
287
|
-
// CIL[DOC-
|
|
288
|
-
// CIL[DOC-
|
|
289
|
-
// CIL[DOC-
|
|
290
|
-
// CIL[DOC-
|
|
291
|
-
// CIL[DOC-
|
|
292
|
-
// CIL[DOC-
|
|
293
|
-
// CIL[DOC-STABILITY stability="experimental"]
|
|
294
|
-
function escapeRegex(s: string): string {
|
|
295
|
-
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
296
|
-
}
|
|
467
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:extractSymbolReferences:function" type="function" identity="extractSymbolReferences" parent="~/.framework/functions/cil-callmap.ts"]
|
|
468
|
+
// CIL[DOC-MACRO purpose="Find token references to a candidate set in source text"]
|
|
469
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Return the set of candidate symbol names found as bare references"]
|
|
470
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
471
|
+
// CIL[DOC-CONTRACT inputs="source, candidateSet, ownName" outputs="string[] of matching symbols" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
472
|
+
// CIL[DOC-MICRO logic_summary="Tokenises the source, skips reserved and own name, and returns matched candidate tokens" notable_decisions="[]"]
|
|
473
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
474
|
+
// CIL[DOC-STABILITY stability="stable"]
|
|
297
475
|
|
|
298
|
-
function extractSymbolReferences(source: string,
|
|
476
|
+
function extractSymbolReferences(source: string, candidateSet: Set<string>, ownName?: string): string[] {
|
|
299
477
|
const reserved = new Set(['if','for','while','switch','catch','return','new','typeof','instanceof','function','const','let','var','class','interface','type','enum','export','import','from','await','async','true','false','null','undefined','this','super','extends','implements','as','in','of','with','yield'])
|
|
300
|
-
const
|
|
301
|
-
.filter(n => n && n !== ownName && n.length >= 2 && !reserved.has(n))
|
|
302
|
-
.sort((a, b) => b.length - a.length)
|
|
303
|
-
if (candidates.length === 0) return []
|
|
304
|
-
|
|
305
|
-
const pattern = new RegExp(`(?:^|[^A-Za-z0-9_$])(${candidates.map(escapeRegex).join('|')})(?=[^A-Za-z0-9_$]|$)`, 'g')
|
|
478
|
+
const tokenRe = /[A-Za-z_$][A-Za-z0-9_$]*/g
|
|
306
479
|
const seen = new Set<string>()
|
|
307
480
|
let m: RegExpExecArray | null
|
|
308
|
-
while ((m =
|
|
309
|
-
|
|
481
|
+
while ((m = tokenRe.exec(source)) !== null) {
|
|
482
|
+
const name = m[0].toLowerCase()
|
|
483
|
+
if (name === ownName || name.length < 2 || reserved.has(name) || !candidateSet.has(name)) continue
|
|
484
|
+
seen.add(name)
|
|
310
485
|
}
|
|
311
486
|
return [...seen]
|
|
312
487
|
}
|
|
488
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Find token references to a candidate set in source text'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
489
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
490
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
491
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
492
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
493
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
494
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:extractSymbolReferences:function"]
|
|
313
495
|
|
|
314
496
|
|
|
315
497
|
|
|
316
498
|
|
|
317
|
-
// CIL[
|
|
318
|
-
// CIL[
|
|
319
|
-
// CIL[DOC-
|
|
320
|
-
// CIL[DOC-
|
|
321
|
-
// CIL[DOC-
|
|
322
|
-
// CIL[DOC-
|
|
323
|
-
// CIL[DOC-
|
|
324
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.95" flags="none"]
|
|
499
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:extractExports:function" type="function" identity="extractExports" parent="~/.framework/functions/cil-callmap.ts"]
|
|
500
|
+
// CIL[DOC-MACRO purpose="Parse exported declarations from source text"]
|
|
501
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Return the list of exported names including named re-exports"]
|
|
502
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
503
|
+
// CIL[DOC-CONTRACT inputs="source string" outputs="string[] of exported identifiers" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
504
|
+
// CIL[DOC-MICRO logic_summary="Regex matches export declarations and export blocks, resolving aliases" notable_decisions="[]"]
|
|
505
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
325
506
|
// CIL[DOC-STABILITY stability="stable"]
|
|
326
|
-
|
|
327
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 0. Total affected: 0."]
|
|
328
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
329
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
330
|
-
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
331
|
-
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
507
|
+
|
|
332
508
|
export function extractExports(source: string): string[] {
|
|
333
509
|
const exports: string[] = []
|
|
334
510
|
|
|
@@ -345,6 +521,13 @@ export function extractExports(source: string): string[] {
|
|
|
345
521
|
}
|
|
346
522
|
return [...new Set(exports)]
|
|
347
523
|
}
|
|
524
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Parse exported declarations from source text'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
525
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
526
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
527
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
528
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
529
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
530
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:extractExports:function"]
|
|
348
531
|
|
|
349
532
|
|
|
350
533
|
|
|
@@ -354,21 +537,15 @@ export function extractExports(source: string): string[] {
|
|
|
354
537
|
|
|
355
538
|
|
|
356
539
|
|
|
357
|
-
// CIL[
|
|
358
|
-
// CIL[
|
|
359
|
-
// CIL[DOC-
|
|
360
|
-
// CIL[DOC-
|
|
361
|
-
// CIL[DOC-
|
|
362
|
-
// CIL[DOC-
|
|
363
|
-
// CIL[DOC-
|
|
364
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.95" flags="none"]
|
|
540
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:resolveImportPath:function" type="function" identity="resolveImportPath" parent="~/.framework/functions/cil-callmap.ts"]
|
|
541
|
+
// CIL[DOC-MACRO purpose="Resolve a relative import specifier to a project file path"]
|
|
542
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Convert a local import specifier to a normalised project-relative base path"]
|
|
543
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
544
|
+
// CIL[DOC-CONTRACT inputs="fromFilePath, importSpecifier" outputs="string | null" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
545
|
+
// CIL[DOC-MICRO logic_summary="Normalises '.' and '..' segments relative to the importing file and returns the base path" notable_decisions="[]"]
|
|
546
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
365
547
|
// CIL[DOC-STABILITY stability="stable"]
|
|
366
|
-
|
|
367
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 0. Total affected: 0."]
|
|
368
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
369
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
370
|
-
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
371
|
-
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
548
|
+
|
|
372
549
|
function resolveImportPath(fromFilePath: string, importSpecifier: string): string | null {
|
|
373
550
|
|
|
374
551
|
if (!importSpecifier.startsWith('.')) return null
|
|
@@ -386,26 +563,27 @@ function resolveImportPath(fromFilePath: string, importSpecifier: string): strin
|
|
|
386
563
|
|
|
387
564
|
return base
|
|
388
565
|
}
|
|
566
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Resolve a relative import specifier to a project file path'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
567
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
568
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
569
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
570
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
571
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
572
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:resolveImportPath:function"]
|
|
389
573
|
|
|
390
574
|
|
|
391
575
|
|
|
392
576
|
|
|
393
577
|
|
|
394
|
-
// CIL[
|
|
395
|
-
// CIL[
|
|
396
|
-
// CIL[DOC-
|
|
397
|
-
// CIL[DOC-
|
|
398
|
-
// CIL[DOC-
|
|
399
|
-
// CIL[DOC-
|
|
400
|
-
// CIL[DOC-
|
|
401
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.95" flags="none"]
|
|
578
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:upsertLink:function" type="function" identity="upsertLink" parent="~/.framework/functions/cil-callmap.ts"]
|
|
579
|
+
// CIL[DOC-MACRO purpose="Create a single link if no matching link already exists"]
|
|
580
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Insert a link record between a source and target item for a given link type"]
|
|
581
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
582
|
+
// CIL[DOC-CONTRACT inputs="ctx, sourceItem, targetItem, linkTypeId, metadata" outputs="boolean indicating created" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
583
|
+
// CIL[DOC-MICRO logic_summary="Checks for an existing link and calls adminCreate when none is found" notable_decisions="[]"]
|
|
584
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
402
585
|
// CIL[DOC-STABILITY stability="stable"]
|
|
403
|
-
|
|
404
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 0. Total affected: 0."]
|
|
405
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
406
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
407
|
-
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
408
|
-
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
586
|
+
|
|
409
587
|
export async function upsertLink(
|
|
410
588
|
ctx: any,
|
|
411
589
|
sourceItem: any,
|
|
@@ -413,20 +591,22 @@ export async function upsertLink(
|
|
|
413
591
|
linkTypeId: string,
|
|
414
592
|
metadata: Record<string, any> = {}
|
|
415
593
|
): Promise<boolean> {
|
|
416
|
-
|
|
594
|
+
|
|
595
|
+
const sourceType = sourceItem.data?.kb_type
|
|
596
|
+
const targetType = targetItem.data?.kb_type
|
|
597
|
+
if (!sourceType || !targetType) return false
|
|
598
|
+
|
|
417
599
|
const { data: existing } = await adminDb
|
|
418
600
|
.from('links')
|
|
419
601
|
.select('id')
|
|
602
|
+
.eq('source_type', sourceType)
|
|
420
603
|
.eq('source_id', sourceItem.id)
|
|
604
|
+
.eq('target_type', targetType)
|
|
421
605
|
.eq('target_id', targetItem.id)
|
|
422
606
|
.eq('link_type_id', linkTypeId)
|
|
423
607
|
.maybeSingle()
|
|
424
608
|
|
|
425
|
-
if (existing) return false
|
|
426
|
-
|
|
427
|
-
const sourceType = sourceItem.data?.kb_type
|
|
428
|
-
const targetType = targetItem.data?.kb_type
|
|
429
|
-
if (!sourceType || !targetType) return false
|
|
609
|
+
if (existing) return false
|
|
430
610
|
|
|
431
611
|
try {
|
|
432
612
|
await adminCreate(ctx, {
|
|
@@ -445,32 +625,36 @@ export async function upsertLink(
|
|
|
445
625
|
return false
|
|
446
626
|
}
|
|
447
627
|
}
|
|
628
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Create a single link if no matching link already exists'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
629
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
630
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
631
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
632
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
633
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
634
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:upsertLink:function"]
|
|
448
635
|
|
|
449
636
|
|
|
450
637
|
|
|
451
638
|
|
|
452
639
|
|
|
453
|
-
// CIL[
|
|
454
|
-
// CIL[
|
|
640
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:clearProjectLinks:function" type="function" identity="clearProjectLinks" parent="~/.framework/functions/cil-callmap.ts"]
|
|
641
|
+
// CIL[DOC-MACRO purpose="Delete all cil links for a project in batches"]
|
|
642
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Remove import, call and export links tied to a project's file and chunk items"]
|
|
643
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
644
|
+
// CIL[DOC-CONTRACT inputs="projectId, linkTypeIds" outputs="number of deleted links" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
645
|
+
// CIL[DOC-MICRO logic_summary="Collects file and chunk ids, then deletes links in UUID_IN_LIMIT sized IN batches" notable_decisions="[]"]
|
|
646
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
647
|
+
// CIL[DOC-STABILITY stability="stable"]
|
|
648
|
+
|
|
455
649
|
async function clearProjectLinks(projectId: string, linkTypeIds: string[]): Promise<number> {
|
|
456
|
-
const [
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
.select('id')
|
|
460
|
-
.filter('data->>project_id', 'eq', projectId)
|
|
461
|
-
.filter('data->>kb_type', 'eq', 'cil_file')
|
|
462
|
-
.eq('is_active', true),
|
|
463
|
-
adminDb
|
|
464
|
-
.from('items')
|
|
465
|
-
.select('id')
|
|
466
|
-
.filter('data->>project_id', 'eq', projectId)
|
|
467
|
-
.filter('data->>kb_type', 'eq', 'cil_chunk')
|
|
468
|
-
.eq('is_active', true),
|
|
650
|
+
const [fileItems, chunkItems] = await Promise.all([
|
|
651
|
+
fetchAllProjectRecords(projectId, 'cil_file'),
|
|
652
|
+
fetchAllProjectRecords(projectId, 'cil_chunk'),
|
|
469
653
|
])
|
|
470
654
|
|
|
471
655
|
const ids = [
|
|
472
|
-
...
|
|
473
|
-
...
|
|
656
|
+
...fileItems.map((f: any) => f.id),
|
|
657
|
+
...chunkItems.map((c: any) => c.id),
|
|
474
658
|
]
|
|
475
659
|
if (!ids.length) return 0
|
|
476
660
|
|
|
@@ -488,27 +672,28 @@ async function clearProjectLinks(projectId: string, linkTypeIds: string[]): Prom
|
|
|
488
672
|
}
|
|
489
673
|
return deleted
|
|
490
674
|
}
|
|
491
|
-
// CIL[
|
|
492
|
-
// CIL[
|
|
493
|
-
// CIL[DOC-
|
|
494
|
-
// CIL[DOC-
|
|
495
|
-
// CIL[DOC-CONTEXT module="cortex.functions.custom_cil-callmap" layer="function" related_files="[]"]
|
|
496
|
-
// CIL[DOC-CONTRACT inputs="none" outputs="return value from function execution" errors="throws on invalid input or runtime failure" side_effects="none"]
|
|
497
|
-
// CIL[DOC-MICRO logic_summary="Provides mapfile with mapFile( inputs, handling internal flow and returning a result" notable_decisions="[]"]
|
|
498
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.95" flags="none"]
|
|
499
|
-
// CIL[DOC-STABILITY stability="stable"]
|
|
500
|
-
// CIL[DOC-VECTOR type="context" content="Layer: function. Direct callers: 0. Direct calls: 0. Related files: none."]
|
|
501
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 0. Total affected: 0."]
|
|
502
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
503
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
675
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Delete all cil links for a project in batches'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
676
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
677
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
678
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
504
679
|
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
505
680
|
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
681
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:clearProjectLinks:function"]
|
|
682
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:mapFile:function" type="function" identity="mapFile" parent="~/.framework/functions/cil-callmap.ts"]
|
|
683
|
+
// CIL[DOC-MACRO purpose="Create import, call and export links for a single file"]
|
|
684
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Map a file's chunks and full content to related files and chunks"]
|
|
685
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
686
|
+
// CIL[DOC-CONTRACT inputs="ctx, fileItem, projectId, allChunksByFile, chunksByNameArg, fileItemsByPath, importsLinkTypeId, callsLinkTypeId, exportsLinkTypeId" outputs="{imports_created, calls_created, exports_created}" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
687
|
+
// CIL[DOC-MICRO logic_summary="Extracts calls and symbols per chunk, imports per file, and exports back to the file item" notable_decisions="[]"]
|
|
688
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
689
|
+
// CIL[DOC-STABILITY stability="stable"]
|
|
690
|
+
|
|
506
691
|
export async function mapFile(
|
|
507
692
|
ctx: any,
|
|
508
693
|
fileItem: any,
|
|
509
694
|
projectId: string,
|
|
510
695
|
allChunksByFile: Map<string, any[]>,
|
|
511
|
-
|
|
696
|
+
chunksByNameArg: Map<string, any>,
|
|
512
697
|
fileItemsByPath: Map<string, any>,
|
|
513
698
|
importsLinkTypeId: string,
|
|
514
699
|
callsLinkTypeId: string,
|
|
@@ -517,10 +702,14 @@ export async function mapFile(
|
|
|
517
702
|
let importsCreated = 0, callsCreated = 0, exportsCreated = 0
|
|
518
703
|
|
|
519
704
|
const filePath: string = fileItem.data?.file_path || fileItem.title
|
|
520
|
-
const chunksInFile = allChunksByFile.get(
|
|
705
|
+
const chunksInFile = allChunksByFile.get(filePath) || []
|
|
521
706
|
|
|
522
|
-
|
|
707
|
+
const chunksByName = new Map<string, any>()
|
|
708
|
+
for (const [name, chunk] of chunksByNameArg.entries()) {
|
|
709
|
+
if (name) chunksByName.set(name.toLowerCase(), chunk)
|
|
710
|
+
}
|
|
523
711
|
const allChunkNames = Array.from(chunksByName.keys())
|
|
712
|
+
const candidateSet = new Set(allChunkNames)
|
|
524
713
|
|
|
525
714
|
for (const chunk of chunksInFile) {
|
|
526
715
|
const codeContent: string = chunk.data?.code_content || ''
|
|
@@ -528,27 +717,41 @@ export async function mapFile(
|
|
|
528
717
|
|
|
529
718
|
|
|
530
719
|
const calls = extractCalls(codeContent)
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
callee_name: call.callee_name,
|
|
536
|
-
is_await: call.is_await,
|
|
720
|
+
const callPromises = calls
|
|
721
|
+
.filter((call) => {
|
|
722
|
+
const targetChunk = chunksByName.get(call.callee_name.toLowerCase())
|
|
723
|
+
return targetChunk && targetChunk.id !== chunk.id
|
|
537
724
|
})
|
|
538
|
-
|
|
539
|
-
|
|
725
|
+
.map((call) => {
|
|
726
|
+
const targetChunk = chunksByName.get(call.callee_name.toLowerCase())!
|
|
727
|
+
const callMetadata: Record<string, any> = {
|
|
728
|
+
callee_name: call.callee_name,
|
|
729
|
+
is_await: call.is_await,
|
|
730
|
+
}
|
|
731
|
+
if (chunk.data?.version_id) callMetadata.version_id = chunk.data.version_id
|
|
732
|
+
return upsertLink(ctx, chunk, targetChunk, callsLinkTypeId, callMetadata)
|
|
733
|
+
})
|
|
734
|
+
const callResults = await Promise.all(callPromises)
|
|
735
|
+
callsCreated += callResults.filter(Boolean).length
|
|
540
736
|
|
|
541
737
|
|
|
542
|
-
const symbolRefs = extractSymbolReferences(codeContent,
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
callee_name: refName,
|
|
548
|
-
is_symbol_reference: true,
|
|
738
|
+
const symbolRefs = extractSymbolReferences(codeContent, candidateSet, (chunk.data?.chunk_name || '').toLowerCase())
|
|
739
|
+
const refPromises = symbolRefs
|
|
740
|
+
.filter((refName) => {
|
|
741
|
+
const targetChunk = chunksByName.get(refName.toLowerCase())
|
|
742
|
+
return targetChunk && targetChunk.id !== chunk.id
|
|
549
743
|
})
|
|
550
|
-
|
|
551
|
-
|
|
744
|
+
.map((refName) => {
|
|
745
|
+
const targetChunk = chunksByName.get(refName.toLowerCase())!
|
|
746
|
+
const refMetadata: Record<string, any> = {
|
|
747
|
+
callee_name: refName,
|
|
748
|
+
is_symbol_reference: true,
|
|
749
|
+
}
|
|
750
|
+
if (chunk.data?.version_id) refMetadata.version_id = chunk.data.version_id
|
|
751
|
+
return upsertLink(ctx, chunk, targetChunk, callsLinkTypeId, refMetadata)
|
|
752
|
+
})
|
|
753
|
+
const refResults = await Promise.all(refPromises)
|
|
754
|
+
callsCreated += refResults.filter(Boolean).length
|
|
552
755
|
}
|
|
553
756
|
|
|
554
757
|
|
|
@@ -556,62 +759,71 @@ export async function mapFile(
|
|
|
556
759
|
const fullFileContent = chunksInFile.map((c: any) => c.data?.code_content || '').join('\n')
|
|
557
760
|
const imports = extractImports(fullFileContent)
|
|
558
761
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
762
|
+
const importPromises = imports
|
|
763
|
+
.map((imp) => {
|
|
764
|
+
const resolvedBase = resolveImportPath(filePath, imp.from_path)
|
|
765
|
+
if (!resolvedBase) return null
|
|
562
766
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
767
|
+
|
|
768
|
+
const targetFile =
|
|
769
|
+
fileItemsByPath.get(resolvedBase) ||
|
|
770
|
+
fileItemsByPath.get(resolvedBase + '.ts') ||
|
|
771
|
+
fileItemsByPath.get(resolvedBase + '.tsx') ||
|
|
772
|
+
fileItemsByPath.get(resolvedBase + '/index.ts') ||
|
|
773
|
+
fileItemsByPath.get(resolvedBase + '/index.tsx')
|
|
774
|
+
|
|
775
|
+
if (!targetFile || targetFile.id === fileItem.id) return null
|
|
776
|
+
|
|
777
|
+
const importMetadata: Record<string, any> = {
|
|
778
|
+
symbols: imp.symbols,
|
|
779
|
+
is_default: imp.is_default,
|
|
780
|
+
specifier: imp.from_path,
|
|
781
|
+
}
|
|
782
|
+
if (fileItem.data?.version_id) importMetadata.version_id = fileItem.data.version_id
|
|
783
|
+
return upsertLink(ctx, fileItem, targetFile, importsLinkTypeId, importMetadata)
|
|
577
784
|
})
|
|
578
|
-
|
|
579
|
-
|
|
785
|
+
.filter((p): p is Promise<boolean> => p !== null)
|
|
786
|
+
const importResults = await Promise.all(importPromises)
|
|
787
|
+
importsCreated += importResults.filter(Boolean).length
|
|
580
788
|
|
|
581
789
|
|
|
582
790
|
const exportedNames = extractExports(fullFileContent)
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
791
|
+
const exportPromises = exportedNames
|
|
792
|
+
.map((exportedName) => {
|
|
793
|
+
const chunk = chunksByName.get(exportedName.toLowerCase())
|
|
794
|
+
if (!chunk) return null
|
|
795
|
+
return upsertLink(ctx, chunk, fileItem, exportsLinkTypeId, {
|
|
796
|
+
exported_name: exportedName,
|
|
797
|
+
})
|
|
588
798
|
})
|
|
589
|
-
|
|
590
|
-
|
|
799
|
+
.filter((p): p is Promise<boolean> => p !== null)
|
|
800
|
+
const exportResults = await Promise.all(exportPromises)
|
|
801
|
+
exportsCreated += exportResults.filter(Boolean).length
|
|
591
802
|
|
|
592
803
|
return { imports_created: importsCreated, calls_created: callsCreated, exports_created: exportsCreated }
|
|
593
804
|
}
|
|
805
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:mapFile:function"]
|
|
594
806
|
|
|
595
807
|
|
|
596
808
|
|
|
809
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Create import, call and export links for a single file'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
810
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
811
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
812
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
813
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
814
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
597
815
|
|
|
598
816
|
|
|
599
817
|
|
|
600
|
-
// CIL[
|
|
601
|
-
// CIL[
|
|
602
|
-
// CIL[DOC-
|
|
603
|
-
// CIL[DOC-
|
|
604
|
-
// CIL[DOC-
|
|
605
|
-
// CIL[DOC-
|
|
606
|
-
// CIL[DOC-
|
|
607
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.95" flags="none"]
|
|
818
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:markFilePass4bComplete:function" type="function" identity="markFilePass4bComplete" parent="~/.framework/functions/cil-callmap.ts"]
|
|
819
|
+
// CIL[DOC-MACRO purpose="Advance a file to the embedded-mapped pipeline status"]
|
|
820
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Update the file item and project tree status after mapping completes"]
|
|
821
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
822
|
+
// CIL[DOC-CONTRACT inputs="ctx, fileItem, tree, secondPass, projectItem" outputs="void" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
823
|
+
// CIL[DOC-MICRO logic_summary="Skips files before 6-enriched, updates file status, advances project file_statuses and mutates projectItem" notable_decisions="[]"]
|
|
824
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
608
825
|
// CIL[DOC-STABILITY stability="stable"]
|
|
609
|
-
|
|
610
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 0. Total affected: 0."]
|
|
611
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
612
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
613
|
-
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
614
|
-
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
826
|
+
|
|
615
827
|
async function markFilePass4bComplete(
|
|
616
828
|
ctx: any,
|
|
617
829
|
fileItem: any,
|
|
@@ -619,12 +831,18 @@ async function markFilePass4bComplete(
|
|
|
619
831
|
secondPass = false,
|
|
620
832
|
projectItem?: any
|
|
621
833
|
): Promise<void> {
|
|
622
|
-
const cil_file_status = secondPass ? '
|
|
623
|
-
const pipeline_status = secondPass ? '
|
|
834
|
+
const cil_file_status: FileStatus = secondPass ? '7-embedded-mapped' : '7-embedded-mapped'
|
|
835
|
+
const pipeline_status: FileStatus = secondPass ? '7-embedded-mapped' : '7-embedded-mapped'
|
|
624
836
|
const currentFileStatus = getFileStatus(fileItem)
|
|
625
837
|
const filePath: string = fileItem.data?.file_path
|
|
626
838
|
|
|
627
839
|
|
|
840
|
+
if (rank(currentFileStatus) < rank('6-enriched')) {
|
|
841
|
+
console.error(`markFilePass4bComplete skipped ${filePath}: current status ${currentFileStatus} is before 6-enriched`)
|
|
842
|
+
return
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
|
|
628
846
|
if (rank(currentFileStatus) < rank(cil_file_status)) {
|
|
629
847
|
const updateCtx = { ...ctx, query: { ...(ctx.query || {}), entity: 'items', id: fileItem.id } }
|
|
630
848
|
await adminUpdate(updateCtx, {
|
|
@@ -670,68 +888,70 @@ async function markFilePass4bComplete(
|
|
|
670
888
|
projectItem.data.file_statuses = fileStatuses
|
|
671
889
|
}
|
|
672
890
|
}
|
|
891
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Advance a file to the embedded-mapped pipeline status'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
892
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
893
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
894
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
895
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
896
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
897
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:markFilePass4bComplete:function"]
|
|
673
898
|
|
|
674
899
|
|
|
675
900
|
|
|
676
901
|
|
|
677
902
|
|
|
678
903
|
|
|
679
|
-
// CIL[
|
|
680
|
-
// CIL[
|
|
681
|
-
// CIL[DOC-
|
|
682
|
-
// CIL[DOC-
|
|
683
|
-
// CIL[DOC-
|
|
684
|
-
// CIL[DOC-
|
|
685
|
-
// CIL[DOC-
|
|
686
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.95" flags="none"]
|
|
904
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:isTestFile:function" type="function" identity="isTestFile" parent="~/.framework/functions/cil-callmap.ts"]
|
|
905
|
+
// CIL[DOC-MACRO purpose="Detect whether a file path is a test file"]
|
|
906
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Return true for paths that look like unit, spec or E2E tests"]
|
|
907
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
908
|
+
// CIL[DOC-CONTRACT inputs="filePath" outputs="boolean" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
909
|
+
// CIL[DOC-MICRO logic_summary="Tests the path against common test, __tests__ and tests directory patterns" notable_decisions="[]"]
|
|
910
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
687
911
|
// CIL[DOC-STABILITY stability="stable"]
|
|
688
|
-
|
|
689
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 0. Total affected: 0."]
|
|
690
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
691
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
692
|
-
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
693
|
-
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
912
|
+
|
|
694
913
|
function isTestFile(filePath: string): boolean {
|
|
695
914
|
return /\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filePath) ||
|
|
696
915
|
/\/__tests__\//.test(filePath) ||
|
|
697
916
|
/\/tests?\//.test(filePath)
|
|
698
917
|
}
|
|
918
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Detect whether a file path is a test file'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
919
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
920
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
921
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
922
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
923
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
924
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:isTestFile:function"]
|
|
699
925
|
|
|
700
926
|
|
|
701
927
|
|
|
702
928
|
|
|
703
|
-
// CIL[
|
|
704
|
-
// CIL[
|
|
705
|
-
// CIL[DOC-
|
|
706
|
-
// CIL[DOC-
|
|
707
|
-
// CIL[DOC-
|
|
708
|
-
// CIL[DOC-
|
|
709
|
-
// CIL[DOC-
|
|
710
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.95" flags="none"]
|
|
929
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:mapTests:function" type="function" identity="mapTests" parent="~/.framework/functions/cil-callmap.ts"]
|
|
930
|
+
// CIL[DOC-MACRO purpose="Create tested_by links between chunks and test files"]
|
|
931
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Scan test files, match chunk names and upsert tested_by links and test path fields"]
|
|
932
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="function" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
933
|
+
// CIL[DOC-CONTRACT inputs="ctx, projectId, repoPath, testedByLinkTypeId, chunksByNameArg" outputs="{test_files_scanned, tested_by_links_created, chunks_updated, errors}" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
934
|
+
// CIL[DOC-MICRO logic_summary="Reads test sources, matches imported names, describe/it strings and calls, then links and updates chunk test paths" notable_decisions="[]"]
|
|
935
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
711
936
|
// CIL[DOC-STABILITY stability="stable"]
|
|
712
|
-
|
|
713
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 0. Total affected: 0."]
|
|
714
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
715
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
716
|
-
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
717
|
-
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
937
|
+
|
|
718
938
|
async function mapTests(
|
|
719
939
|
ctx: any,
|
|
720
940
|
projectId: string,
|
|
721
941
|
repoPath: string,
|
|
722
942
|
testedByLinkTypeId: string,
|
|
723
|
-
|
|
943
|
+
chunksByNameArg: Map<string, any>
|
|
724
944
|
): Promise<{ test_files_scanned: number; tested_by_links_created: number; chunks_updated: number; errors: string[] }> {
|
|
945
|
+
const chunksByName = new Map<string, any>()
|
|
946
|
+
for (const [name, chunk] of chunksByNameArg.entries()) {
|
|
947
|
+
if (name) chunksByName.set(name.toLowerCase(), chunk)
|
|
948
|
+
}
|
|
725
949
|
const errors: string[] = []
|
|
726
950
|
let testFilesScanned = 0, linksCreated = 0, chunksUpdated = 0
|
|
727
951
|
|
|
728
|
-
const
|
|
729
|
-
.from('items').select('id, title, data')
|
|
730
|
-
.filter('data->>project_id', 'eq', projectId)
|
|
731
|
-
.filter('data->>kb_type', 'eq', 'cil_file')
|
|
732
|
-
.eq('is_active', true)
|
|
952
|
+
const allFiles = await fetchAllProjectRecords(projectId, 'cil_file')
|
|
733
953
|
|
|
734
|
-
const testFiles =
|
|
954
|
+
const testFiles = allFiles.filter((f: any) => isTestFile(f.data?.file_path || f.title))
|
|
735
955
|
|
|
736
956
|
const matchesByFile = new Map<string, Set<string>>()
|
|
737
957
|
const allMatchedNames = new Set<string>()
|
|
@@ -752,7 +972,7 @@ async function mapTests(
|
|
|
752
972
|
while ((m = importRe.exec(source)) !== null) {
|
|
753
973
|
const names = m[1].split(',').map(s => s.trim().split(/\s+as\s+/).shift()!.trim()).filter(Boolean)
|
|
754
974
|
for (const n of names) {
|
|
755
|
-
if (chunksByName.has(n)) matchedChunkNames.add(n)
|
|
975
|
+
if (chunksByName.has(n.toLowerCase())) matchedChunkNames.add(n.toLowerCase())
|
|
756
976
|
}
|
|
757
977
|
}
|
|
758
978
|
|
|
@@ -760,13 +980,13 @@ async function mapTests(
|
|
|
760
980
|
while ((m = stringRe.exec(source)) !== null) {
|
|
761
981
|
const words = m[1].split(/\W+/)
|
|
762
982
|
for (const word of words) {
|
|
763
|
-
if (chunksByName.has(word)) matchedChunkNames.add(word)
|
|
983
|
+
if (chunksByName.has(word.toLowerCase())) matchedChunkNames.add(word.toLowerCase())
|
|
764
984
|
}
|
|
765
985
|
}
|
|
766
986
|
|
|
767
987
|
const callRe = /\b(\w{3,})\s*\(/g
|
|
768
988
|
while ((m = callRe.exec(source)) !== null) {
|
|
769
|
-
const name = m[1]
|
|
989
|
+
const name = m[1].toLowerCase()
|
|
770
990
|
if (chunksByName.has(name)) matchedChunkNames.add(name)
|
|
771
991
|
}
|
|
772
992
|
|
|
@@ -788,7 +1008,7 @@ async function mapTests(
|
|
|
788
1008
|
.in('id', matchedIds.slice(i, i + UUID_IN_LIMIT))
|
|
789
1009
|
for (const c of data || []) {
|
|
790
1010
|
const name = c.data?.chunk_name
|
|
791
|
-
if (name) fullChunksByName.set(name, c)
|
|
1011
|
+
if (name) fullChunksByName.set(name.toLowerCase(), c)
|
|
792
1012
|
}
|
|
793
1013
|
}
|
|
794
1014
|
|
|
@@ -823,26 +1043,27 @@ async function mapTests(
|
|
|
823
1043
|
|
|
824
1044
|
return { test_files_scanned: testFilesScanned, tested_by_links_created: linksCreated, chunks_updated: chunksUpdated, errors }
|
|
825
1045
|
}
|
|
1046
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Create tested_by links between chunks and test files'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
1047
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
1048
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
1049
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
1050
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
1051
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
1052
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:mapTests:function"]
|
|
826
1053
|
|
|
827
1054
|
|
|
828
1055
|
|
|
829
1056
|
|
|
830
1057
|
|
|
831
|
-
// CIL[
|
|
832
|
-
// CIL[
|
|
833
|
-
// CIL[DOC-
|
|
834
|
-
// CIL[DOC-
|
|
835
|
-
// CIL[DOC-
|
|
836
|
-
// CIL[DOC-
|
|
837
|
-
// CIL[DOC-
|
|
838
|
-
// CIL[DOC-CONFIDENCE pass="second" score="0.95" flags="none"]
|
|
1058
|
+
// CIL[BEGIN stable_id="~/.framework/functions/cil-callmap.ts:handler:constant" type="constant" identity="handler" parent="~/.framework/functions/cil-callmap.ts"]
|
|
1059
|
+
// CIL[DOC-MACRO purpose="Expose the CIL callmap Netlify function handler"]
|
|
1060
|
+
// CIL[DOC-RESPONSIBILITY responsibility="Dispatch map_project, map_file, map_tests, status and clear actions"]
|
|
1061
|
+
// CIL[DOC-CONTEXT module=".framework/functions/cil-callmap" layer="constant" related_files=".framework/functions/_shared/cil.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/middleware.ts,.framework/functions/_shared/resolve-ids.ts,.framework/functions/admin-data.ts,.framework/functions/cil-callmap.ts"]
|
|
1062
|
+
// CIL[DOC-CONTRACT inputs="ctx, body, typeId, ids" outputs="JSON response object" errors="throws or returns error strings" side_effects="reads/writes CIL items and links via adminDb and admin-data"]
|
|
1063
|
+
// CIL[DOC-MICRO logic_summary="createHandler that resolves link type ids, queries chunks/files, calls mapFile/mapTests and returns counts" notable_decisions="[]"]
|
|
1064
|
+
// CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
|
|
839
1065
|
// CIL[DOC-STABILITY stability="stable"]
|
|
840
|
-
|
|
841
|
-
// CIL[DOC-VECTOR type="blast_radius" content="Direct callers: 0. Total affected: 0."]
|
|
842
|
-
// CIL[DOC-VECTOR type="configuration" content="No configuration dependencies."]
|
|
843
|
-
// CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
|
|
844
|
-
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
845
|
-
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
1066
|
+
|
|
846
1067
|
export const handler = createHandler(async (ctx, body) => {
|
|
847
1068
|
const action = ctx.query?.action
|
|
848
1069
|
|
|
@@ -851,43 +1072,35 @@ export const handler = createHandler(async (ctx, body) => {
|
|
|
851
1072
|
const projectId = ctx.query?.project_id || body?.project_id
|
|
852
1073
|
if (!projectId) throw new Error('project_id is required')
|
|
853
1074
|
|
|
854
|
-
const
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
])
|
|
860
|
-
|
|
861
|
-
const { data: fileItems } = await adminDb
|
|
862
|
-
.from('items')
|
|
863
|
-
.select('id')
|
|
864
|
-
.filter('data->>project_id', 'eq', projectId)
|
|
865
|
-
.filter('data->>kb_type', 'eq', 'cil_file')
|
|
1075
|
+
const linkTypeIds = await resolveLinkTypeIds(['cil_imports','cil_calls','cil_exports','cil_tested_by'])
|
|
1076
|
+
const importsTypeId = linkTypeIds['cil_imports'] ?? null
|
|
1077
|
+
const callsTypeId = linkTypeIds['cil_calls'] ?? null
|
|
1078
|
+
const exportsTypeId = linkTypeIds['cil_exports'] ?? null
|
|
1079
|
+
const testedByTypeId = linkTypeIds['cil_tested_by'] ?? null
|
|
866
1080
|
|
|
867
|
-
const
|
|
868
|
-
|
|
869
|
-
.select('id')
|
|
870
|
-
.filter('data->>project_id', 'eq', projectId)
|
|
871
|
-
.filter('data->>kb_type', 'eq', 'cil_chunk')
|
|
1081
|
+
const fileItems = await fetchAllProjectRecords(projectId, 'cil_file')
|
|
1082
|
+
const chunkItems = await fetchAllProjectRecords(projectId, 'cil_chunk')
|
|
872
1083
|
|
|
873
|
-
const fileIds =
|
|
874
|
-
const chunkIds =
|
|
1084
|
+
const fileIds = fileItems.map((f: any) => f.id)
|
|
1085
|
+
const chunkIds = chunkItems.map((c: any) => c.id)
|
|
875
1086
|
|
|
876
|
-
async function countLinksForIds(typeId: string, ids: string[]): Promise<number> {
|
|
1087
|
+
async function countLinksForIds(typeId: string, ids: string[], batchSize = UUID_IN_LIMIT): Promise<number> {
|
|
877
1088
|
if (!typeId || !ids.length) return 0
|
|
878
1089
|
let total = 0
|
|
879
|
-
for (let i = 0; i < ids.length; i +=
|
|
1090
|
+
for (let i = 0; i < ids.length; i += batchSize) {
|
|
880
1091
|
const { count } = await adminDb.from('links').select('id', { count: 'exact' })
|
|
881
|
-
.eq('link_type_id', typeId).in('source_id', ids.slice(i, i +
|
|
1092
|
+
.eq('link_type_id', typeId).in('source_id', ids.slice(i, i + batchSize))
|
|
882
1093
|
total += count || 0
|
|
883
1094
|
}
|
|
884
1095
|
return total
|
|
885
1096
|
}
|
|
886
1097
|
|
|
887
|
-
const importCount = await
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
1098
|
+
const [importCount, callCount, exportCount, testedByCount] = await Promise.all([
|
|
1099
|
+
countLinksForIds(importsTypeId, fileIds),
|
|
1100
|
+
countLinksForIds(callsTypeId, chunkIds),
|
|
1101
|
+
countLinksForIds(exportsTypeId, chunkIds),
|
|
1102
|
+
countLinksForIds(testedByTypeId, chunkIds),
|
|
1103
|
+
])
|
|
891
1104
|
|
|
892
1105
|
return {
|
|
893
1106
|
project_id: projectId,
|
|
@@ -906,11 +1119,10 @@ export const handler = createHandler(async (ctx, body) => {
|
|
|
906
1119
|
const projectId = body?.project_id
|
|
907
1120
|
if (!projectId) throw new Error('project_id is required')
|
|
908
1121
|
|
|
909
|
-
const [
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
])
|
|
1122
|
+
const clearLinkTypeIds = await resolveLinkTypeIds(['cil_imports','cil_calls','cil_exports']).catch(() => ({} as Record<string, string>))
|
|
1123
|
+
const importsTypeId = clearLinkTypeIds['cil_imports'] ?? null
|
|
1124
|
+
const callsTypeId = clearLinkTypeIds['cil_calls'] ?? null
|
|
1125
|
+
const exportsTypeId = clearLinkTypeIds['cil_exports'] ?? null
|
|
914
1126
|
|
|
915
1127
|
const { data: chunkItems } = await adminDb
|
|
916
1128
|
.from('items').select('id')
|
|
@@ -941,16 +1153,16 @@ export const handler = createHandler(async (ctx, body) => {
|
|
|
941
1153
|
|
|
942
1154
|
let resetCount = 0
|
|
943
1155
|
for (const fileItem of fileItems || []) {
|
|
944
|
-
if (getFileStatus(fileItem) === '
|
|
1156
|
+
if (getFileStatus(fileItem) === '7-embedded-mapped' || getFileStatus(fileItem) === '7-embedded-mapped') {
|
|
945
1157
|
const updateCtx = { ...ctx, query: { ...(ctx.query || {}), entity: 'items', id: fileItem.id } }
|
|
946
1158
|
await adminUpdate(updateCtx, {
|
|
947
1159
|
data: {
|
|
948
1160
|
...fileItem.data,
|
|
949
|
-
status: '
|
|
1161
|
+
status: '3-documented',
|
|
950
1162
|
last_status_at: new Date().toISOString(),
|
|
951
1163
|
},
|
|
952
1164
|
}).catch((e: any) => console.error(`reset status ${fileItem.id}: ${e.message}`))
|
|
953
|
-
if (fileTree) updateTreeNodeStatus(fileTree, fileItem.id, '
|
|
1165
|
+
if (fileTree) updateTreeNodeStatus(fileTree, fileItem.id, '3-documented')
|
|
954
1166
|
resetCount++
|
|
955
1167
|
}
|
|
956
1168
|
}
|
|
@@ -973,35 +1185,29 @@ export const handler = createHandler(async (ctx, body) => {
|
|
|
973
1185
|
const projectId = fileItem.data?.project_id
|
|
974
1186
|
if (!projectId) throw new Error('File has no project_id')
|
|
975
1187
|
|
|
976
|
-
const
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
])
|
|
1188
|
+
const fileLinkTypeIds = await resolveLinkTypeIds(['cil_imports','cil_calls','cil_exports'])
|
|
1189
|
+
const importsTypeId = fileLinkTypeIds['cil_imports']
|
|
1190
|
+
const callsTypeId = fileLinkTypeIds['cil_calls']
|
|
1191
|
+
const exportsTypeId = fileLinkTypeIds['cil_exports']
|
|
981
1192
|
|
|
982
1193
|
|
|
983
|
-
const
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
const { data: allChunks } = await adminDb
|
|
989
|
-
.from('items').select('id, title, data')
|
|
990
|
-
.filter('data->>project_id', 'eq', projectId)
|
|
991
|
-
.filter('data->>kb_type', 'eq', 'cil_chunk').eq('is_active', true)
|
|
1194
|
+
const [allFiles, allChunkNames, fileChunks] = await Promise.all([
|
|
1195
|
+
fetchAllProjectRecords(projectId, 'cil_file'),
|
|
1196
|
+
fetchAllProjectChunkNames(projectId),
|
|
1197
|
+
fetchFileChunks(projectId, fileItem.data?.file_path || fileItem.title),
|
|
1198
|
+
])
|
|
992
1199
|
|
|
993
1200
|
const fileItemsByPath = new Map((allFiles || []).map((f: any) => [f.data?.file_path || f.title, f]))
|
|
994
|
-
const chunksByName = new Map
|
|
995
|
-
const
|
|
996
|
-
|
|
997
|
-
const fid = c.data?.file_id
|
|
998
|
-
if (!fid) continue
|
|
999
|
-
if (!allChunksByFile.has(fid)) allChunksByFile.set(fid, [])
|
|
1000
|
-
allChunksByFile.get(fid)!.push(c)
|
|
1201
|
+
const chunksByName = new Map<string, any>()
|
|
1202
|
+
for (const c of allChunkNames) {
|
|
1203
|
+
if (c.chunk_name) chunksByName.set(c.chunk_name.toLowerCase(), { id: c.id, data: { chunk_name: c.chunk_name, kb_type: c.kb_type || 'cil_chunk' } })
|
|
1001
1204
|
}
|
|
1205
|
+
const allChunksByFile = new Map<string, any[]>()
|
|
1206
|
+
const fp = fileItem.data?.file_path || fileItem.title
|
|
1207
|
+
allChunksByFile.set(fp, fileChunks)
|
|
1002
1208
|
|
|
1003
1209
|
const result = await mapFile(
|
|
1004
|
-
fileItem, projectId,
|
|
1210
|
+
ctx, fileItem, projectId,
|
|
1005
1211
|
allChunksByFile, chunksByName, fileItemsByPath,
|
|
1006
1212
|
importsTypeId, callsTypeId, exportsTypeId
|
|
1007
1213
|
)
|
|
@@ -1020,17 +1226,13 @@ export const handler = createHandler(async (ctx, body) => {
|
|
|
1020
1226
|
const repoPath: string = projectItem?.data?.repo_path || body?.repo_path || ''
|
|
1021
1227
|
if (!repoPath) throw new Error('Project has no repo_path — pass repo_path in body')
|
|
1022
1228
|
|
|
1023
|
-
const
|
|
1024
|
-
const
|
|
1025
|
-
|
|
1026
|
-
.select('id, data->>chunk_name, data->>kb_type')
|
|
1027
|
-
.filter('data->>project_id', 'eq', projectId)
|
|
1028
|
-
.filter('data->>kb_type', 'eq', 'cil_chunk')
|
|
1029
|
-
.eq('is_active', true)
|
|
1229
|
+
const testLinkTypeIds = await resolveLinkTypeIds(['cil_tested_by'])
|
|
1230
|
+
const testedByTypeId = testLinkTypeIds['cil_tested_by']
|
|
1231
|
+
const allChunks = await fetchAllProjectRecords(projectId, 'cil_chunk')
|
|
1030
1232
|
const chunksByName = new Map<string, any>()
|
|
1031
|
-
for (const c of allChunks
|
|
1032
|
-
const name = c.chunk_name
|
|
1033
|
-
if (name) chunksByName.set(name, { id: c.id, data: { chunk_name: c.chunk_name, kb_type: c.kb_type || 'cil_chunk' } })
|
|
1233
|
+
for (const c of allChunks) {
|
|
1234
|
+
const name = c.data?.chunk_name
|
|
1235
|
+
if (name) chunksByName.set(name, { id: c.id, data: { chunk_name: c.data?.chunk_name, kb_type: c.data?.kb_type || 'cil_chunk' } })
|
|
1034
1236
|
}
|
|
1035
1237
|
const result = await mapTests(ctx, projectId, repoPath, testedByTypeId, chunksByName)
|
|
1036
1238
|
return { project_id: projectId, repo_path: repoPath, ...result }
|
|
@@ -1051,15 +1253,15 @@ export const handler = createHandler(async (ctx, body) => {
|
|
|
1051
1253
|
const filePath = body?.file_path || undefined
|
|
1052
1254
|
const force = body?.force_regenerate ?? body?.force ?? false
|
|
1053
1255
|
const secondPass = body?.second_pass ?? false
|
|
1256
|
+
const fast = body?.fast === true
|
|
1054
1257
|
|
|
1055
|
-
const targetPipelineStatus = secondPass ? '
|
|
1258
|
+
const targetPipelineStatus = secondPass ? '7-embedded-mapped' : '7-embedded-mapped'
|
|
1056
1259
|
|
|
1057
|
-
const [
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
])
|
|
1260
|
+
const projectLinkTypeIds = await resolveLinkTypeIds(['cil_imports','cil_calls','cil_exports','cil_tested_by']).catch(() => ({} as Record<string, string>))
|
|
1261
|
+
const importsTypeId = projectLinkTypeIds['cil_imports']
|
|
1262
|
+
const callsTypeId = projectLinkTypeIds['cil_calls']
|
|
1263
|
+
const exportsTypeId = projectLinkTypeIds['cil_exports']
|
|
1264
|
+
const testedByTypeId = projectLinkTypeIds['cil_tested_by'] ?? null
|
|
1063
1265
|
|
|
1064
1266
|
if (force && pageOffset === 0) {
|
|
1065
1267
|
await clearProjectLinks(projectId, [importsTypeId, callsTypeId, exportsTypeId, testedByTypeId])
|
|
@@ -1074,36 +1276,35 @@ export const handler = createHandler(async (ctx, body) => {
|
|
|
1074
1276
|
|
|
1075
1277
|
const sourceFilePaths = filePath
|
|
1076
1278
|
? [filePath]
|
|
1077
|
-
:
|
|
1279
|
+
: fast
|
|
1078
1280
|
? selectedPaths
|
|
1079
|
-
:
|
|
1281
|
+
: force
|
|
1282
|
+
? selectedPaths
|
|
1283
|
+
: getMapSourceFilePaths(projectItem, secondPass)
|
|
1080
1284
|
|
|
1081
1285
|
let filesQ = adminDb.from('items').select('id, title, data')
|
|
1082
1286
|
.filter('data->>project_id', 'eq', projectId)
|
|
1083
1287
|
.filter('data->>kb_type', 'eq', 'cil_file').eq('is_active', true)
|
|
1084
1288
|
.order('id')
|
|
1289
|
+
.limit(100000)
|
|
1085
1290
|
if (filePath) filesQ = filesQ.filter('data->>file_path', 'eq', filePath)
|
|
1086
1291
|
|
|
1087
|
-
const [filesResult,
|
|
1292
|
+
const [filesResult, allChunkNamesResult] = await Promise.all([
|
|
1088
1293
|
filesQ,
|
|
1089
|
-
|
|
1090
|
-
.filter('data->>project_id', 'eq', projectId)
|
|
1091
|
-
.filter('data->>kb_type', 'eq', 'cil_chunk')
|
|
1092
|
-
.eq('is_active', true),
|
|
1294
|
+
fetchAllProjectChunkNames(projectId),
|
|
1093
1295
|
])
|
|
1094
1296
|
|
|
1095
1297
|
const allFiles = filesResult.data || []
|
|
1096
|
-
const allChunksMinimal = allChunksMinimalResult.data || []
|
|
1097
1298
|
|
|
1098
1299
|
const fileItemsByPath = new Map(allFiles.map((f: any) => [f.data?.file_path || f.title, f]))
|
|
1099
1300
|
|
|
1100
1301
|
const chunksByName = new Map<string, any>()
|
|
1101
|
-
for (const c of
|
|
1302
|
+
for (const c of allChunkNamesResult) {
|
|
1102
1303
|
const name = c.chunk_name
|
|
1103
|
-
if (name) chunksByName.set(name, { id: c.id, data: { chunk_name: c.chunk_name, kb_type: c.kb_type || 'cil_chunk' } })
|
|
1304
|
+
if (name) chunksByName.set(name.toLowerCase(), { id: c.id, data: { chunk_name: c.chunk_name, kb_type: c.kb_type || 'cil_chunk' } })
|
|
1104
1305
|
}
|
|
1105
1306
|
|
|
1106
|
-
const mappedFileStatus = secondPass ? '
|
|
1307
|
+
const mappedFileStatus: FileStatus = secondPass ? '7-embedded-mapped' : '7-embedded-mapped'
|
|
1107
1308
|
const syncFiles = allFiles.filter((f: any) => {
|
|
1108
1309
|
const fp = f.data?.file_path || f.title
|
|
1109
1310
|
const status = getFileStatus(f)
|
|
@@ -1114,8 +1315,10 @@ export const handler = createHandler(async (ctx, body) => {
|
|
|
1114
1315
|
&& isSelectedPath(fp, selectedPaths)
|
|
1115
1316
|
&& extMatch
|
|
1116
1317
|
})
|
|
1117
|
-
|
|
1118
|
-
|
|
1318
|
+
if (!fast) {
|
|
1319
|
+
for (const fileItem of syncFiles) {
|
|
1320
|
+
await markFilePass4bComplete(ctx, fileItem, fileTree, secondPass, projectItem)
|
|
1321
|
+
}
|
|
1119
1322
|
}
|
|
1120
1323
|
|
|
1121
1324
|
const eligibleFiles = allFiles.filter((f: any) => {
|
|
@@ -1137,17 +1340,18 @@ export const handler = createHandler(async (ctx, body) => {
|
|
|
1137
1340
|
.filter('data->>kb_type', 'eq', 'cil_chunk')
|
|
1138
1341
|
.eq('is_active', true)
|
|
1139
1342
|
.in('data->>file_path' as any, pageFilePaths)
|
|
1343
|
+
.limit(100000)
|
|
1140
1344
|
pageChunks = data || []
|
|
1141
1345
|
}
|
|
1142
1346
|
|
|
1143
1347
|
const allChunksByFile = new Map<string, any[]>()
|
|
1144
1348
|
for (const c of pageChunks) {
|
|
1145
1349
|
const name = c.data?.chunk_name || ''
|
|
1146
|
-
if (name) chunksByName.set(name, c)
|
|
1147
|
-
const
|
|
1148
|
-
if (!
|
|
1149
|
-
if (!allChunksByFile.has(
|
|
1150
|
-
allChunksByFile.get(
|
|
1350
|
+
if (name) chunksByName.set(name.toLowerCase(), c)
|
|
1351
|
+
const fp = c.data?.file_path
|
|
1352
|
+
if (!fp) continue
|
|
1353
|
+
if (!allChunksByFile.has(fp)) allChunksByFile.set(fp, [])
|
|
1354
|
+
allChunksByFile.get(fp)!.push(c)
|
|
1151
1355
|
}
|
|
1152
1356
|
|
|
1153
1357
|
if (!chunksByName.size) {
|
|
@@ -1169,7 +1373,9 @@ export const handler = createHandler(async (ctx, body) => {
|
|
|
1169
1373
|
totalExports += result.exports_created
|
|
1170
1374
|
|
|
1171
1375
|
|
|
1172
|
-
|
|
1376
|
+
if (!fast) {
|
|
1377
|
+
await markFilePass4bComplete(ctx, fileItem, fileTree, secondPass, projectItem)
|
|
1378
|
+
}
|
|
1173
1379
|
} catch (err) {
|
|
1174
1380
|
errors.push(`${fileItem.data?.file_path || fileItem.id}: ${err instanceof Error ? err.message : String(err)}`)
|
|
1175
1381
|
}
|
|
@@ -1180,11 +1386,12 @@ export const handler = createHandler(async (ctx, body) => {
|
|
|
1180
1386
|
|
|
1181
1387
|
|
|
1182
1388
|
let testResult: { test_files_scanned: number; tested_by_links_created: number; chunks_updated: number; errors: string[] } | null = null
|
|
1183
|
-
if (isLastPage) {
|
|
1389
|
+
if (isLastPage && !fast) {
|
|
1184
1390
|
const repoPath: string = projectItem?.data?.repo_path || ''
|
|
1185
1391
|
if (repoPath) {
|
|
1186
1392
|
try {
|
|
1187
|
-
const
|
|
1393
|
+
const testByLinkIds = await resolveLinkTypeIds(['cil_tested_by']).catch(() => ({} as Record<string, string>))
|
|
1394
|
+
const testedByTypeId = testByLinkIds['cil_tested_by']
|
|
1188
1395
|
if (testedByTypeId) {
|
|
1189
1396
|
testResult = await mapTests(ctx, projectId, repoPath, testedByTypeId, chunksByName)
|
|
1190
1397
|
errors.push(...(testResult.errors || []))
|
|
@@ -1195,7 +1402,7 @@ export const handler = createHandler(async (ctx, body) => {
|
|
|
1195
1402
|
}
|
|
1196
1403
|
|
|
1197
1404
|
|
|
1198
|
-
if (fileTree) {
|
|
1405
|
+
if (fileTree && isLastPage && !fast) {
|
|
1199
1406
|
await saveProjectTree(ctx, projectId, fileTree, { last_ingested_at: new Date().toISOString() }, projectItem)
|
|
1200
1407
|
}
|
|
1201
1408
|
|
|
@@ -1220,8 +1427,13 @@ export const handler = createHandler(async (ctx, body) => {
|
|
|
1220
1427
|
|
|
1221
1428
|
throw new Error(`Unknown action: ${action}. Valid: map_project, map_file, map_tests, status, clear`)
|
|
1222
1429
|
})
|
|
1430
|
+
// CIL[DOC-VECTOR type="context" content="purpose='Expose the CIL callmap Netlify function handler'; No verified external callers; imports: .framework/functions/_shared/middleware.ts,.framework/functions/_shared/db.ts,.framework/functions/_shared/resolve-ids.ts"]
|
|
1431
|
+
// CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
|
|
1432
|
+
// CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
|
|
1433
|
+
// CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
|
|
1434
|
+
// CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
|
|
1435
|
+
// CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
|
|
1436
|
+
// CIL[END stable_id="~/.framework/functions/cil-callmap.ts:handler:constant"]
|
|
1223
1437
|
|
|
1224
1438
|
|
|
1225
1439
|
|
|
1226
|
-
|
|
1227
|
-
// CIL[END chunk_id="custom_apps_cortex_functions_custom_cil_callmap_handler_1784235266"]
|