Skip to content

CheapLlmImportGuard adapter (MN-REQ-12.11 / #63) - #71

Merged
chouswei merged 2 commits into
masterfrom
cursor/cheap-llm-import-guard-343f
Aug 13, 2026
Merged

chouswei merged 2 commits into
masterfrom
cursor/cheap-llm-import-guard-343f

Conversation

@chouswei

Copy link
Copy Markdown
Owner

Closes #63.

Gap

#49 shipped only the ImportGuard hook (set_import_guard / --no-guard). SysML later nested ImportGuardHook vs CheapLlmImportGuard, but memnet-llm still had no LLM adapter — every import stayed GuardPassthrough unless the host registered a function.

This PR

Ships the missing CheapLlmImportGuard adapter:

Concern Behaviour
Off No MEMNET_IMPORT_GUARD_API_KEY → same as today (no process hook)
On Key present → set_import_guard(cheap_llm_guard) on memnet serve / IPC, MCP process start, and CLI import-slice
HTTP OpenAI-compatible chat.completions; bounded slice summary only (ids/tags/short fields/anchors)
Decision Maps allow | trim+keep_ids | reject → ImportGuardDecision
Soft fail Timeout / HTTP / bad JSON → passthrough allow + @WRN (does not hang import)
Hard gates Unchanged — ImportAbsorb still runs; Path A never enters
Skip --no-guard / enable_guard=false still skips even when key is set
Secrets Key never logged or committed

Env

  • MEMNET_IMPORT_GUARD_API_KEY (required to enable)
  • MEMNET_IMPORT_GUARD_BASE_URL (optional; default https://api.openai.com/v1)
  • MEMNET_IMPORT_GUARD_MODEL (optional; default gpt-4.1-mini)

Model

Tests

Fake HTTP only (no live LLM): no key; allow; trim; reject; bad JSON → skip; HTTP error → skip; --no-guard; key never echoed.

Out of scope

N-server #47, AgensGraph #65, export #66, RSV honesty #67, ingest rewrite, PyPI publish.

Open in Web Open in Cursor 

cursoragent and others added 2 commits August 13, 2026 14:52
Add env-gated OpenAI-compatible soft ImportGuard in memnet-llm
(MEMNET_IMPORT_GUARD_API_KEY / BASE_URL / MODEL), wire install on
serve/MCP/import-slice, soft-skip on transport/parse failure, and flip
SysML CheapLlmImportGuard.implemented + MN-VER-12-S14.

Co-authored-by: chouswei <chouswei@users.noreply.github.com>
Co-authored-by: chouswei <chouswei@users.noreply.github.com>
@chouswei
chouswei marked this pull request as ready for review August 13, 2026 14:56
@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

For #63: CheapLlmImportGuard adapter is in this PR (env-gated LLM soft guard, not nest-only). CI green on test 3.11 + 3.12. Env: MEMNET_IMPORT_GUARD_API_KEY / MEMNET_IMPORT_GUARD_BASE_URL / MEMNET_IMPORT_GUARD_MODEL. Ready for review; not merging / not publishing PyPI.

@chouswei
chouswei merged commit 9e58196 into master Aug 13, 2026
2 checks passed
@chouswei
chouswei deleted the cursor/cheap-llm-import-guard-343f branch August 13, 2026 14:57
@chouswei chouswei mentioned this pull request Aug 13, 2026
3 tasks
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.

Cheap-LLM ImportGuard adapter not shipped (MN-REQ-12.11 leftover)

2 participants