Skip to content

fix(v1.6): harden backend and reliability boundaries - #152

Open
Coding-Dev-Tools wants to merge 20 commits into
mainfrom
codex/v1.6-hardening
Open

fix(v1.6): harden backend and reliability boundaries#152
Coding-Dev-Tools wants to merge 20 commits into
mainfrom
codex/v1.6-hardening

Conversation

@Coding-Dev-Tools

Copy link
Copy Markdown
Owner

Summary

  • Add strict opt-in backend loading while preserving existing fallback defaults.
  • Harden encrypted database/config/startup/Docker/health handling.
  • Bound sync-relay retries and update the sync interface.
  • Consolidate reliability fixes across extraction, consolidation, documents, engine, store, MCP, and sync paths with regression coverage.

Validation

  • ruff check .
  • pyright
  • python -m pytest tests/ -q
  • commercial manifest and dashboard asset checks
  • retrieval, reinforcement, adversarial, and ablation evaluation gates
  • python -m pytest tests/test_release_evidence.py -q
  • package wheel build and isolated no-dependency install

Scope

This PR is based on origin/main and intentionally excludes the Galaxy/UI PR files, generated uv.lock, evaluation-integrity/profile helpers, the unreferenced Windows subprocess helper, and stale detached-worktree changes. Package metadata remains at version 1.6; no tag or release is created here.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4879235a5f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/backends/embedder_st.py Outdated
Comment thread engraphis/backends/extractor.py Outdated
Comment thread engraphis/factory.py
Comment thread engraphis/config.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5dbe2d429d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/factory.py
Comment thread engraphis/factory.py
Comment thread engraphis/config.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0940719c5d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/service.py
Comment thread engraphis/config.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ae3bdfcf0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/config.py Outdated
Address review gap: _parse_origins accepts '*' for public access and
rejects schemeless origins, but neither path had dedicated test
coverage. Pins both contracts so future refactors cannot silently
break the dashboard's credential-gating or the operator-typo
defense.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: db28ed0b25

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/backends/encrypted_db.py
Comment thread engraphis/backends/retention.py Outdated
… cleanup

- tests/test_config.py: split multi-import to satisfy ruff E401
- backends/retention.py: redact third-party RuntimeError in strict mode
  so provider credentials/cert paths cannot reach service logs; only the
  locally generated missing-key message passes through unchanged
- core/store.py: Store.close() now calls connector.close() (best-effort)
  so the SQLCipher key pragma is cleared on explicit shutdown, not just
  when the Store object is garbage-collected

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5d3101ce9f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/start_dashboard.py Outdated
Address two Codex review findings:

- scripts/start_dashboard.py: the broad Exception handler during eager
  config validation now emits a value-free diagnostic. UnsafeStateFile
  and other OSError subclasses can embed the configured ENGRAPHIS_ENV_FILE
  path; previously these bypassed the ValueError-specific sanitized branch
  and exposed tenant-identifying paths in service logs.

- engraphis/backends/extractor.py: guard client.close() calls in both
  llm_structured and llm strict-mode credential-rejection paths. If
  HTTP-client cleanup raises (proxy credentials, TLS failures, cert
  paths), the exception must not replace the sanitized missing-key
  diagnostic that dashboard startup surfaces.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fe65f524bc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/mcp_server.py
Address three Codex review findings:

- config.py: normalize relay URL scheme to lowercase before validation.
  URL schemes are case-insensitive per RFC 3986; previously HTTPS://
  rejected while the downstream relay validator accepts it.

- mcp_server.py: eagerly construct the service when
  ENGRAPHIS_REQUIRE_EXACT_BACKENDS=true so missing models or credentials
  fail the process before the stdio/HTTP transport accepts traffic,
  matching the documented startup-failure contract.

- ledger.spec.js: wait for the debounced scene reload request after
  clearing the repository filter. The 250ms debounce plus network fetch
  made the assertion race the in-flight reload; waiting for the
  unfiltered /api/graph/scene request stabilizes the test.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 32c8cd735b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/factory.py
Clearing the filter updates the renderer via setRepoFilter() but the
#graph-count text comes from the last server scene response. In
overview mode the debounced scheduleGraphRepositoryReload() does not
fire (only triggered for code overlay or full mode), so the count
stays at the filtered value. Click Reload data to fetch the
unfiltered scene, wait for the request, then assert.
Close the require_exact_backends validation gap identified by Codex review:

- extractor.py: reject unknown kind values (e.g. typos like 'typo') when
  require_exact=True instead of silently returning PassthroughExtractor.
  Known kinds: none, chunk, llm, llm_structured.

- graph_extractor.py: add require_exact parameter to get_graph_extractor().
  Unknown kinds now raise instead of silently returning NullGraphExtractor.
  Known kinds: none, regex.

- factory.py: thread require_exact_backends through to
  get_graph_extractor() call site — previously this was the only factory
  invocation that did not propagate the exact-mode flag.

The retention supervisor already raised ValueError on unknown modes (no
change needed). The vector index factory validates prefer values via an
explicit enum check. With these changes, every backend selector either
resolves to a known implementation or fails fast when exact mode is
enabled — matching the documented startup-failure contract.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f031722889

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/mcp_server.py
Comment thread engraphis/config.py
… redacted selector errors

Address three Codex P2 findings:

- mcp_server.py: extract _eager_exact_backend_check() shared helper;
  mcp_http_cli.py and mcp_classic_cli.py now call it before accepting
  traffic, matching the startup-failure contract of engraphis-mcp.

- config.py: __post_init__ re-checks raw ENGRAPHIS_VECTOR_BACKEND
  against the known set when require_exact_backends=True. Previously
  _parse_vector_backend silently replaced typos with numpy, hiding the
  configuration error from the factory.

- extractor.py, graph_extractor.py: exact-mode rejection messages no
  longer interpolate the configured selector value (which could be an
  accidentally pasted credential). Report the setting name and valid
  kinds instead.

- test_mcp_server.py: update mock to include _eager_exact_backend_check
  so the DNS rebinding guard test stays green.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e5b337850f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/core/store.py Outdated
SimpleNamespace lacks __spec__/__loader__ attributes that the Python
import machinery requires for 'from X import Y' statements. This caused
ImportError on CI Python 3.10-3.14 when the test mock replaced
engraphis.mcp_server in sys.modules. Use types.ModuleType which
satisfies the import protocol across all supported versions.
Repository owner deleted a comment from chatgpt-codex-connector Bot Aug 17, 2026
Repository owner deleted a comment from chatgpt-codex-connector Bot Aug 17, 2026
Repository owner deleted a comment from chatgpt-codex-connector Bot Aug 17, 2026
Address three Codex P2 findings:

- core/store.py: Store.close() no longer calls connector.close(). An
  injected connector (connect parameter) may be shared across multiple
  Store instances — closing it blanks the SQLCipher key pragma and
  breaks surviving stores' _open_connection() calls (verified backups,
  secure-erasure helpers). The injector owns the connector lifecycle;
  Store never closes what it didn't create.

- mcp_http_cli.py, mcp_classic_cli.py: wrap the new
  _eager_exact_backend_check import in try/except ImportError so test
  mocks that replace engraphis.mcp_server in sys.modules with a minimal
  stand-in get a no-op fallback. Production callers always find the
  real symbol; tests that mock the module stay green across Python
  3.10-3.14 without requiring __spec__ on the mock.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2994b239e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/config.py Outdated
Comment thread engraphis/config.py Outdated
…tor in exact mode

Address two Codex P2 findings:

- config.py: remove interpolated port and embed_dim values from
  out-of-range ValueError messages. Dashboard startup prints these
  verbatim; a parseable but out-of-range numeric secret (e.g. a pasted
  token that happens to look like a number) would otherwise reach
  operator logs. The setting name and valid range are sufficient for
  diagnosis.

- config.py: __post_init__ exact-mode vector backend check now rejects
  blank and whitespace-only values, not just unrecognized non-empty
  strings. Previously ENGRAPHIS_VECTOR_BACKEND='' with
  require_exact_backends=true passed the truthiness guard and silently
  degraded to numpy via _parse_vector_backend.
- Wrap _open() in initialize() with try/except — provider failures must
  not take down the host application
- Broaden backup_paths config import catch to Exception (best-effort)
- Add uv.lock to .gitignore (generated tooling, never a project dep)
…wn\n\nMemoryService.create() builds the SQLCipher connector via connector_from_env()\nbut never closed it — Store.close() correctly refuses to close an injected\nconnector (it may be shared), and MemoryEngine doesn't retain a reference.\nThe SQLCipher key pragma therefore survived MemoryService.close() until GC.\n\nAdd owned_connector tracking: create() passes the connector it built to\n__init__, and close() clears the key material after the Store shuts down.\nInjected connectors (caller-owned) remain untouched.\n\nAddresses Codex review thread: encrypted_db.py:204 (P2)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e9f9d29380

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/service.py Outdated
… raises

Wrap engine.close()/store.close() in try/finally so the SQLCipher key
pragma is always cleared, even when a backend collaborator fails during
shutdown. Previously the connector cleanup ran only on the success path.

Addresses Codex review thread: service.py:1232 (P2)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7c4a96a18c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/start_dashboard.py Outdated
…iagnostics

The _startup_error fallback branches for ValueError and RuntimeError were
echoing third-party exception messages verbatim. AutoTokenizer.from_pretrained
and provider client constructors can embed configured model paths, endpoint
URLs, or proxy credentials in their error text.

Replace both fallbacks with value-free diagnostics pointing to
engraphis-init --check. The known-safe branches (trusted config,
require_exact_backends) retain their actionable messages.

Addresses Codex review thread: start_dashboard.py:196 (P2)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be42c98ade

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/start_dashboard.py Outdated
The trusted config / environment variable substring check in _startup_error
still echoed arbitrary third-party ValueError messages verbatim when the
message happened to contain those phrases. A library raising
ValueError("environment variable failure loading C:/tenant/private/...")
would pass the check and leak the path.

Replace with unconditional value-free diagnostic. All ValueErrors from
dashboard construction now route to engraphis-init --check.

Addresses Codex review thread: start_dashboard.py:199 (P2)
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.

1 participant