Skip to content

feat(librarian): Module C retrieval upgrades (stack base) - #1088

Merged
northdpole merged 4 commits into
stagingfrom
wip/oie-pipeline-eval-harness
Nov 1, 2026
Merged

northdpole merged 4 commits into
stagingfrom
wip/oie-pipeline-eval-harness

Conversation

@northdpole

@northdpole northdpole commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Stack base for OIE Module C. Rewritten from the monolithic tip so reviews stay scoped.

LiteLLM shared router already landed via #1102 — this slice is librarian retrieval only:

  • Dual-index C.1 retrieval, CRE summaries, prior cage, hub seed, edition remap
  • Factory defaults (CRE summary + dual-index), embedding text hygiene hooks
  • Librarian unit tests + related OIE utility scripts

Full tip backup (pre-split): commit b0e5e65b / local ref refs/backup/oie-1088-full.

Stack (merge bottom → top)

  1. feat(librarian): Module C retrieval upgrades (stack base) #1088 — librarian base ← you are here
  2. feat(harvester): requirement extract and GitHub URL ingest #1115 — harvester requirement extract + GitHub ingest
  3. feat(oie): B2 eval harness and CRE neighborhood scorer #1116 — B2 eval harness code
  4. chore(oie): ASVS 5.0 provisional B2 sources and gold #1117 — ASVS B2 fixtures/gold
  5. chore(oie): NIST 800-53 and remaining B2 sources/gold #1118 — NIST + remaining B2 fixtures/gold
  6. feat(mappings): promote Related-orphan remaps and re-point the LLM fixture to AI-hub CREs (#1124) #1119 — canonical mapping fixture promotions
  7. feat(oie): full-pipeline runner, docs, and experimental-flag notes #1120 — full-pipeline runner + docs (experimental flags removable on merge if unused)

Test plan

  • Targeted: python -m unittest discover -s application/tests/librarian -p '*_test.py'
  • Confirm PR diff is librarian-scoped (no scripts/oie_owasp_eval/fixtures/b2_sources)

Stack (merge bottom → top)

  1. feat(librarian): Module C retrieval upgrades (stack base) #1088 — librarian base (wip/oie-pipeline-eval-harness → main)
  2. feat(harvester): requirement extract and GitHub URL ingest #1115 — harvester (stack/oie-p2-harvester → feat(librarian): Module C retrieval upgrades (stack base) #1088)
  3. feat(oie): B2 eval harness and CRE neighborhood scorer #1116 — B2 harness (stack/oie-p3-b2-harness → feat(harvester): requirement extract and GitHub URL ingest #1115)
  4. chore(oie): ASVS 5.0 provisional B2 sources and gold #1117 — ASVS fixtures (stack/oie-p4-asvs-fixtures → feat(oie): B2 eval harness and CRE neighborhood scorer #1116)
  5. chore(oie): NIST 800-53 and remaining B2 sources/gold #1118 — NIST + other fixtures (stack/oie-p5-nist-other-fixtures → chore(oie): ASVS 5.0 provisional B2 sources and gold #1117)
  6. feat(mappings): promote Related-orphan remaps and re-point the LLM fixture to AI-hub CREs (#1124) #1119 — mapping promotions (stack/oie-p6-mapping-promotions → chore(oie): NIST 800-53 and remaining B2 sources/gold #1118)
  7. feat(oie): full-pipeline runner, docs, and experimental-flag notes #1120 — full-pipeline + docs (stack/oie-p7-full-pipeline-docs → feat(mappings): promote Related-orphan remaps and re-point the LLM fixture to AI-hub CREs (#1124) #1119)

@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review: 1
  • main

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 7fe303e and 44dc468.

Files selected for processing: 1
  • application/utils/librarian/config_loader.py
Files with no reviewable changes: 1
  • application/utils/librarian/config_loader.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Summary by CodeRabbit

  • New Features
    • Improved CRE recommendations using linked standards, section titles, and related security guidance.
    • Recognized OpenCRE URLs as authoritative references and flagged unknown references for review.
    • Suggested proposed CRE entries when no suitable match is found.
    • Added safety checks that can route adversarial or ambiguous content to review.
  • Bug Fixes
    • Improved recovery from temporary connection and timeout errors.
    • Improved embedding text quality by filtering page clutter and using relevant linked-standard content.

Walkthrough

This pull request adds OIE-based Librarian classification and metadata workflows, expands candidate retrieval and decision handling, and improves embedding text selection, filtering, and caching. It also adds supporting scripts, configuration, documentation, and tests.

Changes

Librarian metadata and retrieval

Layer / File(s) Summary
OIE taxonomy and metadata workflows
application/utils/librarian/oie_taxonomy.py, application/utils/librarian/metadata_enricher.py, scripts/oie_*, scripts/oie_taxonomy_bootstrap.py, application/tests/librarian/oie_*, application/tests/librarian/metadata_enricher_test.py
Adds OIE taxonomy indexing, metadata tagging and enrichment, and scripts for preparing and checking metadata.
Classification, CRE priors, and transfer indexes
application/utils/librarian/problem_class.py, application/utils/librarian/standard_link_seed.py, application/utils/librarian/aix_llm_link_seed.py, application/utils/librarian/cre_prior.py, application/utils/librarian/edition_remap.py, application/utils/librarian/neighbor_transfer.py, application/utils/librarian/control_name_seed.py, application/utils/librarian/umbrella_promote.py, application/tests/librarian/*seed_test.py, application/tests/librarian/*prior_test.py, application/tests/librarian/*transfer_test.py, application/tests/librarian/problem_class_test.py, application/tests/librarian/edition_remap_test.py, application/tests/librarian/umbrella_promote_test.py
Adds classification from catalog IDs and text, then uses standard links, taxonomy priors, edition remaps, neighboring standards, names, and parent relationships to derive preferred CRE IDs and retrieval constraints.
Retrieval and ranking composition
application/utils/librarian/candidate_retriever.py, application/utils/librarian/dual_index_retriever.py, application/utils/librarian/hub_leaf_cage.py, application/utils/librarian/standard_hop_retriever.py, application/utils/librarian/cross_encoder.py, application/utils/librarian/title_boost.py, application/utils/librarian/margin_cutoff.py, application/utils/librarian/focus_query.py, application/utils/librarian/config_loader.py, application/tests/librarian/candidate_retriever_test.py, application/tests/librarian/dual_index_retriever_test.py, application/tests/librarian/hub_leaf_cage_test.py, application/tests/librarian/standard_hop_retriever_test.py, application/tests/librarian/cross_encoder_test.py, application/tests/librarian/title_boost_test.py, application/tests/librarian/margin_cutoff_test.py, application/tests/librarian/focus_query_test.py, application/tests/librarian/config_loader_test.py
Adds allowlisted retrieval, name/body dual indexing, hub/leaf cages, Standard-to-CRE hops, and hybrid ranking controls. Configuration supplies the related retrieval and scoring settings.
Pipeline decisions and safety handling
application/utils/librarian/pipeline.py, application/utils/librarian/decision_engine.py, application/utils/librarian/explicit_link_resolver.py, application/utils/librarian/cre_gap_suggester.py, application/utils/librarian/cre_registry.py, application/utils/librarian/shortlist_judge.py, application/utils/librarian/llm_safety_guard.py, application/utils/librarian/emitter.py, application/utils/librarian/queue_runner.py, application/utils/librarian/schemas.py, application/tests/librarian/pipeline_test.py, application/tests/librarian/decision_engine_test.py, application/tests/librarian/explicit_link_resolver_test.py, application/tests/librarian/cre_gap_suggester_test.py, application/tests/librarian/cre_registry_test.py, application/tests/librarian/shortlist_judge_test.py, application/tests/librarian/llm_safety_guard_test.py, application/tests/librarian/queue_runner_test.py, application/tests/librarian/fixtures/golden_dataset.schema.json
Adds authoritative OpenCRE URL handling, shortlist judging, CRE-gap proposals, membership grounding, and LLM safety verdicts. Review decisions can include two candidate IDs, and the emitter formats gap proposals as suggested links.
CRE text, summaries, and component wiring
application/utils/librarian/cre_text.py, application/utils/librarian/cre_summary.py, application/utils/librarian/factory.py, application/utils/librarian/README.md, scripts/oie_generate_cre_summaries.py, scripts/evaluate_librarian.py, application/tests/librarian/cre_text_test.py, application/tests/librarian/cre_summary_test.py, application/tests/librarian/factory_test.py
Adds linked-Standard text enrichment and cached CRE summaries, with optional summary vectors and dual-index retrieval. Component construction and evaluation wire in the configured retrieval, text, and reranking options.
Embedding acquisition and retry handling
application/prompt_client/prompt_client.py, application/prompt_client/llm_error_utils.py, application/prompt_client/litellm_router.py, application/utils/librarian/embedding_quality.py, scripts/audit_standard_embeddings.py, scripts/oie_sync_cre_hub.py, application/tests/prompt_client_incremental_embeddings_test.py, application/tests/prompt_client_plain_text_fetch_test.py, application/tests/librarian/embedding_quality_test.py, application/tests/litellm_router_test.py
Layer / File(s) Summary
Embedding text and vector handling
application/prompt_client/prompt_client.py, application/prompt_client/llm_error_utils.py, application/prompt_client/litellm_router.py, application/utils/librarian/embedding_quality.py, scripts/audit_standard_embeddings.py, scripts/oie_sync_cre_hub.py, application/tests/prompt_client_incremental_embeddings_test.py, application/tests/prompt_client_plain_text_fetch_test.py, application/tests/librarian/embedding_quality_test.py, application/tests/litellm_router_test.py
Adds GitHub raw-URL selection, bounded plain-text fetching, content filtering, selected database-field fallback text, and an optional disk cache for single-string vectors. LiteLLM retries transient connection and timeout errors as well as rate-limit errors. Adds embedding-quality reporting and CRE embedding synchronization scripts.

Estimated code review effort: 5 (Critical) | ~100 minutes

Change: Feature

Possibly related PRs

  • OWASP/OpenCRE#1172: This PR changes the Librarian decision results and pipeline constructor used by the mapping workflow in #1172.
Merge Risk: Moderate · up to 44dc4

Several retrieval and safety paths can still produce incorrect links or bypass intended safeguards. Resolve the material issues before merging; the two previously reported test failures no longer appear to apply.

Security architecture risk: Moderate · up to dd480

The new database-copy command can expose credentials and does not reliably enforce its intended connection boundaries. It requires operator execution and database permissions, limiting reachability, but can affect the destination’s shared catalog.

Retained concerns

  • Medium · security · observed: The newly added sync command enforces its local-destination policy using only the URI authority hostname, while passing the complete URI to libpq. Query-string host or hostaddr parameters can select a remote destination without the acknowledgement flag. The resulting operation replaces every destination CRE embedding and upserts referenced CRE metadata. The base command had an analogous guard weakness, but only copied embeddings.
  • High · security · inferred: The new PostgreSQL source path relies on caller or environment TLS settings except for selected URLs, where it adds sslmode=require. This does not itself guarantee server identity verification. Under permissive effective settings, a network-positioned attacker could alter copied catalog content. Permissive source connections predate this PR, but the new command also accepts source metadata for insertion or overwrite in the CRE catalog.
  • High · security · observed: The new command prints the complete destination URL after committing its writes, including any supplied username and password. Anyone able to read captured stdout may obtain the supplied database identity. The impact is bounded by that identity’s actual grants, which are unknown. The base command already printed destination URLs, so this is an additional credential-output path rather than a novel exposure class.
Security review details

Security Blast Radius

  • observed — The direct mutation scope is all CRE embeddings in the selected destination database and metadata for source-referenced CRE IDs. There is no tenant or ownership predicate in these writes. Execution requires a supplied database identity; exposure beyond these operations depends on its grants and is not established by the available deployment evidence.

Security Findings and Attack Paths

  • inferred — The three retained findings cover distinct attack prerequisites: access to captured stdout for destination credentials, influence over a destination URI plus usable database authentication for the local-policy bypass, and network interception under permissive effective TLS settings for source tampering. None establishes unauthenticated web reachability or automatic cross-tenant access.

Trust Boundaries and Controls

  • observed — Source database content crosses into destination catalog authority through parameterized upserts and inserts. The command rejects an empty usable embedding set before opening its destination transaction and defaults to a local destination. These controls protect against empty-source destruction and SQL value injection, but do not bind the effective libpq endpoint or authenticate the source server.

Resilience and Maintainability Implications

  • observed — Destination metadata upsert and embedding replacement share one transaction, containing partial mutation on failure before commit. Counts and credential-bearing output occur after the explicit commit, so a subsequent reporting failure cannot undo the writes. There is no explicit synchronization between concurrent sync runs or built-in restoration of the previous catalog; rerunning identical input reconstructs the embedding set but leaves stale CRE records.
  • observed — The shortlist disk cache is keyed by query text and ordered candidate IDs, without tenant, authorization, model-version, or run identity. Writes are not atomic; malformed reads become cache misses, and cached IDs are revalidated before use. Whether reuse across authorization contexts violates an ownership contract remains unresolved, so no tenant-isolation finding is asserted.

Hardening Proposals

  • proposed — Redact connection credentials from operational output, enforce destination policy against libpq’s effective connection parameters, and require authenticated TLS for remote database connections. Use database roles limited to the required catalog operations to bound both leaked-credential and unintended-destination impact.
Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title "feat(librarian): Module C retrieval upgrades (stack base)" matches the main change. The changeset adds dual-index retrieval, CRE summaries, prior-cage retrieval, edition remapping, and rela…
Description check Passed The description states that the PR covers librarian retrieval: dual-index C.1 retrieval, CRE summaries, prior cage, hub seed, edition remap, factory defaults, and embedding text hygiene. These match t…
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(librarian): Module C retrieval upgrades (stack base)" matches the main change. The changeset adds dual-index retrieval, CRE summaries, prior-cage retrieval, edition remapping, and related librarian tests and utilities. The title is specific to the librarian retrieval scope. The phrase "stack base" refers to the PR's position in a stack, which is accurate but not a description of the code change itself.

Full details: Description check

Explanation

The description states that the PR covers librarian retrieval: dual-index C.1 retrieval, CRE summaries, prior cage, hub seed, edition remap, factory defaults, and embedding text hygiene. These match the changeset. It also gives a test command, a scope check, and the stack order. It is related to the changeset.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@northdpole
northdpole force-pushed the wip/oie-pipeline-eval-harness branch from f16272c to c6bf04b Compare September 13, 2026 17:50
@northdpole northdpole changed the title WIP: OIE mapping pipeline + OWASP eval harness (not merge-ready) OIE Module C: librarian retrieval + B2 eval harness Sep 22, 2026
@northdpole
northdpole force-pushed the wip/oie-pipeline-eval-harness branch from 9364f9b to d346bf7 Compare September 22, 2026 15:57
northdpole added a commit that referenced this pull request Sep 22, 2026
Unshaped dump for Cloud Agent to split into a clean commit stack on #1088.
@cursor
cursor Bot force-pushed the wip/oie-pipeline-eval-harness branch from 59957ab to 81434d2 Compare September 22, 2026 23:09
@northdpole

Copy link
Copy Markdown
Collaborator Author

Please stress-test GitHub ingest

Point-and-shoot ingest is on this branch: give it a public GitHub URL → harvest markdown → Module B noise filter → print knowledge. Try to break it.

Prereq — Gemini key (required for real classification)

Module B needs GEMINI_API_KEY in a local .env (do not commit or paste keys here):

cp .env.example .env
# set: GEMINI_API_KEY=…

Sanity check (prints ok / missing, never the secret):

python -c "import os; from pathlib import Path; from dotenv import load_dotenv; load_dotenv(Path('.env')); print('ok' if os.getenv('GEMINI_API_KEY') else 'missing')"

Without a key, use --ingest_keep_all only as a last-resort offline dump — that is not a real noise-filter test.

What to run

git fetch origin && git checkout wip/oie-pipeline-eval-harness
# venv + usual local setup, then .env with GEMINI_API_KEY

make ingest URL=https://github.com/OWASP/ASVS
make ingest URL=https://github.com/OWASP/ASVS/tree/master/5.0/en
./scripts/ingest_github.sh https://github.com/OWASP/CheatSheetSeries
python cre.py --ingest_github https://github.com/OWASP/CheatSheetSeries

No key on hand (last resort):

./scripts/ingest_github.sh https://github.com/OWASP/ASVS --ingest_keep_all

Make cannot take https://… as a bare goal (colon is special). Use URL= or ./scripts/ingest_github.sh.

Good looks like

  • stdout: knowledge chunks (path + text)
  • stderr: counts like files=… chunks=… knowledge=… noise=…

Please try to break it

Weird URLs, huge/tiny repos, table-heavy standards (ASVS/AISVS), re-runs, non-GitHub hosts (should fail cleanly).

How to report

Comment here with: (1) exact command (2) repo URL (3) whether GEMINI was configured — yes/no, not the key (4) expected vs actual (stderr counts + short stdout sample) (5) keep-all or not.

This is not the eval/accuracy scorer — just “does URL ingest dump useful knowledge?”

@northdpole

Copy link
Copy Markdown
Collaborator Author

Hey everyone — we’re trying something new.

Thanks to our awesome community, a ton of work from our GSoC students, and the maintainer team, we now have a point-and-shoot way to feed a public GitHub repo into OpenCRE’s OIE pipeline and see what it keeps as security knowledge.

You can find it on the WIP PR: #1088 (branch wip/oie-pipeline-eval-harness).

This is version zero of the OWASP agent (ingest → classify → show knowledge). We’re fine-tuning toward v1 and prepping for a release around AppSec California / AppSec SF — and we want beta testers from the community to hammer it before then.

How you can help

  1. Pull the branch and set a Gemini key (needed for real KNOWLEDGE vs NOISE classification — don’t paste keys in the PR):
git fetch origin && git checkout wip/oie-pipeline-eval-harness
cp .env.example .env   # if needed
# set GEMINI_API_KEY=… in .env

Sanity check (prints ok / missing only):

python -c "import os; from pathlib import Path; from dotenv import load_dotenv; load_dotenv(Path('.env')); print('ok' if os.getenv('GEMINI_API_KEY') else 'missing')"
  1. Point it at a public GitHub repo and see what comes back:
make ingest URL=https://github.com/OWASP/ASVS
make ingest URL=https://github.com/OWASP/ASVS/tree/master/5.0/en
./scripts/ingest_github.sh https://github.com/OWASP/CheatSheetSeries

(Make can’t take a bare https://… goal because of the colon — use URL= or ./scripts/ingest_github.sh.)

No Gemini key? Last resort only (not a real classification test):

./scripts/ingest_github.sh https://github.com/OWASP/ASVS --ingest_keep_all
  1. Tell us what broke or felt wrong — comment on this PR with:
    • exact command + repo URL
    • whether GEMINI was configured (yes/no — not the key)
    • expected vs actual (stderr counts + a short stdout sample)
    • keep-all or not

Please try weird URLs, huge/tiny repos, table-heavy standards (ASVS / AISVS), re-runs, non-GitHub hosts.

This is not the accuracy/eval scorer — it’s “does URL ingest dump useful knowledge?” Thanks for beta-testing v0 with us.

@northdpole

Copy link
Copy Markdown
Collaborator Author

Update: any LiteLLM provider / mid-size chat model

Module B already runs through LiteLLM. Ingest preflight now accepts whatever provider key matches your model — not Gemini-only.

In .env (pick a pair):

OPENAI_API_KEY=…
CRE_NOISE_FILTER_LLM_MODEL=openai/gpt-4o-mini

# or ANTHROPIC_API_KEY=… + anthropic/claude-haiku-4-5
# or GEMINI_API_KEY=… + gemini/gemini-2.5-flash
# or Groq / Mistral / OpenRouter / … (see .env.example)

Or per run:

make ingest URL=https://github.com/OWASP/ASVS INGEST_ARGS='--ingest_model openai/gpt-4o-mini'
./scripts/ingest_github.sh https://github.com/OWASP/ASVS --ingest_model anthropic/claude-haiku-4-5

Prefer a mid-size chat model (gpt-4o-mini, Claude Haiku/Sonnet, Gemini Flash, Llama 70B on Groq, …). Don’t paste keys in the PR.

@northdpole

Copy link
Copy Markdown
Collaborator Author

Wording tweak for beta testers: any LiteLLM chat model works; mid-size models usually work best (cheap + reliable for the classify gate — tiny stubs can be flaky, frontier models are optional spend).

@northdpole
northdpole marked this pull request as ready for review September 23, 2026 19:30
@skypank-coder

Copy link
Copy Markdown
Contributor

@northdpole Stress-testing --ingest_github on the current tip (394c10f), Windows, keyless (--ingest_keep_all) — hit a reproducible SQLite blocker after a clean harvest. No LLM key spent.

Command / setup

  • ./scripts/ingest_github.sh https://github.com/OWASP/ASVS --ingest_keep_all
  • Provider key: no (keep-all, offline)
  • DB: default standards_cache.sqlite, schema built with sqla.create_all() (per the Makefile note that migrations are the Postgres path and produce an incomplete SQLite cache)

Expected vs actual

  • Harvest succeeded: harvested OWASP/ASVS@master: files=236 chunks=3660

  • Then failed writing to knowledge_queue:
    sqlite3.OperationalError: too many SQL variables
    github_url_ingest.py:338 → :220 _keep_all_noise_filter → :191 session.execute(stmt)
    INSERT INTO knowledge_queue (21 cols) VALUES (…),(…),… ×3660 rows

  • 21 cols × 3660 rows ≈ 76,860 bound params, over SQLite's SQLITE_MAX_VARIABLE_NUMBER (32766). The knowledge_queue insert (_keep_all_noise_filter) isn't chunked to respect SQLite's variable limit, so any non-tiny repo overflows it on SQLite. Postgres wouldn't hit the cap — but since the beta default DB is SQLite, --ingest_keep_all on ASVS-scale (or larger) walls off here. Batching the insert (e.g. rows-per-statement under the SQLite cap) would fix it.

Notes

  • Reached this via the tarball path (codeload .tar.gz), not git clone — so it's independent of any clone/rename step.
  • Minor: branch probe tries refs/heads/main first (404 for ASVS, default master) then falls back — non-fatal, --ingest_branch master skips the wasted request.
  • Haven't run the keyed classify path yet — a keyed ASVS run would harvest the same 3660 chunks and hit the same insert overflow, so I'll do the real KNOWLEDGE/NOISE comparison on Postgres. Flagging this first since it blocks the SQLite keep-all path testers are pointed at.

northdpole added a commit that referenced this pull request Sep 28, 2026
…name-packer

Sync with PR #1088 upstream. Prefer dual-index librarian defaults on
conflicts; take 1088-only harness/full-pipeline/NIST/harvester additions.
northdpole added a commit that referenced this pull request Sep 29, 2026
Dual-index retrieval, CRE summaries, prior cage, hub seed, edition remap,
and related librarian defaults. Rewrites #1088 as the reviewable base; later
stacked PRs add harvester, B2 eval, fixtures, mappings, and full-pipeline docs.
@northdpole
northdpole force-pushed the wip/oie-pipeline-eval-harness branch from b0e5e65 to 9fb6d73 Compare September 29, 2026 09:51
@northdpole northdpole changed the title OIE Module C: librarian retrieval + B2 eval harness feat(librarian): Module C retrieval upgrades (stack base) Sep 29, 2026
Comment thread scripts/oie_sync_cre_hub.py Fixed
- Refuse plain-text fetch redirects that leave GitHub raw hosts (SSRF).
- Re-check expected embedding dimension on query-cache hits.
- Fill phrase-only oie blocks in apply_oie_fill_if_missing without losing phrases.
- Expose last_preferred_cre_ids on StandardHopRetriever and honour its allowlist.
- Commit each metadata enrichment so a later failure cannot roll back earlier work.
- Load .env from the repo root in the enrichment scripts.
- Parse hostnames for CRE hub sync SSL and loopback checks; batch SQLite IN
  lookups; stop echoing database credentials.
Wire LlmSafetyGuard (LiteLLM) as the live factory default so runs evaluate
safety instead of NullSafetyGuard. Apply the guard on every decision path,
prefer safety reason codes over empty shortlists, and cover a synthetic
adversarial corpus in unit tests.
northdpole added a commit that referenced this pull request Oct 14, 2026
Optional requirement extract (off/auto/on) plus GitHub tarball/URL ingest
wiring for Module B → C. Stacked on #1088 librarian base.
@northdpole
northdpole force-pushed the wip/oie-pipeline-eval-harness branch from 6b95fa1 to 7fe303e Compare October 14, 2026 08:48
northdpole added a commit that referenced this pull request Oct 21, 2026
Dual-index retrieval, CRE summaries, prior cage, hub seed, edition remap,
and related librarian defaults. Rewrites #1088 as the reviewable base; later
stacked PRs add harvester, B2 eval, fixtures, mappings, and full-pipeline docs.
northdpole added a commit that referenced this pull request Oct 21, 2026
Optional requirement extract (off/auto/on) plus GitHub tarball/URL ingest
wiring for Module B → C. Stacked on #1088 librarian base.
@Ajha2005

Copy link
Copy Markdown

Tested the ingest harness on branch stack/oie-p7-full-pipeline-docs
(commit 0b797a5), no LLM key, --ingest_keep_all.

Command:

./scripts/ingest_github.sh https://github.com/Ajha2005/DocuQuery --ingest_keep_all

Actual: chunks are prefixed with "Standard: DocuQuery" and "Version: 2005".
Expected: no Version line, since the repo has no version or year.

Cause: ChunkRecordBuilder._version_id (application/utils/harvester/chunk_record_builder.py)
searches (20\d{2}) over a text that includes source.repository ("owner/name")
and artifact_id. The pattern has no boundaries, so it picks up the digits
from the middle of the owner name "Ajha2005".

Control: ingesting https://github.com/jlevy/the-art-of-command-line the same
way (19 files, 470 chunks) produced no Version line, since there is no 20xx
in those strings. This inclines to the assumption that 2005 came from the owner's name.

Note: grepping application/tests for _version_id finds no direct test.

Fix ideas I'd suggest:

  1. Search only the repo name, not the owner (this fixes the case above).
  2. Add digit-boundary lookarounds, e.g. (?<!\d)(20\d{2})(?!\d), so a longer
    number like 12034 doesn't produce 2034 (separate from the owner-name issue).

Happy to open a PR against the stack if you want one.

@northdpole

Copy link
Copy Markdown
Collaborator Author

Review gate result for #1088 (stack base): TRIM.

Scope: 91 files, +17.9k/-305. This is the Module C retrieval base. 24 of the 27 new modules and scripts are imported or wired later in the stack. There are no migrations, no new dependencies, and no secrets or hardcoded hosts. The new GitHub plain-text fetch parses the host and re-validates redirects, with spoof tests.

Requested trims before merge:

  • Remove context_enrich.py and context_enrich_test.py (experiment not wired, preserved on a separate branch).
  • Revert golden_dataset.json to main's 322 rows. The 190 gold:asvs5 rows depend on owasp_asvs_5_0_provisional.json, which lands in the ASVS fixtures PR. Move the build_golden_dataset.py ASVS5 additions with it. Keep the CRE_GAP schema enum.
  • Drop scripts/oie_enrich_neighbor_phrases.py and scripts/oie_enrich_node_metadata_llm.py (no references anywhere in the stack).
  • Delete the duplicated _env_bool/_env_csv block in config_loader.py.

To confirm before staging:

  • scripts/oie_sync_cre_hub.py runs DELETE FROM embeddings WHERE doc_type='CRE'. It is loopback-only by default, but admin_panel/service.py later in the stack passes --allow-remote-destination. The PR adding that call must confirm the target DB and require explicit destructive confirmation.
  • build_components now hard-fails when OIE base metadata is unpopulated. The populate tooling (make oie-tag-base, setup_oie.sh) is not in this PR, so the stack must land together.
  • generate_embeddings changes unconditionally (node text, junk filtering, GitHub raw URLs), so embeddings_content will change and re-embed on the next run.

Follow-ups, not blocking: the default-on LLM safety guard sends chunk text to an external LLM; flag-gated losing experiments (hub_leaf_cage, focus_query, cre_text_enrich) can be reviewed once the stack settles; about 23 new env vars are undocumented; prompt_client.py is 1.5k lines; DB-writing oie_* scripts other than oie_generate_cre_summaries.py have no local-host guard.

- Remove the unwired context_enrich experiment (module and test); it is
  preserved on the staging-experiments branch.
- Drop oie_enrich_neighbor_phrases.py and oie_enrich_node_metadata_llm.py
  (no references anywhere in the stack).
- Revert golden_dataset.json and build_golden_dataset.py to main. The 190
  gold:asvs5 rows depend on the ASVS 5 fixture, which lands in the ASVS
  fixtures PR; they move there. The CRE_GAP schema enum stays.
- Delete the duplicated _env_bool/_env_csv block in librarian config_loader.
northdpole added a commit that referenced this pull request Nov 1, 2026
…nto trim/1115

* origin/wip/oie-pipeline-eval-harness:
  chore(oie): trim #1088 for the staging rollout
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1115:
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1116:
  chore(oie): trim #1116 and guard destructive eval scripts
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1117:
  chore(oie): trim #1117 for the staging rollout
  chore(oie): trim #1116 and guard destructive eval scripts
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1118:
  chore(oie): trim #1118 for the staging rollout
  chore(oie): trim #1117 for the staging rollout
  chore(oie): trim #1116 and guard destructive eval scripts
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1119:
  chore(oie): trim #1118 for the staging rollout
  chore(oie): trim #1117 for the staging rollout
  chore(oie): trim #1116 and guard destructive eval scripts
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout

# Conflicts:
#	requirements-dev.txt
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1120:
  trim(#1120): fix merge-conflict markers, guard full pipeline, drop dead experiments
  style: black-format llm_safety_guard.py
  chore(oie): trim #1118 for the staging rollout
  chore(oie): trim #1117 for the staging rollout
  chore(oie): trim #1116 and guard destructive eval scripts
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout

# Conflicts:
#	application/utils/librarian/factory.py
#	docs/oie/full-pipeline.md
#	scripts/oie_owasp_eval/run_fullpipe_detached.sh
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1125:
  trim(#1120): fix merge-conflict markers, guard full pipeline, drop dead experiments
  style: black-format llm_safety_guard.py
  chore(oie): trim #1118 for the staging rollout
  chore(oie): trim #1117 for the staging rollout
  chore(oie): trim #1116 and guard destructive eval scripts
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1127:
  trim(#1127): drop adversarial asker/batch scripts and canned CRE follow-ups, set source_channel in raw embedding writers
  trim(#1120): fix merge-conflict markers, guard full pipeline, drop dead experiments
  style: black-format llm_safety_guard.py
  chore(oie): trim #1118 for the staging rollout
  chore(oie): trim #1117 for the staging rollout
  chore(oie): trim #1116 and guard destructive eval scripts
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout

# Conflicts:
#	cre.py
#	scripts/owasp_agent_adversarial_asker.py
#	scripts/owasp_agent_adversarial_batch_run.py
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1137:
  trim(#1137): drop brevity-bot skills and stale handover doc, restore README/dev setup, loopback guard for run_admin_local.sh
  trim(#1127): drop adversarial asker/batch scripts and canned CRE follow-ups, set source_channel in raw embedding writers
  trim(#1120): fix merge-conflict markers, guard full pipeline, drop dead experiments
  style: black-format llm_safety_guard.py
  chore(oie): trim #1118 for the staging rollout
  chore(oie): trim #1117 for the staging rollout
  chore(oie): trim #1116 and guard destructive eval scripts
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1136:
  trim(#1137): drop brevity-bot skills and stale handover doc, restore README/dev setup, loopback guard for run_admin_local.sh
  trim(#1127): drop adversarial asker/batch scripts and canned CRE follow-ups, set source_channel in raw embedding writers
  trim(#1120): fix merge-conflict markers, guard full pipeline, drop dead experiments
  style: black-format llm_safety_guard.py
  chore(oie): trim #1118 for the staging rollout
  chore(oie): trim #1117 for the staging rollout
  chore(oie): trim #1116 and guard destructive eval scripts
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout
  test: embedding-failure scheduler test needs graph filing enabled now that it defaults off
  style: format files flagged by CI (black, prettier)
  Make event-repo harvesting opt-in (OIE_HARVEST_EVENTS)
  Make event page parsing linear-time and clean Playwright fallback text
  Embed auto-filed graph nodes in the CRE expansion job
  Parse OWASP event pages and harvest event repos

# Conflicts:
#	application/utils/oie_scheduler/jobs.py
#	scripts/oie_owasp_eval/run_full_pipeline.py
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1142:
  trim(#1142): admin upstream-sync-and-ingest no longer replaces existing CRE embeddings
  trim(#1142): no credentialed CORS without an allowlist, OIE workers opt-in in import-all, guard levers-matrix queue reset
  trim(#1137): drop brevity-bot skills and stale handover doc, restore README/dev setup, loopback guard for run_admin_local.sh
  trim(#1127): drop adversarial asker/batch scripts and canned CRE follow-ups, set source_channel in raw embedding writers
  trim(#1120): fix merge-conflict markers, guard full pipeline, drop dead experiments
  style: black-format llm_safety_guard.py
  chore(oie): trim #1118 for the staging rollout
  chore(oie): trim #1117 for the staging rollout
  chore(oie): trim #1116 and guard destructive eval scripts
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout
  test: embedding-failure scheduler test needs graph filing enabled now that it defaults off
  style: format files flagged by CI (black, prettier)
  Make event-repo harvesting opt-in (OIE_HARVEST_EVENTS)
  Make event page parsing linear-time and clean Playwright fallback text
  Embed auto-filed graph nodes in the CRE expansion job
  Parse OWASP event pages and harvest event repos

# Conflicts:
#	scripts/owasp_agent_adversarial_asker.py
#	scripts/owasp_agent_adversarial_batch_run.py
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1155:
  trim(#1155): drop laptop-local edge probe scripts, make node metadata seeding opt-in, fix empty-key blurb match
  trim(#1142): admin upstream-sync-and-ingest no longer replaces existing CRE embeddings
  trim(#1142): no credentialed CORS without an allowlist, OIE workers opt-in in import-all, guard levers-matrix queue reset
  trim(#1137): drop brevity-bot skills and stale handover doc, restore README/dev setup, loopback guard for run_admin_local.sh
  trim(#1127): drop adversarial asker/batch scripts and canned CRE follow-ups, set source_channel in raw embedding writers
  trim(#1120): fix merge-conflict markers, guard full pipeline, drop dead experiments
  style: black-format llm_safety_guard.py
  chore(oie): trim #1118 for the staging rollout
  chore(oie): trim #1117 for the staging rollout
  chore(oie): trim #1116 and guard destructive eval scripts
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout
  test: embedding-failure scheduler test needs graph filing enabled now that it defaults off
  style: format files flagged by CI (black, prettier)
  Make event-repo harvesting opt-in (OIE_HARVEST_EVENTS)
  Make event page parsing linear-time and clean Playwright fallback text
  Embed auto-filed graph nodes in the CRE expansion job
  Parse OWASP event pages and harvest event repos
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1159:
  trim(#1159): drop cambridge->boston alias, dead locals, test env/tempfile leaks
  trim(#1155): drop laptop-local edge probe scripts, make node metadata seeding opt-in, fix empty-key blurb match
  trim(#1142): admin upstream-sync-and-ingest no longer replaces existing CRE embeddings
  trim(#1142): no credentialed CORS without an allowlist, OIE workers opt-in in import-all, guard levers-matrix queue reset
  trim(#1137): drop brevity-bot skills and stale handover doc, restore README/dev setup, loopback guard for run_admin_local.sh
  trim(#1127): drop adversarial asker/batch scripts and canned CRE follow-ups, set source_channel in raw embedding writers
  trim(#1120): fix merge-conflict markers, guard full pipeline, drop dead experiments
  style: black-format llm_safety_guard.py
  chore(oie): trim #1118 for the staging rollout
  chore(oie): trim #1117 for the staging rollout
  chore(oie): trim #1116 and guard destructive eval scripts
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout
  test: embedding-failure scheduler test needs graph filing enabled now that it defaults off
  style: format files flagged by CI (black, prettier)
  Make event-repo harvesting opt-in (OIE_HARVEST_EVENTS)
  Make event page parsing linear-time and clean Playwright fallback text
  Embed auto-filed graph nodes in the CRE expansion job
  Parse OWASP event pages and harvest event repos
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1158:
  trim(#1158): strip_injection no longer truncates legitimate questions; correct default-off claims
  trim(#1159): drop cambridge->boston alias, dead locals, test env/tempfile leaks
  trim(#1155): drop laptop-local edge probe scripts, make node metadata seeding opt-in, fix empty-key blurb match
  trim(#1142): admin upstream-sync-and-ingest no longer replaces existing CRE embeddings
  trim(#1142): no credentialed CORS without an allowlist, OIE workers opt-in in import-all, guard levers-matrix queue reset
  trim(#1137): drop brevity-bot skills and stale handover doc, restore README/dev setup, loopback guard for run_admin_local.sh
  trim(#1127): drop adversarial asker/batch scripts and canned CRE follow-ups, set source_channel in raw embedding writers
  trim(#1120): fix merge-conflict markers, guard full pipeline, drop dead experiments
  style: black-format llm_safety_guard.py
  chore(oie): trim #1118 for the staging rollout
  chore(oie): trim #1117 for the staging rollout
  chore(oie): trim #1116 and guard destructive eval scripts
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout
  test: embedding-failure scheduler test needs graph filing enabled now that it defaults off
  style: format files flagged by CI (black, prettier)
  Make event-repo harvesting opt-in (OIE_HARVEST_EVENTS)
  Make event page parsing linear-time and clean Playwright fallback text
  Embed auto-filed graph nodes in the CRE expansion job
  Parse OWASP event pages and harvest event repos

# Conflicts:
#	application/mcp/ask.py
#	application/web/web_main.py
northdpole added a commit that referenced this pull request Nov 1, 2026
* trim/1162: (27 commits)
  docs(env): document CHAT_BLOCK_UNVERIFIED (default on, changes public chat answers)
  trim(#1162): drop prune_noise_chunks (unguarded DELETE on embeddings), validate authority weights before use, document ANSWER_LOG_*, no host paths in sync_check_staging
  trim(#1158): strip_injection no longer truncates legitimate questions; correct default-off claims
  trim(#1159): drop cambridge->boston alias, dead locals, test env/tempfile leaks
  trim(#1155): drop laptop-local edge probe scripts, make node metadata seeding opt-in, fix empty-key blurb match
  trim(#1142): admin upstream-sync-and-ingest no longer replaces existing CRE embeddings
  trim(#1142): no credentialed CORS without an allowlist, OIE workers opt-in in import-all, guard levers-matrix queue reset
  trim(#1137): drop brevity-bot skills and stale handover doc, restore README/dev setup, loopback guard for run_admin_local.sh
  trim(#1127): drop adversarial asker/batch scripts and canned CRE follow-ups, set source_channel in raw embedding writers
  trim(#1120): fix merge-conflict markers, guard full pipeline, drop dead experiments
  style: black-format llm_safety_guard.py
  chore(oie): trim #1118 for the staging rollout
  chore(oie): trim #1117 for the staging rollout
  chore(oie): trim #1116 and guard destructive eval scripts
  chore(harvester): trim #1115 for the staging rollout
  chore(oie): trim #1088 for the staging rollout
  fix(auth): harden web sign-in found by adversarial review
  fix(auth): /auth/user needs any role, not admin
  fix(auth): carry the PKCE code_verifier from login to callback
  fix(auth): build a fresh OAuth flow per login instead of a shared singleton
  ...
@northdpole
northdpole removed this pull request from stack #1121 November 1, 2026 22:50
@northdpole
northdpole changed the base branch from main to staging November 1, 2026 22:50
@northdpole
northdpole merged commit e47794b into staging Nov 1, 2026
12 of 13 checks passed
@northdpole
northdpole deleted the wip/oie-pipeline-eval-harness branch November 1, 2026 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants