Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
cd1705a
feat(jobs): embed job contracts, projection, record and queue envelope
aman-bhaskar-codes Nov 12, 2026
22af0cc
feat(jobs): JobService enqueue, claim, retry and recovery for embed jobs
aman-bhaskar-codes Nov 12, 2026
bcbeed6
feat(jobs): principal-bound embed job creation, status and cancel
aman-bhaskar-codes Nov 12, 2026
17e28ad
feat(workers): consume embed jobs with V7 envelope and mapped failure…
aman-bhaskar-codes Nov 12, 2026
65b9388
feat(index): dense index job over HTTP, worker composition and policy…
aman-bhaskar-codes Nov 12, 2026
94a1c3e
fix(jobs): lock the snapshot for recovery without the actor access check
aman-bhaskar-codes Nov 12, 2026
0b5f8fc
fix(jobs): privilege-aware recovery lock, named skip log and stricter…
aman-bhaskar-codes Nov 12, 2026
7139a61
feat(report): evidence-first architecture report and dependency graph…
aman-bhaskar-codes Nov 12, 2026
9d073df
feat(report): deterministic per-language import resolution and depend…
aman-bhaskar-codes Nov 12, 2026
2cbfb25
fix(report): resolver corrections found by the real-repository calibr…
aman-bhaskar-codes Nov 12, 2026
d13a2f4
feat(report): deterministic graph analytics (cycles, hubs, components…
aman-bhaskar-codes Nov 12, 2026
b90c333
feat(report): evidence-first report assembly with Markdown and graph …
aman-bhaskar-codes Nov 12, 2026
1be8aab
fix(report): unambiguous-only Python resolution found by the Flask co…
aman-bhaskar-codes Nov 12, 2026
9ea0101
feat(report): deterministic fact-analysis shard planner
aman-bhaskar-codes Nov 13, 2026
1932681
feat(report): shard coordinator, immutable report table and service
aman-bhaskar-codes Nov 13, 2026
3ac7110
feat(report): architecture report routes, OpenAPI and SDK
aman-bhaskar-codes Nov 13, 2026
1e69f1c
feat(report): report viewer, templates route and ADR 0006
aman-bhaskar-codes Nov 13, 2026
4ad027c
feat(report): corpus evaluation with measured floors and acceptance r…
aman-bhaskar-codes Nov 13, 2026
675474a
fix(report): scope shard keys to the snapshot, bound inputs, redact h…
aman-bhaskar-codes Nov 13, 2026
e4c25dd
feat(report): retry failed or cancelled shard analyses through prepare
aman-bhaskar-codes Nov 13, 2026
632fd18
feat(facts): record Rust mod declarations as file dependencies
aman-bhaskar-codes Nov 13, 2026
13e0afd
feat(report): Rust integration tests, examples and benches are crate …
aman-bhaskar-codes Nov 13, 2026
cf8291a
perf(report): cache component grouping across graph pages
aman-bhaskar-codes Nov 13, 2026
8b89e98
feat(report): read package manifests as name-only facts and use them …
aman-bhaskar-codes Nov 13, 2026
04be706
feat(admission): policy source-zip-v4 admits go.mod as a manifest
aman-bhaskar-codes Nov 13, 2026
4388460
eval: measure the corpus under admission policy v4
aman-bhaskar-codes Nov 13, 2026
c3d7d8a
fix(report): count bounds decide analytics; wall clock is only a safe…
aman-bhaskar-codes Nov 13, 2026
be2b608
fix(recovery): a lost scope no longer aborts the sweep; queued cleanu…
aman-bhaskar-codes Nov 13, 2026
bb67fb0
feat(report): orphan files and declared-but-unobserved dependencies a…
aman-bhaskar-codes Nov 13, 2026
2a3be55
fix(facts): review fixes for manifest parsing, digests, Package.swift…
aman-bhaskar-codes Nov 13, 2026
1015e40
feat(report): architecture rules (forbidden, layers, independence) ch…
aman-bhaskar-codes Nov 13, 2026
7e30371
docs: architecture rules acceptance notes
aman-bhaskar-codes Nov 13, 2026
93531ec
eval: greedy modularity clustering prototype with corpus comparison (…
aman-bhaskar-codes Nov 13, 2026
c4e4665
docs: correct clustering comparison wording
aman-bhaskar-codes Nov 13, 2026
abe73a9
feat(ui): architecture rule checks panel with prefix suggestions and …
aman-bhaskar-codes Nov 13, 2026
05d65ea
feat(ui): VS Code-style workbench shell (title bar, activity bar, exp…
aman-bhaskar-codes Nov 13, 2026
7a5d1b9
feat(ui): resizable explorer, persisted layout, Ctrl+B and F6 part na…
aman-bhaskar-codes Nov 13, 2026
a2915fc
feat(ui): explorer file tree and read-only source editor pane
aman-bhaskar-codes Nov 13, 2026
e3f5050
feat(ui): editor tab strip for visited views and open files (keyboard…
aman-bhaskar-codes Nov 13, 2026
4d9ae35
feat(ui): bottom panel (Problems, Output), status bar actions, Ctrl+J
aman-bhaskar-codes Nov 13, 2026
1cac764
feat(ui): command palette (Ctrl+Shift+P, F1) with fuzzy search and sh…
aman-bhaskar-codes Nov 13, 2026
26c68a8
test(ui): rule checks component and workbench integration tests; acce…
aman-bhaskar-codes Nov 13, 2026
de701fe
feat(ui): workbench e2e coverage, narrow-width fixes, UX contract and…
aman-bhaskar-codes Nov 13, 2026
098100b
fix(lint): use raw string for regex match in architecture report test
aman-bhaskar-codes Nov 13, 2026
ed968ce
docs: ADR 0007 report narrative decisions and probed constraint names
aman-bhaskar-codes Nov 13, 2026
72e8f2b
feat(investigations): report narrative mode, report-pinned specs, rep…
aman-bhaskar-codes Nov 13, 2026
f77410e
feat(investigations): read_report_section tool with report_fact recei…
aman-bhaskar-codes Nov 13, 2026
7773872
feat(investigations): deterministic narrative verifier over delivered…
aman-bhaskar-codes Nov 13, 2026
afa333d
feat(agents): versioned report narrative prompts, boundary markers an…
aman-bhaskar-codes Nov 13, 2026
9515fb5
feat(investigations): report narrative executor mode with per-page na…
aman-bhaskar-codes Nov 13, 2026
219e0f0
feat(investigations): publish a narrative into the report link table …
aman-bhaskar-codes Nov 13, 2026
d7ce450
feat(report): narrative read route, start flow and viewer in the work…
aman-bhaskar-codes Nov 13, 2026
f8c9b73
feat(report): owner-run narrative smoke script, shared page builder a…
aman-bhaskar-codes Nov 13, 2026
19d1c8a
fix(report): review fixes for narrative (re-runs, viewer polling, str…
aman-bhaskar-codes Nov 13, 2026
7c86c05
chore(merge): bring architecture-report up to date with main
aman-bhaskar-codes Nov 13, 2026
11f6da2
fix(lint): suppress BLE001, remove unused noqa, sort imports
aman-bhaskar-codes Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions UX-CONTRACT.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Do not expose credentials, raw provider payloads or source-bearing diagnostics.
| ----------------------------- | -------------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------------- | --------------------------------------------------------- |
| Appearance | `frontend/src/theme/ThemeProvider.tsx` | `frontend/src/styles/tokens.css` | Dark default, light; storage optional | Theme component and browser tests |
| Workspace chrome | `frontend/src/workspace/WorkspaceShell.tsx` | This navigation contract | Enabled links or explained unavailable destinations | Shell component and browser tests |
| Workbench layout | `frontend/src/workspace/useWorkbenchLayout.ts` | Persisted explorer width, panel size and visibility | Explorer 160-480 px, panel 80-480 px; storage optional | Layout, splitter and workbench browser tests |
| Editor tabs | `frontend/src/workspace/EditorTabs.tsx` | Visited views and open files; the URL hash decides | Views and read-only source files; Delete closes a tab | Tab component and browser tests |
| Command palette | `frontend/src/workspace/CommandPalette.tsx` | `commands.ts` plus commands passed to the shell | Ctrl/Cmd+Shift+P or F1; never opens inside other dialogs | Palette component and browser tests |
| Explorer and source | `frontend/src/features/explorer`, `features/source` | Snapshot inventory; redacted source-view contract | Read-only; partial listings are disclosed | Tree, source and browser tests |
| Selection restoration | `frontend/src/App.tsx` | Validated URL identifiers; backend authority | Repository, snapshot, submission, job, scan | App restoration and browser tests |
| Buttons | `frontend/src/ui/Button.tsx` | `DESIGN.md` | Neutral, primary, danger; pending | Button component tests |
| Panels | `frontend/src/ui/Panel.tsx` | `DESIGN.md` | Labelled section, optional actions | Browser checks of session recovery |
Expand Down Expand Up @@ -53,8 +57,8 @@ URL parameters. Browser history restores those selections and resets inventory
pagination; section navigation preserves local form input. The home link targets
the mounted overview rather than reloading the application. URLs never contain
source, questions or memory text. Backend authorization remains authoritative.
Browser navigation alone must not cancel durable jobs. Pane links use validated hashes; dedicated repository paths and resizable panels
are not implemented. Saved investigation and finding/run identifiers also restore
Browser navigation alone must not cancel durable jobs. Pane links use validated hashes; dedicated repository paths are not
implemented. The workbench's only resizable parts are the explorer and the bottom panel (separators with keyboard resizing). Saved investigation and finding/run identifiers also restore
from the URL, scoped to the selected repository and snapshot.

## Interaction and failure
Expand Down
87 changes: 87 additions & 0 deletions backend/alembic/versions/0048_architecture_reports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# ruff: noqa: E501
"""Immutable architecture reports derived from published AST facts.

A report is a pure function of the fact runs it names. The insert guard requires every named run to
be a published AST-facts analysis of the same snapshot, no file in two runs, and the stored inputs
digest to equal the digest recomputed from the facts rows, so a report cannot cite facts that do
not exist or silently change its inputs. Rows are never updated or deleted.
"""

from alembic import op

revision = "0048_architecture_reports"
down_revision = "0047_recovery_snapshot_lock"
branch_labels = None
depends_on = None

UP = r"""
SET LOCAL lock_timeout='5s';
CREATE TABLE public.architecture_reports (
org_id uuid NOT NULL,id uuid NOT NULL,repository_id uuid NOT NULL,snapshot_id uuid NOT NULL,
principal_id uuid NOT NULL,schema_version integer NOT NULL,
inputs_digest text NOT NULL,report_digest text NOT NULL,
fact_runs jsonb NOT NULL,report_json jsonb NOT NULL,size_bytes integer NOT NULL,
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
PRIMARY KEY(org_id,id),
UNIQUE(org_id,repository_id,snapshot_id,inputs_digest),
FOREIGN KEY(org_id,repository_id,snapshot_id) REFERENCES public.source_snapshots(org_id,repository_id,id),
FOREIGN KEY(org_id,principal_id) REFERENCES public.memberships(org_id,principal_id),
CHECK(schema_version=1),
CHECK(inputs_digest ~ '^[0-9a-f]{64}$' AND report_digest ~ '^[0-9a-f]{64}$'),
CHECK(jsonb_typeof(fact_runs)='array' AND jsonb_array_length(fact_runs) BETWEEN 1 AND 64),
CHECK(jsonb_typeof(report_json)='object' AND size_bytes BETWEEN 2 AND 8388608
AND octet_length(report_json::text)<=8388608+65536)
);
CREATE INDEX ix_architecture_reports_history ON public.architecture_reports(org_id,repository_id,snapshot_id,created_at,id);
CREATE TRIGGER guard_architecture_report_immutable BEFORE UPDATE OR DELETE ON public.architecture_reports
FOR EACH ROW EXECUTE FUNCTION public.codespy_reject_mutation();
CREATE FUNCTION public.codespy_architecture_report_guard() RETURNS trigger LANGUAGE plpgsql SECURITY INVOKER AS $$
DECLARE n integer; total integer; files integer; distinct_files integer; recomputed text;
BEGIN
SELECT count(*) INTO n FROM jsonb_array_elements_text(NEW.fact_runs) r
JOIN public.analysis_runs a ON a.org_id=NEW.org_id AND a.snapshot_id=NEW.snapshot_id AND a.id=r::uuid
AND a.status IN ('completed','partial') AND (a.config->'adapters') ? 'ast_facts';
SELECT count(DISTINCT r) INTO total FROM jsonb_array_elements_text(NEW.fact_runs) r;
IF n<>jsonb_array_length(NEW.fact_runs) OR total<>jsonb_array_length(NEW.fact_runs) THEN
RAISE EXCEPTION 'architecture report input differs' USING ERRCODE='23514'; END IF;
SELECT count(*),count(DISTINCT f.file_id) INTO files,distinct_files FROM public.ast_file_facts f
WHERE f.org_id=NEW.org_id AND f.snapshot_id=NEW.snapshot_id
AND f.run_id IN (SELECT r::uuid FROM jsonb_array_elements_text(NEW.fact_runs) r);
IF files=0 OR files<>distinct_files THEN
RAISE EXCEPTION 'architecture report facts overlap or are missing' USING ERRCODE='23514'; END IF;
recomputed:=encode(sha256(convert_to(
(SELECT string_agg(r,E'\n' ORDER BY r COLLATE "C") FROM jsonb_array_elements_text(NEW.fact_runs) r)||E'\n'||
(SELECT string_agg(f.facts_sha256,E'\n' ORDER BY f.facts_sha256 COLLATE "C") FROM public.ast_file_facts f
WHERE f.org_id=NEW.org_id AND f.snapshot_id=NEW.snapshot_id
AND f.run_id IN (SELECT r::uuid FROM jsonb_array_elements_text(NEW.fact_runs) r)),'UTF8')),'hex');
IF recomputed<>NEW.inputs_digest OR NEW.report_json->>'inputs_digest' IS DISTINCT FROM NEW.inputs_digest
OR NEW.report_json->>'org_id' IS DISTINCT FROM NEW.org_id::text
OR NEW.report_json->>'repository_id' IS DISTINCT FROM NEW.repository_id::text
OR NEW.report_json->>'snapshot_id' IS DISTINCT FROM NEW.snapshot_id::text
OR (NEW.report_json->>'schema_version')::integer IS DISTINCT FROM NEW.schema_version
OR NEW.report_json->'coverage'->'fact_runs' IS DISTINCT FROM NEW.fact_runs
THEN RAISE EXCEPTION 'architecture report identity differs' USING ERRCODE='23514'; END IF;
RETURN NEW;
END $$;
CREATE TRIGGER guard_architecture_report BEFORE INSERT ON public.architecture_reports
FOR EACH ROW EXECUTE FUNCTION public.codespy_architecture_report_guard();
REVOKE ALL ON FUNCTION public.codespy_architecture_report_guard() FROM PUBLIC;
"""

DOWN = r"""
SET LOCAL lock_timeout='5s';
DO $$ BEGIN
IF EXISTS(SELECT 1 FROM public.architecture_reports) THEN
RAISE EXCEPTION 'architecture report history must be preserved' USING ERRCODE='23514'; END IF;
END $$;
DROP TABLE public.architecture_reports;
DROP FUNCTION public.codespy_architecture_report_guard();
"""


def upgrade() -> None:
op.execute(UP)


def downgrade() -> None:
op.execute(DOWN)
162 changes: 162 additions & 0 deletions backend/alembic/versions/0049_report_narrative.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# ruff: noqa: E501
"""Report narrative: a synthetic investigation pinned to one stored architecture report.

Widens the investigation mode and target, pins a spec to a report (id and digest), lets an evidence row
describe a report statement instead of a source range (a strict per-type CHECK keeps rows either fully
source-bound or fully report-bound), and records which narrative describes which report in an immutable,
guarded link table. Existing rows, hashes and constraints keep their meaning.
"""

from alembic import op

revision = "0049_report_narrative"
down_revision = "0048_architecture_reports"
branch_labels = None
depends_on = None

UP = r"""
SET LOCAL lock_timeout='5s';

ALTER TABLE public.investigations DROP CONSTRAINT ck_investigation_mode;
ALTER TABLE public.investigations ADD CONSTRAINT ck_investigation_mode
CHECK (mode IN ('short_path','two_specialist','report_narrative'));
ALTER TABLE public.investigations DROP CONSTRAINT ck_investigation_target_type;
ALTER TABLE public.investigations ADD CONSTRAINT ck_investigation_target_type
CHECK (target_type IN ('finding','repository','commit','diff','architecture_report'));

ALTER TABLE public.investigation_specs DROP CONSTRAINT investigation_specs_mode_check;
ALTER TABLE public.investigation_specs ADD CONSTRAINT investigation_specs_mode_check
CHECK (mode IN ('short_path','two_specialist','report_narrative'));
ALTER TABLE public.investigation_specs DROP CONSTRAINT investigation_specs_target_type_check;
ALTER TABLE public.investigation_specs ADD CONSTRAINT investigation_specs_target_type_check
CHECK (target_type IN ('repository','finding','architecture_report'));
ALTER TABLE public.investigation_specs
ADD COLUMN architecture_report_id uuid,
ADD COLUMN architecture_report_digest text;
ALTER TABLE public.investigation_specs
ADD CONSTRAINT fk_investigation_spec_report FOREIGN KEY(org_id,architecture_report_id)
REFERENCES public.architecture_reports(org_id,id),
ADD CONSTRAINT ck_investigation_spec_report_pin CHECK (
(architecture_report_id IS NULL) = (architecture_report_digest IS NULL)
AND (architecture_report_id IS NOT NULL) = (mode='report_narrative')
AND (architecture_report_id IS NOT NULL) = (target_type='architecture_report')
AND (architecture_report_digest IS NULL OR architecture_report_digest ~ '^[0-9a-f]{64}$'));

ALTER TABLE public.investigation_evidence
ALTER COLUMN source_path DROP NOT NULL,
ALTER COLUMN file_sha256 DROP NOT NULL,
ALTER COLUMN original_start_line DROP NOT NULL,
ALTER COLUMN original_end_line DROP NOT NULL,
ALTER COLUMN safe_start_line DROP NOT NULL,
ALTER COLUMN safe_end_line DROP NOT NULL,
ADD COLUMN fact_ref text,
ADD CONSTRAINT ck_evidence_fact_ref_bytes CHECK (fact_ref IS NULL OR octet_length(fact_ref) BETWEEN 1 AND 256),
ADD CONSTRAINT ck_evidence_source_or_fact CHECK (
(observation_type='report_fact' AND fact_ref IS NOT NULL AND source_path IS NULL AND file_sha256 IS NULL
AND original_start_line IS NULL AND original_end_line IS NULL AND safe_start_line IS NULL AND safe_end_line IS NULL)
OR (observation_type<>'report_fact' AND fact_ref IS NULL AND source_path IS NOT NULL AND file_sha256 IS NOT NULL
AND original_start_line IS NOT NULL AND original_end_line IS NOT NULL
AND safe_start_line IS NOT NULL AND safe_end_line IS NOT NULL));

CREATE TABLE public.architecture_report_narratives (
org_id uuid NOT NULL,id uuid NOT NULL,
architecture_report_id uuid NOT NULL,repository_id uuid NOT NULL,snapshot_id uuid NOT NULL,
investigation_id uuid NOT NULL,investigation_report_id uuid NOT NULL,
spec_hash text NOT NULL,report_digest text NOT NULL,narrative_json jsonb NOT NULL,
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
PRIMARY KEY(org_id,id),
UNIQUE(org_id,investigation_report_id),
FOREIGN KEY(org_id,architecture_report_id) REFERENCES public.architecture_reports(org_id,id),
FOREIGN KEY(org_id,investigation_id) REFERENCES public.investigations(org_id,id),
FOREIGN KEY(org_id,investigation_report_id) REFERENCES public.investigation_reports(org_id,id),
CHECK(spec_hash ~ '^[0-9a-f]{64}$' AND report_digest ~ '^[0-9a-f]{64}$'),
CHECK(jsonb_typeof(narrative_json)='object' AND octet_length(narrative_json::text)<=262144)
);
CREATE INDEX ix_report_narratives_report ON public.architecture_report_narratives(org_id,architecture_report_id,created_at,id);
CREATE TRIGGER guard_report_narrative_immutable BEFORE UPDATE OR DELETE ON public.architecture_report_narratives
FOR EACH ROW EXECUTE FUNCTION public.codespy_reject_mutation();
CREATE FUNCTION public.codespy_report_narrative_guard() RETURNS trigger LANGUAGE plpgsql SECURITY INVOKER AS $$
DECLARE ok integer;
BEGIN
SELECT count(*) INTO ok
FROM public.investigation_specs s
JOIN public.architecture_reports r ON r.org_id=s.org_id AND r.id=s.architecture_report_id
JOIN public.investigation_reports ir ON ir.org_id=s.org_id AND ir.spec_hash=s.spec_hash
WHERE s.org_id=NEW.org_id AND s.spec_hash=NEW.spec_hash AND s.mode='report_narrative'
AND s.architecture_report_id=NEW.architecture_report_id AND s.architecture_report_digest=NEW.report_digest
AND r.report_digest=NEW.report_digest
AND r.repository_id=NEW.repository_id AND r.snapshot_id=NEW.snapshot_id
AND s.repository_id=NEW.repository_id AND s.snapshot_id=NEW.snapshot_id
AND ir.id=NEW.investigation_report_id AND ir.investigation_id=NEW.investigation_id;
IF ok<>1 THEN
RAISE EXCEPTION 'report narrative differs from its report, spec or published investigation' USING ERRCODE='23514'; END IF;
RETURN NEW;
END $$;
CREATE TRIGGER guard_report_narrative BEFORE INSERT ON public.architecture_report_narratives
FOR EACH ROW EXECUTE FUNCTION public.codespy_report_narrative_guard();
REVOKE ALL ON FUNCTION public.codespy_report_narrative_guard() FROM PUBLIC;

DO $$ BEGIN
IF EXISTS(SELECT 1 FROM pg_roles WHERE rolname='p2_api') THEN
GRANT SELECT ON public.architecture_reports, public.architecture_report_narratives TO p2_api;
END IF;
IF EXISTS(SELECT 1 FROM pg_roles WHERE rolname='p2_broker') THEN
GRANT SELECT ON public.architecture_reports, public.architecture_report_narratives TO p2_broker;
GRANT INSERT ON public.architecture_report_narratives TO p2_broker;
END IF;
IF EXISTS(SELECT 1 FROM pg_roles WHERE rolname='p2_operator') THEN
GRANT SELECT ON public.architecture_report_narratives TO p2_operator;
END IF;
IF EXISTS(SELECT 1 FROM pg_roles WHERE rolname='codespy_app') THEN
GRANT SELECT, INSERT ON public.architecture_report_narratives TO codespy_app;
END IF;
END $$;
"""

DOWN = r"""
SET LOCAL lock_timeout='5s';
DO $$ BEGIN
IF EXISTS(SELECT 1 FROM public.architecture_report_narratives)
OR EXISTS(SELECT 1 FROM public.investigation_specs WHERE mode='report_narrative' OR target_type='architecture_report')
OR EXISTS(SELECT 1 FROM public.investigations WHERE mode='report_narrative' OR target_type='architecture_report')
OR EXISTS(SELECT 1 FROM public.investigation_evidence WHERE observation_type='report_fact') THEN
RAISE EXCEPTION 'report narrative history must be preserved' USING ERRCODE='23514'; END IF;
END $$;
DROP TABLE public.architecture_report_narratives;
DROP FUNCTION public.codespy_report_narrative_guard();
ALTER TABLE public.investigation_evidence
DROP CONSTRAINT ck_evidence_source_or_fact,
DROP CONSTRAINT ck_evidence_fact_ref_bytes,
DROP COLUMN fact_ref,
ALTER COLUMN source_path SET NOT NULL,
ALTER COLUMN file_sha256 SET NOT NULL,
ALTER COLUMN original_start_line SET NOT NULL,
ALTER COLUMN original_end_line SET NOT NULL,
ALTER COLUMN safe_start_line SET NOT NULL,
ALTER COLUMN safe_end_line SET NOT NULL;
ALTER TABLE public.investigation_specs
DROP CONSTRAINT ck_investigation_spec_report_pin,
DROP CONSTRAINT fk_investigation_spec_report,
DROP COLUMN architecture_report_digest,
DROP COLUMN architecture_report_id;
ALTER TABLE public.investigation_specs DROP CONSTRAINT investigation_specs_target_type_check;
ALTER TABLE public.investigation_specs ADD CONSTRAINT investigation_specs_target_type_check
CHECK (target_type IN ('repository','finding'));
ALTER TABLE public.investigation_specs DROP CONSTRAINT investigation_specs_mode_check;
ALTER TABLE public.investigation_specs ADD CONSTRAINT investigation_specs_mode_check
CHECK (mode IN ('short_path','two_specialist'));
ALTER TABLE public.investigations DROP CONSTRAINT ck_investigation_target_type;
ALTER TABLE public.investigations ADD CONSTRAINT ck_investigation_target_type
CHECK (target_type IN ('finding','repository','commit','diff'));
ALTER TABLE public.investigations DROP CONSTRAINT ck_investigation_mode;
ALTER TABLE public.investigations ADD CONSTRAINT ck_investigation_mode
CHECK (mode IN ('short_path','two_specialist'));
"""


def upgrade() -> None:
op.execute(UP)


def downgrade() -> None:
op.execute(DOWN)
11 changes: 8 additions & 3 deletions backend/app/admission/zip_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
AdmissionPolicy,
AdmissionPolicyV2,
AdmissionPolicyV3,
AdmissionPolicyV4,
ArtifactManifestV1,
ManifestEntryV1,
Reason,
Expand Down Expand Up @@ -224,14 +225,18 @@ def inspect_zip_bytes(
path = PurePosixPath(name)
parts = {x.casefold() for x in path.parts}
language = (
EXTENDED_LANGUAGES if isinstance(policy, AdmissionPolicyV3) else LANGUAGES
EXTENDED_LANGUAGES
if isinstance(policy, (AdmissionPolicyV3, AdmissionPolicyV4))
else LANGUAGES
).get(path.suffix.casefold())
lock_metadata = (
isinstance(policy, (AdmissionPolicyV2, AdmissionPolicyV3))
isinstance(policy, (AdmissionPolicyV2, AdmissionPolicyV3, AdmissionPolicyV4))
and path.name == "uv.lock"
)
if lock_metadata:
language = "toml"
if isinstance(policy, AdmissionPolicyV4) and path.name == "go.mod":
language = "gomod"
reason: Reason | None = None
if path.name.casefold() in {
".env",
Expand All @@ -245,7 +250,7 @@ def inspect_zip_bytes(
elif path.suffix.casefold() in {".zip", ".tar", ".gz", ".asar", ".jar"}:
reason = "nested_archive"
elif size > policy.eligible_file_bytes or (
isinstance(policy, (AdmissionPolicyV2, AdmissionPolicyV3))
isinstance(policy, (AdmissionPolicyV2, AdmissionPolicyV3, AdmissionPolicyV4))
and lock_metadata
and size > policy.metadata_file_bytes
):
Expand Down
1 change: 1 addition & 0 deletions backend/app/agents/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Agent assets that are not services: versioned prompts and their loader."""
Loading
Loading