attocode-code-intel 0.1.0__py3-none-any.whl
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.
- attocode_code_intel-0.1.0.dist-info/METADATA +221 -0
- attocode_code_intel-0.1.0.dist-info/RECORD +345 -0
- attocode_code_intel-0.1.0.dist-info/WHEEL +4 -0
- attocode_code_intel-0.1.0.dist-info/entry_points.txt +2 -0
- attocode_code_intel-0.1.0.dist-info/licenses/LICENSE +21 -0
- attocode_intel/GUIDELINES.md +432 -0
- attocode_intel/__init__.py +52 -0
- attocode_intel/_internal/__init__.py +1 -0
- attocode_intel/_internal/errors/__init__.py +126 -0
- attocode_intel/_internal/integrations/__init__.py +1 -0
- attocode_intel/_internal/integrations/context/__init__.py +1 -0
- attocode_intel/_internal/integrations/context/architecture_drift.py +354 -0
- attocode_intel/_internal/integrations/context/ast_chunker.py +202 -0
- attocode_intel/_internal/integrations/context/ast_service.py +1483 -0
- attocode_intel/_internal/integrations/context/blob_oid.py +423 -0
- attocode_intel/_internal/integrations/context/cache_manifest.py +221 -0
- attocode_intel/_internal/integrations/context/cas.py +466 -0
- attocode_intel/_internal/integrations/context/code_analyzer.py +528 -0
- attocode_intel/_internal/integrations/context/codebase_ast.py +1461 -0
- attocode_intel/_internal/integrations/context/codebase_context.py +1736 -0
- attocode_intel/_internal/integrations/context/cross_mode.py +263 -0
- attocode_intel/_internal/integrations/context/cross_references.py +616 -0
- attocode_intel/_internal/integrations/context/embedding_rotation.py +597 -0
- attocode_intel/_internal/integrations/context/embeddings.py +282 -0
- attocode_intel/_internal/integrations/context/frecency.py +427 -0
- attocode_intel/_internal/integrations/context/fuzzy.py +320 -0
- attocode_intel/_internal/integrations/context/hierarchical_explorer.py +331 -0
- attocode_intel/_internal/integrations/context/hydration.py +90 -0
- attocode_intel/_internal/integrations/context/index_repair.py +87 -0
- attocode_intel/_internal/integrations/context/index_store.py +586 -0
- attocode_intel/_internal/integrations/context/memory_store.py +602 -0
- attocode_intel/_internal/integrations/context/module_resolution.py +52 -0
- attocode_intel/_internal/integrations/context/query_constraints.py +361 -0
- attocode_intel/_internal/integrations/context/query_history.py +417 -0
- attocode_intel/_internal/integrations/context/reranker.py +351 -0
- attocode_intel/_internal/integrations/context/semantic_search.py +2931 -0
- attocode_intel/_internal/integrations/context/syntax_evidence.py +94 -0
- attocode_intel/_internal/integrations/context/systemone_ranker.py +245 -0
- attocode_intel/_internal/integrations/context/temporal_coupling.py +411 -0
- attocode_intel/_internal/integrations/context/trigram_index.py +820 -0
- attocode_intel/_internal/integrations/context/trigram_regex.py +171 -0
- attocode_intel/_internal/integrations/context/ts_parser.py +2199 -0
- attocode_intel/_internal/integrations/context/vector_store.py +795 -0
- attocode_intel/_internal/integrations/feature_flags/__init__.py +357 -0
- attocode_intel/_internal/integrations/lsp/__init__.py +1 -0
- attocode_intel/_internal/integrations/lsp/client.py +1140 -0
- attocode_intel/_internal/integrations/mcp/__init__.py +1 -0
- attocode_intel/_internal/integrations/mcp/client.py +253 -0
- attocode_intel/_internal/integrations/security/__init__.py +1 -0
- attocode_intel/_internal/integrations/security/custom_rules.py +176 -0
- attocode_intel/_internal/integrations/security/dataflow.py +522 -0
- attocode_intel/_internal/integrations/security/dependency_audit.py +303 -0
- attocode_intel/_internal/integrations/security/matcher.py +44 -0
- attocode_intel/_internal/integrations/security/patterns.py +724 -0
- attocode_intel/_internal/integrations/security/scanner.py +351 -0
- attocode_intel/_internal/integrations/utilities/__init__.py +1 -0
- attocode_intel/_internal/integrations/utilities/ignore.py +64 -0
- attocode_intel/_internal/integrations/utilities/token_estimate.py +51 -0
- attocode_intel/_internal/tricks/__init__.py +1 -0
- attocode_intel/_internal/tricks/recursive_context.py +357 -0
- attocode_intel/_internal/types/__init__.py +1 -0
- attocode_intel/_internal/types/events.py +289 -0
- attocode_intel/_internal/types/severity.py +15 -0
- attocode_intel/_shared.py +341 -0
- attocode_intel/analysis_coverage.py +56 -0
- attocode_intel/api/__init__.py +1 -0
- attocode_intel/api/access.py +32 -0
- attocode_intel/api/app.py +247 -0
- attocode_intel/api/auth/__init__.py +128 -0
- attocode_intel/api/auth/api_keys.py +61 -0
- attocode_intel/api/auth/context.py +34 -0
- attocode_intel/api/auth/jwt.py +66 -0
- attocode_intel/api/auth/oauth.py +146 -0
- attocode_intel/api/auth/passwords.py +15 -0
- attocode_intel/api/deps.py +351 -0
- attocode_intel/api/knowledge_bridge.py +13 -0
- attocode_intel/api/mcp_transport.py +51 -0
- attocode_intel/api/middleware.py +411 -0
- attocode_intel/api/models.py +698 -0
- attocode_intel/api/providers/__init__.py +1 -0
- attocode_intel/api/providers/db_provider.py +1106 -0
- attocode_intel/api/providers/local_provider.py +476 -0
- attocode_intel/api/providers/remote_provider.py +740 -0
- attocode_intel/api/repository_source.py +21 -0
- attocode_intel/api/routes/__init__.py +1 -0
- attocode_intel/api/routes/_pin_helper.py +158 -0
- attocode_intel/api/routes/activity.py +148 -0
- attocode_intel/api/routes/adr.py +102 -0
- attocode_intel/api/routes/analysis.py +515 -0
- attocode_intel/api/routes/api_keys.py +170 -0
- attocode_intel/api/routes/auth.py +428 -0
- attocode_intel/api/routes/branches.py +262 -0
- attocode_intel/api/routes/cross_repo_search.py +198 -0
- attocode_intel/api/routes/embeddings.py +386 -0
- attocode_intel/api/routes/files.py +132 -0
- attocode_intel/api/routes/files_v2.py +388 -0
- attocode_intel/api/routes/gc.py +322 -0
- attocode_intel/api/routes/git_v2.py +433 -0
- attocode_intel/api/routes/graph.py +174 -0
- attocode_intel/api/routes/graph_viz.py +160 -0
- attocode_intel/api/routes/health.py +62 -0
- attocode_intel/api/routes/history.py +175 -0
- attocode_intel/api/routes/jobs.py +84 -0
- attocode_intel/api/routes/learning.py +205 -0
- attocode_intel/api/routes/lsp.py +272 -0
- attocode_intel/api/routes/notify.py +623 -0
- attocode_intel/api/routes/operations.py +27 -0
- attocode_intel/api/routes/orgs.py +924 -0
- attocode_intel/api/routes/preferences.py +100 -0
- attocode_intel/api/routes/presence.py +42 -0
- attocode_intel/api/routes/projects.py +116 -0
- attocode_intel/api/routes/repos.py +47 -0
- attocode_intel/api/routes/search.py +180 -0
- attocode_intel/api/routes/snapshots.py +614 -0
- attocode_intel/api/routes/webhooks.py +313 -0
- attocode_intel/api/routes/websocket.py +116 -0
- attocode_intel/api/static/graph.html +239 -0
- attocode_intel/api/utils.py +96 -0
- attocode_intel/artifacts/__init__.py +45 -0
- attocode_intel/artifacts/hashing.py +230 -0
- attocode_intel/artifacts/provenance.py +190 -0
- attocode_intel/artifacts/retrieval_pin.py +159 -0
- attocode_intel/audit.py +59 -0
- attocode_intel/bug_finder.py +206 -0
- attocode_intel/bundle.py +80 -0
- attocode_intel/catalog.py +242 -0
- attocode_intel/change_review.py +75 -0
- attocode_intel/cli.py +3062 -0
- attocode_intel/community.py +63 -0
- attocode_intel/confidence/__init__.py +144 -0
- attocode_intel/confidence/jev.py +234 -0
- attocode_intel/confidence/llm.py +330 -0
- attocode_intel/confidence/redact.py +44 -0
- attocode_intel/confidence/settings.py +74 -0
- attocode_intel/config.py +256 -0
- attocode_intel/crypto.py +31 -0
- attocode_intel/db/__init__.py +7 -0
- attocode_intel/db/base.py +33 -0
- attocode_intel/db/engine.py +61 -0
- attocode_intel/db/models.py +529 -0
- attocode_intel/entrypoint.py +185 -0
- attocode_intel/focused_evidence.py +130 -0
- attocode_intel/freshness.py +154 -0
- attocode_intel/gateway.py +734 -0
- attocode_intel/git/__init__.py +7 -0
- attocode_intel/git/credentials.py +75 -0
- attocode_intel/git/manager.py +493 -0
- attocode_intel/git/models.py +96 -0
- attocode_intel/git/storage.py +98 -0
- attocode_intel/graph_query_parser.py +761 -0
- attocode_intel/helpers.py +712 -0
- attocode_intel/indexing/__init__.py +29 -0
- attocode_intel/indexing/debouncer.py +136 -0
- attocode_intel/indexing/delta_indexer.py +151 -0
- attocode_intel/indexing/full_indexer.py +323 -0
- attocode_intel/indexing/incremental.py +240 -0
- attocode_intel/indexing/parser.py +403 -0
- attocode_intel/indexing/summarizer.py +264 -0
- attocode_intel/installer.py +1896 -0
- attocode_intel/knowledge.py +269 -0
- attocode_intel/local_knowledge.py +77 -0
- attocode_intel/migrations/alembic.ini +36 -0
- attocode_intel/migrations/env.py +71 -0
- attocode_intel/migrations/script.py.mako +27 -0
- attocode_intel/migrations/versions/001_initial_schema.py +219 -0
- attocode_intel/migrations/versions/002_branch_version_and_embeddings.py +61 -0
- attocode_intel/migrations/versions/003_embedding_uniqueness_and_cascade.py +51 -0
- attocode_intel/migrations/versions/004_audit_events.py +38 -0
- attocode_intel/migrations/versions/005_user_preferences.py +30 -0
- attocode_intel/migrations/versions/006_google_oauth.py +27 -0
- attocode_intel/migrations/versions/007_pgvector_embeddings.py +28 -0
- attocode_intel/migrations/versions/008_symbol_references.py +37 -0
- attocode_intel/migrations/versions/009_webhook_secret_encryption.py +25 -0
- attocode_intel/migrations/versions/010_add_commits_table.py +40 -0
- attocode_intel/migrations/versions/011_commit_changed_files.py +25 -0
- attocode_intel/migrations/versions/012_branch_merged_at.py +25 -0
- attocode_intel/migrations/versions/013_revoked_tokens.py +32 -0
- attocode_intel/migrations/versions/014_blame_hunks.py +40 -0
- attocode_intel/migrations/versions/015_commit_file_stats.py +40 -0
- attocode_intel/migrations/versions/016_embedding_provenance_columns.py +179 -0
- attocode_intel/migrations/versions/017_provenance_table.py +102 -0
- attocode_intel/migrations/versions/018_repo_snapshots.py +178 -0
- attocode_intel/migrations/versions/019_symref_caller.py +42 -0
- attocode_intel/migrations/versions/020_shared_knowledge.py +29 -0
- attocode_intel/onboarding.py +258 -0
- attocode_intel/output.py +178 -0
- attocode_intel/precision.py +133 -0
- attocode_intel/presence.py +160 -0
- attocode_intel/probe.py +110 -0
- attocode_intel/project_dir.py +97 -0
- attocode_intel/pubsub.py +113 -0
- attocode_intel/query_ranking.py +242 -0
- attocode_intel/readiness.py +972 -0
- attocode_intel/redis.py +51 -0
- attocode_intel/reference_pages.py +60 -0
- attocode_intel/remote.py +131 -0
- attocode_intel/repo_ranker.py +246 -0
- attocode_intel/request_context.py +82 -0
- attocode_intel/rules/__init__.py +28 -0
- attocode_intel/rules/ci.py +320 -0
- attocode_intel/rules/combinators.py +293 -0
- attocode_intel/rules/enricher.py +127 -0
- attocode_intel/rules/evolution.py +452 -0
- attocode_intel/rules/executor.py +531 -0
- attocode_intel/rules/filters/__init__.py +5 -0
- attocode_intel/rules/filters/pipeline.py +151 -0
- attocode_intel/rules/formatter.py +198 -0
- attocode_intel/rules/hygiene.py +242 -0
- attocode_intel/rules/importers/__init__.py +1 -0
- attocode_intel/rules/importers/semgrep.py +382 -0
- attocode_intel/rules/loader.py +292 -0
- attocode_intel/rules/marketplace.py +375 -0
- attocode_intel/rules/metavar.py +181 -0
- attocode_intel/rules/model.py +317 -0
- attocode_intel/rules/packs/__init__.py +1 -0
- attocode_intel/rules/packs/community/_license_templates/Apache-2.0.txt +176 -0
- attocode_intel/rules/packs/community/_license_templates/MIT.txt +21 -0
- attocode_intel/rules/packs/community/bandit-python/LICENSE +176 -0
- attocode_intel/rules/packs/community/bandit-python/NOTICE +13 -0
- attocode_intel/rules/packs/community/bandit-python/PORTING.md +23 -0
- attocode_intel/rules/packs/community/bandit-python/manifest.yaml +14 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B105-hardcoded-password.yaml +23 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B303-weak-md5.yaml +21 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B304-weak-des.yaml +20 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B307-use-of-eval.yaml +22 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B324-weak-sha1.yaml +21 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B501-no-cert-validation.yaml +23 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B602-shell-true.yaml +22 -0
- attocode_intel/rules/packs/community/bandit-python/rules/B608-sqli.yaml +22 -0
- attocode_intel/rules/packs/community/eslint-typescript/LICENSE +21 -0
- attocode_intel/rules/packs/community/eslint-typescript/NOTICE +13 -0
- attocode_intel/rules/packs/community/eslint-typescript/PORTING.md +23 -0
- attocode_intel/rules/packs/community/eslint-typescript/manifest.yaml +14 -0
- attocode_intel/rules/packs/community/eslint-typescript/rules/eqeqeq.yaml +20 -0
- attocode_intel/rules/packs/community/eslint-typescript/rules/no-eval.yaml +22 -0
- attocode_intel/rules/packs/community/eslint-typescript/rules/no-implied-eval.yaml +20 -0
- attocode_intel/rules/packs/community/eslint-typescript/rules/no-new-func.yaml +21 -0
- attocode_intel/rules/packs/community/eslint-typescript/rules/no-throw-literal.yaml +19 -0
- attocode_intel/rules/packs/community/eslint-typescript/rules/no-var.yaml +20 -0
- attocode_intel/rules/packs/community/eslint-typescript/rules/no-with.yaml +18 -0
- attocode_intel/rules/packs/community/gosec-go/LICENSE +176 -0
- attocode_intel/rules/packs/community/gosec-go/NOTICE +13 -0
- attocode_intel/rules/packs/community/gosec-go/PORTING.md +23 -0
- attocode_intel/rules/packs/community/gosec-go/manifest.yaml +14 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G101-hardcoded-credentials.yaml +22 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G102-bind-all-interfaces.yaml +21 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G103-unsafe-block.yaml +21 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G201-sql-format.yaml +21 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G304-file-inclusion.yaml +23 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G401-weak-cipher.yaml +20 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G402-tls-min-version.yaml +20 -0
- attocode_intel/rules/packs/community/gosec-go/rules/G501-md5-import.yaml +21 -0
- attocode_intel/rules/packs/examples/cpp/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/cpp/rules/security.yaml +90 -0
- attocode_intel/rules/packs/examples/cpp/rules/structural.yaml +42 -0
- attocode_intel/rules/packs/examples/csharp/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/csharp/rules/security.yaml +69 -0
- attocode_intel/rules/packs/examples/csharp/rules/structural.yaml +42 -0
- attocode_intel/rules/packs/examples/go/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/go/rules/performance.yaml +136 -0
- attocode_intel/rules/packs/examples/go/rules/security.yaml +48 -0
- attocode_intel/rules/packs/examples/go/rules/structural.yaml +58 -0
- attocode_intel/rules/packs/examples/go/taint/sanitizers.yaml +24 -0
- attocode_intel/rules/packs/examples/go/taint/sinks.yaml +51 -0
- attocode_intel/rules/packs/examples/go/taint/sources.yaml +26 -0
- attocode_intel/rules/packs/examples/java/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/java/rules/correctness.yaml +55 -0
- attocode_intel/rules/packs/examples/java/rules/structural.yaml +48 -0
- attocode_intel/rules/packs/examples/java/taint/sinks.yaml +37 -0
- attocode_intel/rules/packs/examples/java/taint/sources.yaml +21 -0
- attocode_intel/rules/packs/examples/kotlin/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/kotlin/rules/correctness.yaml +50 -0
- attocode_intel/rules/packs/examples/kotlin/rules/structural.yaml +38 -0
- attocode_intel/rules/packs/examples/php/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/php/rules/security.yaml +66 -0
- attocode_intel/rules/packs/examples/php/rules/structural.yaml +41 -0
- attocode_intel/rules/packs/examples/python/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/python/rules/performance.yaml +90 -0
- attocode_intel/rules/packs/examples/python/rules/structural.yaml +55 -0
- attocode_intel/rules/packs/examples/ruby/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/ruby/rules/security.yaml +73 -0
- attocode_intel/rules/packs/examples/ruby/rules/structural.yaml +41 -0
- attocode_intel/rules/packs/examples/rust/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/rust/rules/correctness.yaml +51 -0
- attocode_intel/rules/packs/examples/rust/rules/structural.yaml +49 -0
- attocode_intel/rules/packs/examples/typescript/manifest.yaml +4 -0
- attocode_intel/rules/packs/examples/typescript/rules/performance.yaml +70 -0
- attocode_intel/rules/packs/examples/typescript/rules/structural.yaml +48 -0
- attocode_intel/rules/packs/pack_loader.py +244 -0
- attocode_intel/rules/plugins/__init__.py +1 -0
- attocode_intel/rules/plugins/plugin_loader.py +132 -0
- attocode_intel/rules/profiling.py +332 -0
- attocode_intel/rules/registry.py +213 -0
- attocode_intel/rules/sarif.py +187 -0
- attocode_intel/rules/synthesis.py +420 -0
- attocode_intel/rules/testing.py +326 -0
- attocode_intel/server.py +734 -0
- attocode_intel/service.py +3416 -0
- attocode_intel/sharing.py +57 -0
- attocode_intel/storage/__init__.py +6 -0
- attocode_intel/storage/branch_overlay.py +352 -0
- attocode_intel/storage/content_store.py +220 -0
- attocode_intel/storage/dependency_store.py +143 -0
- attocode_intel/storage/diff_engine.py +187 -0
- attocode_intel/storage/embedding_store.py +594 -0
- attocode_intel/storage/provenance_store.py +137 -0
- attocode_intel/storage/security_scanner_db.py +164 -0
- attocode_intel/storage/symbol_store.py +160 -0
- attocode_intel/structural_evidence.py +144 -0
- attocode_intel/symbol_inspection.py +141 -0
- attocode_intel/symbol_links.py +167 -0
- attocode_intel/telemetry.py +42 -0
- attocode_intel/test_ranking.py +73 -0
- attocode_intel/testing/__init__.py +43 -0
- attocode_intel/testing/fixtures.py +122 -0
- attocode_intel/testing/helpers.py +75 -0
- attocode_intel/testing/mocks.py +99 -0
- attocode_intel/tools/__init__.py +2 -0
- attocode_intel/tools/adr_tools.py +628 -0
- attocode_intel/tools/analysis_tools.py +382 -0
- attocode_intel/tools/composite_tools.py +695 -0
- attocode_intel/tools/cross_mode_tools.py +173 -0
- attocode_intel/tools/dead_code_tools.py +582 -0
- attocode_intel/tools/distill_tools.py +353 -0
- attocode_intel/tools/frecency_tools.py +220 -0
- attocode_intel/tools/fuzzy_tools.py +255 -0
- attocode_intel/tools/history_tools.py +486 -0
- attocode_intel/tools/learning_tools.py +222 -0
- attocode_intel/tools/lsp_tools.py +218 -0
- attocode_intel/tools/maintenance_tools.py +1662 -0
- attocode_intel/tools/navigation_tools.py +220 -0
- attocode_intel/tools/overlay_tools.py +540 -0
- attocode_intel/tools/pin_store.py +432 -0
- attocode_intel/tools/pin_tools.py +266 -0
- attocode_intel/tools/query_constraints_tools.py +262 -0
- attocode_intel/tools/query_history_tools.py +158 -0
- attocode_intel/tools/readiness_tools.py +44 -0
- attocode_intel/tools/rule_tools.py +992 -0
- attocode_intel/tools/search_tools.py +770 -0
- attocode_intel/tools/snapshot_tools.py +624 -0
- attocode_intel/workers/__init__.py +1 -0
- attocode_intel/workers/job_utils.py +111 -0
- attocode_intel/workers/jobs.py +573 -0
- attocode_intel/workers/run.py +30 -0
- attocode_intel/workers/settings.py +61 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"""Initial schema — identity, repos, branches, content-addressed storage, jobs.
|
|
2
|
+
|
|
3
|
+
Revision ID: 001
|
|
4
|
+
Revises: None
|
|
5
|
+
Create Date: 2026-03-11
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
from alembic import op
|
|
12
|
+
import sqlalchemy as sa
|
|
13
|
+
from sqlalchemy.dialects.postgresql import ARRAY, JSONB, UUID
|
|
14
|
+
|
|
15
|
+
revision: str = "001"
|
|
16
|
+
down_revision: Union[str, None] = None
|
|
17
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
18
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def upgrade() -> None:
|
|
22
|
+
# --- Identity tables ---
|
|
23
|
+
op.create_table(
|
|
24
|
+
"organizations",
|
|
25
|
+
sa.Column("id", UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), primary_key=True),
|
|
26
|
+
sa.Column("name", sa.Text, nullable=False),
|
|
27
|
+
sa.Column("slug", sa.Text, unique=True, nullable=False),
|
|
28
|
+
sa.Column("plan", sa.Text, nullable=False, server_default="free"),
|
|
29
|
+
sa.Column("settings", JSONB, nullable=False, server_default="{}"),
|
|
30
|
+
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
31
|
+
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
op.create_table(
|
|
35
|
+
"users",
|
|
36
|
+
sa.Column("id", UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), primary_key=True),
|
|
37
|
+
sa.Column("email", sa.Text, unique=True, nullable=False),
|
|
38
|
+
sa.Column("name", sa.Text, nullable=False, server_default=""),
|
|
39
|
+
sa.Column("avatar_url", sa.Text, nullable=True),
|
|
40
|
+
sa.Column("password_hash", sa.Text, nullable=True),
|
|
41
|
+
sa.Column("github_id", sa.BigInteger, unique=True, nullable=True),
|
|
42
|
+
sa.Column("auth_provider", sa.Text, nullable=False, server_default="email"),
|
|
43
|
+
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
op.create_table(
|
|
47
|
+
"org_memberships",
|
|
48
|
+
sa.Column("org_id", UUID(as_uuid=True), sa.ForeignKey("organizations.id", ondelete="CASCADE"), primary_key=True),
|
|
49
|
+
sa.Column("user_id", UUID(as_uuid=True), sa.ForeignKey("users.id", ondelete="CASCADE"), primary_key=True),
|
|
50
|
+
sa.Column("role", sa.Text, nullable=False, server_default="member"),
|
|
51
|
+
sa.Column("invited_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
52
|
+
sa.Column("accepted_at", sa.DateTime(timezone=True), nullable=True),
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
op.create_table(
|
|
56
|
+
"api_keys",
|
|
57
|
+
sa.Column("id", UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), primary_key=True),
|
|
58
|
+
sa.Column("org_id", UUID(as_uuid=True), sa.ForeignKey("organizations.id", ondelete="CASCADE"), nullable=False),
|
|
59
|
+
sa.Column("user_id", UUID(as_uuid=True), sa.ForeignKey("users.id"), nullable=True),
|
|
60
|
+
sa.Column("name", sa.Text, nullable=False),
|
|
61
|
+
sa.Column("key_hash", sa.Text, unique=True, nullable=False),
|
|
62
|
+
sa.Column("key_prefix", sa.Text, nullable=False),
|
|
63
|
+
sa.Column("scopes", ARRAY(sa.String), nullable=False, server_default="{}"),
|
|
64
|
+
sa.Column("expires_at", sa.DateTime(timezone=True), nullable=True),
|
|
65
|
+
sa.Column("last_used_at", sa.DateTime(timezone=True), nullable=True),
|
|
66
|
+
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
# --- Repositories ---
|
|
70
|
+
op.create_table(
|
|
71
|
+
"repositories",
|
|
72
|
+
sa.Column("id", UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), primary_key=True),
|
|
73
|
+
sa.Column("org_id", UUID(as_uuid=True), sa.ForeignKey("organizations.id", ondelete="CASCADE"), nullable=False),
|
|
74
|
+
sa.Column("name", sa.Text, nullable=False),
|
|
75
|
+
sa.Column("local_path", sa.Text, nullable=True),
|
|
76
|
+
sa.Column("clone_url", sa.Text, nullable=True),
|
|
77
|
+
sa.Column("default_branch", sa.Text, nullable=False, server_default="main"),
|
|
78
|
+
sa.Column("language", sa.Text, nullable=True),
|
|
79
|
+
sa.Column("last_indexed_at", sa.DateTime(timezone=True), nullable=True),
|
|
80
|
+
sa.Column("index_status", sa.Text, nullable=False, server_default="pending"),
|
|
81
|
+
sa.Column("settings", JSONB, nullable=False, server_default="{}"),
|
|
82
|
+
sa.Column("clone_path", sa.Text, nullable=True),
|
|
83
|
+
sa.Column("disk_usage_bytes", sa.BigInteger, nullable=False, server_default="0"),
|
|
84
|
+
sa.Column("last_fetched_at", sa.DateTime(timezone=True), nullable=True),
|
|
85
|
+
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
86
|
+
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
87
|
+
sa.UniqueConstraint("org_id", "name", name="uq_repo_org_name"),
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
op.create_table(
|
|
91
|
+
"repo_credentials",
|
|
92
|
+
sa.Column("id", UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), primary_key=True),
|
|
93
|
+
sa.Column("repo_id", UUID(as_uuid=True), sa.ForeignKey("repositories.id", ondelete="CASCADE"), nullable=False),
|
|
94
|
+
sa.Column("cred_type", sa.Text, nullable=False),
|
|
95
|
+
sa.Column("encrypted_value", sa.LargeBinary, nullable=False),
|
|
96
|
+
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# --- Branches & content-addressed storage ---
|
|
100
|
+
op.create_table(
|
|
101
|
+
"branches",
|
|
102
|
+
sa.Column("id", UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), primary_key=True),
|
|
103
|
+
sa.Column("repo_id", UUID(as_uuid=True), sa.ForeignKey("repositories.id", ondelete="CASCADE"), nullable=False),
|
|
104
|
+
sa.Column("name", sa.Text, nullable=False),
|
|
105
|
+
sa.Column("parent_branch_id", UUID(as_uuid=True), sa.ForeignKey("branches.id"), nullable=True),
|
|
106
|
+
sa.Column("head_commit", sa.Text, nullable=True),
|
|
107
|
+
sa.Column("last_indexed_at", sa.DateTime(timezone=True), nullable=True),
|
|
108
|
+
sa.Column("is_default", sa.Boolean, nullable=False, server_default="false"),
|
|
109
|
+
sa.UniqueConstraint("repo_id", "name", name="uq_branch_repo_name"),
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
op.create_table(
|
|
113
|
+
"file_contents",
|
|
114
|
+
sa.Column("sha256", sa.Text, primary_key=True),
|
|
115
|
+
sa.Column("content", sa.LargeBinary, nullable=False),
|
|
116
|
+
sa.Column("size_bytes", sa.Integer, nullable=False),
|
|
117
|
+
sa.Column("language", sa.Text, nullable=True),
|
|
118
|
+
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
op.create_table(
|
|
122
|
+
"branch_files",
|
|
123
|
+
sa.Column("branch_id", UUID(as_uuid=True), sa.ForeignKey("branches.id", ondelete="CASCADE"), primary_key=True),
|
|
124
|
+
sa.Column("path", sa.Text, primary_key=True),
|
|
125
|
+
sa.Column("content_sha", sa.Text, sa.ForeignKey("file_contents.sha256"), nullable=True),
|
|
126
|
+
sa.Column("status", sa.Text, nullable=False),
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
op.create_table(
|
|
130
|
+
"symbols",
|
|
131
|
+
sa.Column("id", UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), primary_key=True),
|
|
132
|
+
sa.Column("content_sha", sa.Text, sa.ForeignKey("file_contents.sha256"), nullable=False),
|
|
133
|
+
sa.Column("name", sa.Text, nullable=False),
|
|
134
|
+
sa.Column("kind", sa.Text, nullable=False),
|
|
135
|
+
sa.Column("line_start", sa.Integer, nullable=True),
|
|
136
|
+
sa.Column("line_end", sa.Integer, nullable=True),
|
|
137
|
+
sa.Column("signature", sa.Text, nullable=True),
|
|
138
|
+
sa.Column("exported", sa.Boolean, nullable=False, server_default="false"),
|
|
139
|
+
sa.Column("metadata", JSONB, nullable=False, server_default="{}"),
|
|
140
|
+
)
|
|
141
|
+
op.create_index("idx_symbols_content_sha", "symbols", ["content_sha"])
|
|
142
|
+
op.create_index("idx_symbols_name", "symbols", ["name"])
|
|
143
|
+
|
|
144
|
+
op.create_table(
|
|
145
|
+
"dependencies",
|
|
146
|
+
sa.Column("id", UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), primary_key=True),
|
|
147
|
+
sa.Column("source_sha", sa.Text, sa.ForeignKey("file_contents.sha256"), nullable=False),
|
|
148
|
+
sa.Column("target_sha", sa.Text, sa.ForeignKey("file_contents.sha256"), nullable=False),
|
|
149
|
+
sa.Column("dep_type", sa.Text, nullable=False),
|
|
150
|
+
sa.Column("weight", sa.Float, nullable=False, server_default="1.0"),
|
|
151
|
+
sa.Column("metadata", JSONB, nullable=False, server_default="{}"),
|
|
152
|
+
)
|
|
153
|
+
op.create_index("idx_deps_source", "dependencies", ["source_sha"])
|
|
154
|
+
op.create_index("idx_deps_target", "dependencies", ["target_sha"])
|
|
155
|
+
|
|
156
|
+
# --- Jobs & webhooks ---
|
|
157
|
+
op.create_table(
|
|
158
|
+
"indexing_jobs",
|
|
159
|
+
sa.Column("id", UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), primary_key=True),
|
|
160
|
+
sa.Column("repo_id", UUID(as_uuid=True), sa.ForeignKey("repositories.id"), nullable=False),
|
|
161
|
+
sa.Column("job_type", sa.Text, nullable=False),
|
|
162
|
+
sa.Column("status", sa.Text, nullable=False, server_default="queued"),
|
|
163
|
+
sa.Column("branch_name", sa.Text, nullable=True),
|
|
164
|
+
sa.Column("progress", JSONB, nullable=False, server_default="{}"),
|
|
165
|
+
sa.Column("result", JSONB, nullable=True),
|
|
166
|
+
sa.Column("error", sa.Text, nullable=True),
|
|
167
|
+
sa.Column("started_at", sa.DateTime(timezone=True), nullable=True),
|
|
168
|
+
sa.Column("completed_at", sa.DateTime(timezone=True), nullable=True),
|
|
169
|
+
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
170
|
+
sa.Column("arq_job_id", sa.Text, nullable=True),
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
op.create_table(
|
|
174
|
+
"webhook_configs",
|
|
175
|
+
sa.Column("id", UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), primary_key=True),
|
|
176
|
+
sa.Column("repo_id", UUID(as_uuid=True), sa.ForeignKey("repositories.id"), nullable=False),
|
|
177
|
+
sa.Column("provider", sa.Text, nullable=False),
|
|
178
|
+
sa.Column("secret_hash", sa.Text, nullable=False),
|
|
179
|
+
sa.Column("events", ARRAY(sa.String), nullable=False, server_default="{push}"),
|
|
180
|
+
sa.Column("active", sa.Boolean, nullable=False, server_default="true"),
|
|
181
|
+
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
# --- RLS policies ---
|
|
185
|
+
op.execute("ALTER TABLE repositories ENABLE ROW LEVEL SECURITY")
|
|
186
|
+
op.execute("""
|
|
187
|
+
CREATE POLICY repo_org_isolation ON repositories
|
|
188
|
+
USING (org_id = current_setting('app.current_org_id', true)::UUID)
|
|
189
|
+
""")
|
|
190
|
+
op.execute("ALTER TABLE api_keys ENABLE ROW LEVEL SECURITY")
|
|
191
|
+
op.execute("""
|
|
192
|
+
CREATE POLICY apikey_org_isolation ON api_keys
|
|
193
|
+
USING (org_id = current_setting('app.current_org_id', true)::UUID)
|
|
194
|
+
""")
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def downgrade() -> None:
|
|
198
|
+
op.execute("DROP POLICY IF EXISTS apikey_org_isolation ON api_keys")
|
|
199
|
+
op.execute("ALTER TABLE api_keys DISABLE ROW LEVEL SECURITY")
|
|
200
|
+
op.execute("DROP POLICY IF EXISTS repo_org_isolation ON repositories")
|
|
201
|
+
op.execute("ALTER TABLE repositories DISABLE ROW LEVEL SECURITY")
|
|
202
|
+
|
|
203
|
+
op.drop_table("webhook_configs")
|
|
204
|
+
op.drop_table("indexing_jobs")
|
|
205
|
+
op.drop_index("idx_deps_target")
|
|
206
|
+
op.drop_index("idx_deps_source")
|
|
207
|
+
op.drop_table("dependencies")
|
|
208
|
+
op.drop_index("idx_symbols_name")
|
|
209
|
+
op.drop_index("idx_symbols_content_sha")
|
|
210
|
+
op.drop_table("symbols")
|
|
211
|
+
op.drop_table("branch_files")
|
|
212
|
+
op.drop_table("file_contents")
|
|
213
|
+
op.drop_table("branches")
|
|
214
|
+
op.drop_table("repo_credentials")
|
|
215
|
+
op.drop_table("repositories")
|
|
216
|
+
op.drop_table("api_keys")
|
|
217
|
+
op.drop_table("org_memberships")
|
|
218
|
+
op.drop_table("users")
|
|
219
|
+
op.drop_table("organizations")
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Add branch version counter, file_contents.content_type, and embeddings table.
|
|
2
|
+
|
|
3
|
+
Revision ID: 002
|
|
4
|
+
Revises: 001
|
|
5
|
+
Create Date: 2026-03-11
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
import sqlalchemy as sa
|
|
12
|
+
from alembic import op
|
|
13
|
+
from sqlalchemy.dialects.postgresql import UUID
|
|
14
|
+
|
|
15
|
+
revision: str = "002"
|
|
16
|
+
down_revision: Union[str, None] = "001"
|
|
17
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
18
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def upgrade() -> None:
|
|
22
|
+
# Branch version counter for consistency tracking
|
|
23
|
+
op.add_column(
|
|
24
|
+
"branches",
|
|
25
|
+
sa.Column("version", sa.Integer, nullable=False, server_default="0"),
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# Content type for future fractal summaries (source|summary_l1|summary_l2)
|
|
29
|
+
op.add_column(
|
|
30
|
+
"file_contents",
|
|
31
|
+
sa.Column("content_type", sa.Text, nullable=False, server_default="source"),
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# Embeddings table — content-SHA-keyed with model tracking
|
|
35
|
+
op.create_table(
|
|
36
|
+
"embeddings",
|
|
37
|
+
sa.Column("id", UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), primary_key=True),
|
|
38
|
+
sa.Column("content_sha", sa.Text, sa.ForeignKey("file_contents.sha256"), nullable=False),
|
|
39
|
+
sa.Column("embedding_model", sa.Text, nullable=False, server_default="default"),
|
|
40
|
+
sa.Column("chunk_text", sa.Text, nullable=False, server_default=""),
|
|
41
|
+
sa.Column("chunk_type", sa.Text, nullable=False, server_default="file"),
|
|
42
|
+
# vector column will be added when pgvector extension is enabled:
|
|
43
|
+
# sa.Column("vector", Vector(384)) # or Vector(1536) for OpenAI
|
|
44
|
+
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
45
|
+
)
|
|
46
|
+
op.create_index("idx_embeddings_content_sha", "embeddings", ["content_sha"])
|
|
47
|
+
op.create_index("idx_embeddings_model", "embeddings", ["embedding_model"])
|
|
48
|
+
op.create_index(
|
|
49
|
+
"idx_embeddings_content_model",
|
|
50
|
+
"embeddings",
|
|
51
|
+
["content_sha", "embedding_model"],
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def downgrade() -> None:
|
|
56
|
+
op.drop_index("idx_embeddings_content_model")
|
|
57
|
+
op.drop_index("idx_embeddings_model")
|
|
58
|
+
op.drop_index("idx_embeddings_content_sha")
|
|
59
|
+
op.drop_table("embeddings")
|
|
60
|
+
op.drop_column("file_contents", "content_type")
|
|
61
|
+
op.drop_column("branches", "version")
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Add unique constraint on embeddings and CASCADE on FK.
|
|
2
|
+
|
|
3
|
+
C6: Ensure one embedding per (content_sha, embedding_model, chunk_type).
|
|
4
|
+
N5: Add ON DELETE CASCADE to embeddings.content_sha FK.
|
|
5
|
+
|
|
6
|
+
Revision ID: 003
|
|
7
|
+
Revises: 002
|
|
8
|
+
Create Date: 2026-03-11
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from typing import Sequence, Union
|
|
13
|
+
|
|
14
|
+
from alembic import op
|
|
15
|
+
|
|
16
|
+
revision: str = "003"
|
|
17
|
+
down_revision: Union[str, None] = "002"
|
|
18
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
19
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def upgrade() -> None:
|
|
23
|
+
# C6: unique constraint on (content_sha, embedding_model, chunk_type)
|
|
24
|
+
op.create_unique_constraint(
|
|
25
|
+
"uq_embedding_content_model_chunk",
|
|
26
|
+
"embeddings",
|
|
27
|
+
["content_sha", "embedding_model", "chunk_type"],
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# N5: replace FK with CASCADE version
|
|
31
|
+
op.drop_constraint("embeddings_content_sha_fkey", "embeddings", type_="foreignkey")
|
|
32
|
+
op.create_foreign_key(
|
|
33
|
+
"embeddings_content_sha_fkey",
|
|
34
|
+
"embeddings",
|
|
35
|
+
"file_contents",
|
|
36
|
+
["content_sha"],
|
|
37
|
+
["sha256"],
|
|
38
|
+
ondelete="CASCADE",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def downgrade() -> None:
|
|
43
|
+
op.drop_constraint("embeddings_content_sha_fkey", "embeddings", type_="foreignkey")
|
|
44
|
+
op.create_foreign_key(
|
|
45
|
+
"embeddings_content_sha_fkey",
|
|
46
|
+
"embeddings",
|
|
47
|
+
"file_contents",
|
|
48
|
+
["content_sha"],
|
|
49
|
+
["sha256"],
|
|
50
|
+
)
|
|
51
|
+
op.drop_constraint("uq_embedding_content_model_chunk", "embeddings", type_="unique")
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Add audit_events table for activity feed / audit log.
|
|
2
|
+
|
|
3
|
+
Revision ID: 004
|
|
4
|
+
Revises: 003
|
|
5
|
+
Create Date: 2026-03-11
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
import sqlalchemy as sa
|
|
12
|
+
from alembic import op
|
|
13
|
+
|
|
14
|
+
revision: str = "004"
|
|
15
|
+
down_revision: Union[str, None] = "003"
|
|
16
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
17
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def upgrade() -> None:
|
|
21
|
+
op.create_table(
|
|
22
|
+
"audit_events",
|
|
23
|
+
sa.Column("id", sa.dialects.postgresql.UUID(as_uuid=True), primary_key=True, server_default=sa.text("gen_random_uuid()")),
|
|
24
|
+
sa.Column("org_id", sa.dialects.postgresql.UUID(as_uuid=True), sa.ForeignKey("organizations.id", ondelete="CASCADE"), nullable=False),
|
|
25
|
+
sa.Column("repo_id", sa.dialects.postgresql.UUID(as_uuid=True), sa.ForeignKey("repositories.id", ondelete="SET NULL"), nullable=True),
|
|
26
|
+
sa.Column("user_id", sa.dialects.postgresql.UUID(as_uuid=True), sa.ForeignKey("users.id", ondelete="SET NULL"), nullable=True),
|
|
27
|
+
sa.Column("event_type", sa.Text, nullable=False),
|
|
28
|
+
sa.Column("detail", sa.dialects.postgresql.JSONB, nullable=False, server_default="{}"),
|
|
29
|
+
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
30
|
+
)
|
|
31
|
+
op.create_index("ix_audit_events_org_created", "audit_events", ["org_id", sa.text("created_at DESC")])
|
|
32
|
+
op.create_index("ix_audit_events_repo_created", "audit_events", ["repo_id", sa.text("created_at DESC")])
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def downgrade() -> None:
|
|
36
|
+
op.drop_index("ix_audit_events_repo_created", "audit_events")
|
|
37
|
+
op.drop_index("ix_audit_events_org_created", "audit_events")
|
|
38
|
+
op.drop_table("audit_events")
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Add user_preferences table for UI settings.
|
|
2
|
+
|
|
3
|
+
Revision ID: 005
|
|
4
|
+
Revises: 004
|
|
5
|
+
Create Date: 2026-03-11
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
import sqlalchemy as sa
|
|
12
|
+
from alembic import op
|
|
13
|
+
|
|
14
|
+
revision: str = "005"
|
|
15
|
+
down_revision: Union[str, None] = "004"
|
|
16
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
17
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def upgrade() -> None:
|
|
21
|
+
op.create_table(
|
|
22
|
+
"user_preferences",
|
|
23
|
+
sa.Column("user_id", sa.dialects.postgresql.UUID(as_uuid=True), sa.ForeignKey("users.id", ondelete="CASCADE"), primary_key=True),
|
|
24
|
+
sa.Column("preferences", sa.dialects.postgresql.JSONB, nullable=False, server_default="{}"),
|
|
25
|
+
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now(), onupdate=sa.func.now(), nullable=False),
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def downgrade() -> None:
|
|
30
|
+
op.drop_table("user_preferences")
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Add google_id column to users table for Google OAuth.
|
|
2
|
+
|
|
3
|
+
Revision ID: 006
|
|
4
|
+
Revises: 005
|
|
5
|
+
Create Date: 2026-03-12
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
import sqlalchemy as sa
|
|
12
|
+
from alembic import op
|
|
13
|
+
|
|
14
|
+
revision: str = "006"
|
|
15
|
+
down_revision: Union[str, None] = "005"
|
|
16
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
17
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def upgrade() -> None:
|
|
21
|
+
op.add_column("users", sa.Column("google_id", sa.Text, nullable=True))
|
|
22
|
+
op.create_unique_constraint("uq_users_google_id", "users", ["google_id"])
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def downgrade() -> None:
|
|
26
|
+
op.drop_constraint("uq_users_google_id", "users")
|
|
27
|
+
op.drop_column("users", "google_id")
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Enable pgvector extension for embedding vector storage.
|
|
2
|
+
|
|
3
|
+
The vector column on the embeddings table is added at runtime by
|
|
4
|
+
ensure_vector_column() — dimension depends on the configured embedding model.
|
|
5
|
+
|
|
6
|
+
Revision ID: 007
|
|
7
|
+
Revises: 006
|
|
8
|
+
Create Date: 2026-03-12
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from typing import Sequence, Union
|
|
13
|
+
|
|
14
|
+
from alembic import op
|
|
15
|
+
|
|
16
|
+
revision: str = "007"
|
|
17
|
+
down_revision: Union[str, None] = "006"
|
|
18
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
19
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def upgrade() -> None:
|
|
23
|
+
op.execute("CREATE EXTENSION IF NOT EXISTS vector")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def downgrade() -> None:
|
|
27
|
+
# Don't DROP EXTENSION — other things might use it
|
|
28
|
+
pass
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Add symbol_references table for call-site / import reference tracking.
|
|
2
|
+
|
|
3
|
+
Revision ID: 008
|
|
4
|
+
Revises: 007
|
|
5
|
+
Create Date: 2026-03-13
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
import sqlalchemy as sa
|
|
12
|
+
from alembic import op
|
|
13
|
+
|
|
14
|
+
revision: str = "008"
|
|
15
|
+
down_revision: Union[str, None] = "007"
|
|
16
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
17
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def upgrade() -> None:
|
|
21
|
+
op.create_table(
|
|
22
|
+
"symbol_references",
|
|
23
|
+
sa.Column("id", sa.dialects.postgresql.UUID(as_uuid=True), primary_key=True, server_default=sa.text("gen_random_uuid()")),
|
|
24
|
+
sa.Column("content_sha", sa.Text, sa.ForeignKey("file_contents.sha256", ondelete="CASCADE"), nullable=False),
|
|
25
|
+
sa.Column("symbol_name", sa.String(500), nullable=False),
|
|
26
|
+
sa.Column("ref_kind", sa.String(20), nullable=False),
|
|
27
|
+
sa.Column("line", sa.Integer, nullable=False),
|
|
28
|
+
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
29
|
+
)
|
|
30
|
+
op.create_index("ix_symref_sha", "symbol_references", ["content_sha"])
|
|
31
|
+
op.create_index("ix_symref_name", "symbol_references", ["symbol_name"])
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def downgrade() -> None:
|
|
35
|
+
op.drop_index("ix_symref_name", "symbol_references")
|
|
36
|
+
op.drop_index("ix_symref_sha", "symbol_references")
|
|
37
|
+
op.drop_table("symbol_references")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Add encrypted secret column to webhook_configs.
|
|
2
|
+
|
|
3
|
+
Revision ID: 009
|
|
4
|
+
Revises: 008
|
|
5
|
+
Create Date: 2026-03-14
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
import sqlalchemy as sa
|
|
12
|
+
from alembic import op
|
|
13
|
+
|
|
14
|
+
revision: str = "009"
|
|
15
|
+
down_revision: Union[str, None] = "008"
|
|
16
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
17
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def upgrade() -> None:
|
|
21
|
+
op.add_column("webhook_configs", sa.Column("secret_encrypted", sa.Text(), nullable=True))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def downgrade() -> None:
|
|
25
|
+
op.drop_column("webhook_configs", "secret_encrypted")
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Add commits table for DB-backed commit history.
|
|
2
|
+
|
|
3
|
+
Revision ID: 010
|
|
4
|
+
Revises: 009
|
|
5
|
+
Create Date: 2026-03-15
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
import sqlalchemy as sa
|
|
12
|
+
from alembic import op
|
|
13
|
+
|
|
14
|
+
revision: str = "010"
|
|
15
|
+
down_revision: Union[str, None] = "009"
|
|
16
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
17
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def upgrade() -> None:
|
|
21
|
+
op.create_table(
|
|
22
|
+
"commits",
|
|
23
|
+
sa.Column("id", sa.dialects.postgresql.UUID(as_uuid=True), primary_key=True),
|
|
24
|
+
sa.Column("repo_id", sa.dialects.postgresql.UUID(as_uuid=True), sa.ForeignKey("repositories.id", ondelete="CASCADE"), nullable=False),
|
|
25
|
+
sa.Column("oid", sa.Text(), nullable=False),
|
|
26
|
+
sa.Column("message", sa.Text(), nullable=False),
|
|
27
|
+
sa.Column("author_name", sa.Text(), nullable=False),
|
|
28
|
+
sa.Column("author_email", sa.Text(), nullable=False),
|
|
29
|
+
sa.Column("timestamp", sa.BigInteger(), nullable=False),
|
|
30
|
+
sa.Column("parent_oids", sa.dialects.postgresql.ARRAY(sa.String()), nullable=False, server_default="{}"),
|
|
31
|
+
sa.Column("branch_name", sa.Text(), nullable=False, server_default="main"),
|
|
32
|
+
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
33
|
+
sa.UniqueConstraint("repo_id", "oid", name="uq_commits_repo_oid"),
|
|
34
|
+
)
|
|
35
|
+
op.create_index("ix_commits_repo_branch_ts", "commits", ["repo_id", "branch_name", sa.text("timestamp DESC")])
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def downgrade() -> None:
|
|
39
|
+
op.drop_index("ix_commits_repo_branch_ts", table_name="commits")
|
|
40
|
+
op.drop_table("commits")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Add changed_files JSONB column to commits table.
|
|
2
|
+
|
|
3
|
+
Revision ID: 011
|
|
4
|
+
Revises: 010
|
|
5
|
+
Create Date: 2026-03-15
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
import sqlalchemy as sa
|
|
12
|
+
from alembic import op
|
|
13
|
+
|
|
14
|
+
revision: str = "011"
|
|
15
|
+
down_revision: Union[str, None] = "010"
|
|
16
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
17
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def upgrade() -> None:
|
|
21
|
+
op.add_column("commits", sa.Column("changed_files", sa.dialects.postgresql.JSONB(), nullable=True))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def downgrade() -> None:
|
|
25
|
+
op.drop_column("commits", "changed_files")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Add merged_at column to branches table.
|
|
2
|
+
|
|
3
|
+
Revision ID: 012
|
|
4
|
+
Revises: 011
|
|
5
|
+
Create Date: 2026-03-15
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
import sqlalchemy as sa
|
|
12
|
+
from alembic import op
|
|
13
|
+
|
|
14
|
+
revision: str = "012"
|
|
15
|
+
down_revision: Union[str, None] = "011"
|
|
16
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
17
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def upgrade() -> None:
|
|
21
|
+
op.add_column("branches", sa.Column("merged_at", sa.DateTime(timezone=True), nullable=True))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def downgrade() -> None:
|
|
25
|
+
op.drop_column("branches", "merged_at")
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Add revoked_tokens table for JWT blocklist.
|
|
2
|
+
|
|
3
|
+
Revision ID: 013
|
|
4
|
+
Revises: 012
|
|
5
|
+
Create Date: 2026-03-15
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
import sqlalchemy as sa
|
|
12
|
+
from alembic import op
|
|
13
|
+
|
|
14
|
+
revision: str = "013"
|
|
15
|
+
down_revision: Union[str, None] = "012"
|
|
16
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
17
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def upgrade() -> None:
|
|
21
|
+
op.create_table(
|
|
22
|
+
"revoked_tokens",
|
|
23
|
+
sa.Column("jti", sa.Text(), primary_key=True),
|
|
24
|
+
sa.Column("revoked_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
|
25
|
+
sa.Column("expires_at", sa.DateTime(timezone=True), nullable=False),
|
|
26
|
+
)
|
|
27
|
+
op.create_index("ix_revoked_tokens_expires_at", "revoked_tokens", ["expires_at"])
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def downgrade() -> None:
|
|
31
|
+
op.drop_index("ix_revoked_tokens_expires_at", table_name="revoked_tokens")
|
|
32
|
+
op.drop_table("revoked_tokens")
|