Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f4c314d
feat(librarian): Module C retrieval upgrades (stack base for #1088)
northdpole Sep 29, 2026
8368601
Address review feedback on OIE librarian base.
northdpole Oct 5, 2026
70af687
feat(harvester): requirement extract and GitHub URL ingest
northdpole Sep 29, 2026
583e987
feat(oie): B2 eval harness and CRE neighborhood scorer
northdpole Sep 29, 2026
7fe303e
feat(librarian): LLM SafetyGuard for C.4 adversarial / update flags
northdpole Oct 7, 2026
62d0c4b
Address review feedback on harvester and GitHub URL ingest.
northdpole Oct 5, 2026
25f07e1
Address review feedback on B2 harness scripts.
northdpole Oct 5, 2026
955528d
chore(oie): ASVS 5.0 provisional B2 sources and gold
northdpole Sep 29, 2026
86d320a
chore(oie): NIST 800-53 and remaining B2 sources/gold
northdpole Sep 29, 2026
62cedd4
feat(mappings): promote Related-orphan remaps into canonical fixtures
northdpole Sep 29, 2026
e83b169
feat(oie): full-pipeline runner, docs, and experimental-flag notes
northdpole Sep 29, 2026
0b797a5
feat(librarian): promote d1-winner combo defaults (judge+cap8+top_k=3)
northdpole Sep 30, 2026
44dc468
chore(oie): trim #1088 for the staging rollout
northdpole Nov 1, 2026
692bc35
Merge remote-tracking branch 'origin/wip/oie-pipeline-eval-harness' i…
northdpole Nov 1, 2026
4074ac7
chore(harvester): trim #1115 for the staging rollout
northdpole Nov 1, 2026
1524c9f
Merge branch 'trim/1115' into trim/1116
northdpole Nov 1, 2026
f694b1c
chore(oie): trim #1116 and guard destructive eval scripts
northdpole Nov 1, 2026
71b6abd
Merge branch 'trim/1116' into trim/1117
northdpole Nov 1, 2026
866b86f
chore(oie): trim #1117 for the staging rollout
northdpole Nov 1, 2026
abe9547
Merge branch 'trim/1117' into trim/1118
northdpole Nov 1, 2026
fb4c782
chore(oie): trim #1118 for the staging rollout
northdpole Nov 1, 2026
adac09b
Merge branch 'trim/1118' into trim/1119
northdpole Nov 1, 2026
1a7c875
Merge branch 'trim/1119' into trim/1120
northdpole Nov 1, 2026
98d5c50
style: black-format llm_safety_guard.py
northdpole Nov 1, 2026
287cc1d
trim(#1120): fix merge-conflict markers, guard full pipeline, drop de…
northdpole Nov 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 13 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,25 @@ GOOGLE_CLIENT_SECRET=your-client-secret
GOOGLE_SECRET_JSON=path/to/secret.json
LOGIN_ALLOWED_DOMAINS=example.com

# GCP
# GCP / Gemini (optional — any LiteLLM provider works for Module B)

GCP_NATIVE=false
GEMINI_API_KEY=your-gemini-api-key
VERTEX_CHAT_MODEL=gemini-2.5-flash
VERTEX_EMBED_CONTENT_MODEL=gemini-embedding-001

# Noise / Relevance Filter (Module B)
# Other chat providers (LiteLLM). Set the key that matches CRE_NOISE_FILTER_LLM_MODEL.
# OPENAI_API_KEY=sk-...
# ANTHROPIC_API_KEY=sk-ant-...
# GROQ_API_KEY=gsk_...
# MISTRAL_API_KEY=...
# OPENROUTER_API_KEY=...

# Noise / Relevance Filter (Module B) — LiteLLM model id (provider/model)
# Examples: gemini/gemini-2.5-flash-lite | openai/gpt-4o-mini |
# anthropic/claude-haiku-4-5 | groq/llama-3.3-70b-versatile
# Any chat model LiteLLM supports; mid-size models usually work best
# (cheap + reliable for this classify gate — avoid tiny completion stubs).

CRE_NOISE_FILTER_LLM_MODEL=gemini/gemini-2.5-flash-lite
CRE_NOISE_FILTER_BATCH_SIZE=10
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ standards_cache.sqlite
!docs/gsoc_2026_module_b/module_c_contract.md
!docs/gsoc_2026_module_b/module_b_runbook.md
!docs/gsoc_2026_module_b/final_metrics.md
!docs/oie/*.md
!scripts/oie_owasp_eval/experiments/*.md

### Dev DBDumps
*.sql
Expand Down
24 changes: 22 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@ install-python:
make install-deps-python &&\
playwright install # Python embeddings/scraping (prompt_client); NOT frontend e2e — keep when migrating to Cypress

install-typescript:
yarn add webpack && cd application/frontend && yarn build
# Yarn install only. Do not `yarn add` or `yarn build` here: webpack is
# already in package.json, and a local build rewrites
# application/frontend/www/bundle.js (tracked so Heroku can serve the UI
# without a Node compile step). That was dirtying contributor trees after
# `make install`. Rebuild with `make frontend` when you change the UI.
install-typescript: install-deps-typescript

install: install-typescript install-python migrate-upgrade

Expand Down Expand Up @@ -185,6 +189,22 @@ oie-pipeline:
[ -d "./venv" ] && . ./venv/bin/activate &&\
PYTHONPATH=. python scripts/run_oie_pipeline.py --cache_file "$(or $(CACHE_FILE),sqlite:///$(CURDIR)/standards_cache.sqlite)" $(OIE_ARGS)

# Deterministic OIE base metadata (Node then CRE document_metadata.oie). Fill-if-missing.
# Example:
# make oie-tag-base CACHE_FILE=postgresql://cre:password@127.0.0.1:5432/cre_prodclone
oie-tag-base:
[ -d "./venv" ] && . ./venv/bin/activate &&\
PYTHONPATH=. python scripts/oie_ensure_base_metadata.py \
--cache-file "$(or $(CACHE_FILE),$(or $(DEV_DATABASE_URL),postgresql://cre:password@127.0.0.1:5432/cre))" \
$(OIE_TAG_ARGS)

# Local OIE bootstrap: start cre-postgres, migrate, sync CRE hub (local|upstream).
# Examples:
# make setup-oie
# make setup-oie SETUP_OIE_ARGS='--source upstream --install-ml --calibrate'
setup-oie:
bash ./scripts/setup_oie.sh $(SETUP_OIE_ARGS)

oie-e2e-smoke:
[ -d "./venv" ] && . ./venv/bin/activate &&\
PYTHONPATH=. python scripts/run_oie_e2e_smoke.py
Expand Down
21 changes: 14 additions & 7 deletions application/prompt_client/litellm_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@

from __future__ import annotations

from cre_logging import get_logger

logger = get_logger(__name__)

import logging
import os
import time
from typing import Any, Callable, List, Optional, Sequence

from application.prompt_client.llm_error_utils import is_rate_limit_error
from application.prompt_client.llm_error_utils import (
is_rate_limit_error,
is_transient_llm_error,
)

logger = logging.getLogger(__name__)

LlmFn = Callable[[str, str], str]

Expand Down Expand Up @@ -47,21 +49,26 @@ def with_rate_limit_retry(
max_retries: Optional[int] = None,
retry_sleep_seconds: Optional[int] = None,
) -> Any:
"""Retry rate limits and transient connection/timeout blips."""
default_retries, default_sleep = retry_policy()
retries = default_retries if max_retries is None else max_retries
sleep_s = default_sleep if retry_sleep_seconds is None else retry_sleep_seconds
for attempt in range(retries + 1):
try:
return fn()
except Exception as err:
if not is_rate_limit_error(err) or attempt >= retries:
retriable = is_transient_llm_error(err) or is_rate_limit_error(err)
if not retriable or attempt >= retries:
raise
kind = "rate/quota" if is_rate_limit_error(err) else "transient"
logger.info(
"rate/quota limited during %s; sleeping %ss (attempt %s/%s)",
"%s error during %s; sleeping %ss (attempt %s/%s): %s",
kind,
context,
sleep_s,
attempt + 1,
retries + 1,
type(err).__name__,
)
time.sleep(sleep_s)
raise RuntimeError("unreachable: retry loop exited unexpectedly")
Expand Down
35 changes: 35 additions & 0 deletions application/prompt_client/llm_error_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,38 @@ def is_rate_limit_error(err: BaseException) -> bool:
if code == 429:
return True
return False


def is_transient_llm_error(err: BaseException) -> bool:
"""Connection / timeout blips that are safe to retry (not model refusal)."""
if is_rate_limit_error(err):
return True
name = type(err).__name__.lower()
if any(
tok in name
for tok in (
"connect",
"timeout",
"apiconnection",
"remoteprotocol",
"network",
)
):
return True
msg = str(err).lower()
return any(
tok in msg
for tok in (
"connection reset",
"connection aborted",
"connection refused",
"temporarily unavailable",
"broken pipe",
"timed out",
"timeout",
"errno 54",
"errno 104",
"server disconnected",
"remote end closed",
)
)
Loading
Loading