CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
0068_doc_tracking.sql
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| d199847 | 1 | -- Gluecron migration 0068: AI-tracked documentation sections. |
| 2 | -- | |
| 3 | -- A markdown file (typically README.md) can contain regions delimited by | |
| 4 | -- HTML-comment markers like: | |
| 5 | -- | |
| 6 | -- <!-- gluecron:doc-track src=src/lib/auth.ts --> | |
| 7 | -- This module exports `signIn` and `signUp` — see the source for details. | |
| 8 | -- <!-- /gluecron:doc-track --> | |
| 9 | -- | |
| 10 | -- Each region tracks the live hash of the referenced source file. When the | |
| 11 | -- hash drifts, src/lib/ai-doc-updater.ts asks Claude to refresh the prose | |
| 12 | -- and opens a PR tagged `ai:doc-update`. | |
| 13 | -- | |
| 14 | -- This table stores the *currently claimed* hash so we can detect drift | |
| 15 | -- without re-reading every region on every push. The unique constraint on | |
| 16 | -- (repo, doc_path, section_marker) keeps one row per region; pushes UPSERT | |
| 17 | -- the latest content hash through it. | |
| 18 | -- | |
| 19 | -- Wrapped in DO blocks so the migration is safe to re-run and gracefully | |
| 20 | -- ignores missing parents on partial replays. The whole feature degrades | |
| 21 | -- to "no rows" when the table is missing, which is exactly what we want | |
| 22 | -- for environments that haven't migrated yet. | |
| 23 | ||
| 24 | --> statement-breakpoint | |
| 25 | DO $$ | |
| 26 | BEGIN | |
| 27 | CREATE TABLE IF NOT EXISTS "doc_tracking" ( | |
| 28 | "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), | |
| 29 | "repository_id" uuid NOT NULL REFERENCES "repositories"("id") ON DELETE CASCADE, | |
| 30 | "doc_path" text NOT NULL, | |
| 31 | "section_marker" text NOT NULL, | |
| 32 | "src_path" text NOT NULL, | |
| 33 | "claimed_hash" text NOT NULL, | |
| 34 | "last_checked_at" timestamptz NOT NULL DEFAULT now(), | |
| 35 | "last_pr_id" uuid REFERENCES "pull_requests"("id") ON DELETE SET NULL, | |
| 36 | "created_at" timestamptz NOT NULL DEFAULT now() | |
| 37 | ); | |
| 38 | EXCEPTION WHEN OTHERS THEN | |
| 39 | RAISE NOTICE 'doc_tracking create failed (%); ai-doc-updater will degrade to no-op', SQLERRM; | |
| 40 | END $$; | |
| 41 | ||
| 42 | --> statement-breakpoint | |
| 43 | DO $$ | |
| 44 | BEGIN | |
| 45 | CREATE UNIQUE INDEX IF NOT EXISTS "doc_tracking_repo_doc_marker" | |
| 46 | ON "doc_tracking" ("repository_id", "doc_path", "section_marker"); | |
| 47 | EXCEPTION WHEN OTHERS THEN | |
| 48 | RAISE NOTICE 'doc_tracking_repo_doc_marker index failed (%)', SQLERRM; | |
| 49 | END $$; | |
| 50 | ||
| 51 | --> statement-breakpoint | |
| 52 | DO $$ | |
| 53 | BEGIN | |
| 54 | CREATE INDEX IF NOT EXISTS "doc_tracking_repo" | |
| 55 | ON "doc_tracking" ("repository_id"); | |
| 56 | EXCEPTION WHEN OTHERS THEN | |
| 57 | RAISE NOTICE 'doc_tracking_repo index failed (%)', SQLERRM; | |
| 58 | END $$; |