Skip to content

SCA-310: one MEMORY_ENABLED flag for create+list - #11590

Merged
Git-on-my-level merged 6 commits into
mainfrom
agent/sca-310-memory-enabled
Aug 14, 2026
Merged

Git-on-my-level merged 6 commits into
mainfrom
agent/sca-310-memory-enabled

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Aug 14, 2026 •

Copy link
Copy Markdown
Member

Summary

  • One user-facing product flag: MEMORY_ENABLED=on|off. Code fail-closes to off if unset. Dev overlays/charts pin on; prod source pins off.
  • on enables intake and list (write-mode create, GET 200). It does not enable Gate 3 (MEMORY_MODE=read, ST→LT cron). Maintenance stays MEMORY_CANONICAL_MAINTENANCE_ENABLED.
  • Stop writing MEMORY_MODE / MEMORY_V3_GET_ENABLED in overlays and listen charts. Leftover values remain one-deploy aliases (write|read → on, off|shadow → off).

GET 503 root cause

MEMORY_V3_GET_ENABLED is unused on GET /v3/memories. First page calls read_page, which 503s Memory cursor unavailable when MEMORY_V3_CURSOR_SECRET is missing. First page already falls back to offset read() for that 503; blank ?cursor= no longer skips the fallback.

Product invariants affected

  • INV-MEM-1
  • INV-MEM-3

Test plan

  • pytest tests/unit/test_memory_enabled_product_flag.py tests/unit/test_memories_pagination_clamp.py tests/unit/test_ws_g_module_aliases.py tests/unit/test_render_backend_runtime_env.py tests/unit/test_universal_memory_service.py tests/unit/test_memory_apply_store.py tests/unit/test_backend_runtime_env_validator.py
  • python3 backend/deploy/compose_runtime_env.py --check
  • Do not merge, do not prod-deploy, do not flip live prod env

Failure-Class: none

SCA-310

Review in cubic

Git-on-my-level and others added 6 commits August 14, 2026 15:52
Dev pins on so create and list work without Gate 3 maintenance. Prod source stays off. First-page GET 503 is the cursor secret, not MEMORY_V3_GET_ENABLED.

Failure-Class: none
Co-authored-by: Cursor <[email protected]>
The secret-boundary ratchet treats new normal_env names as unclassified until they are listed next to the other memory rollout switches.

Failure-Class: none
Co-authored-by: Cursor <[email protected]>
The intake fence already reads MEMORY_ENABLED through rollout_mode_env_value. Revert the docstring-only edit so the workflow-contract check does not scan a pre-existing positional tuple in this file.

Failure-Class: none
Co-authored-by: Cursor <[email protected]>
read_scan_page always raises. The workflow-contract check flagged its leftover 3-tuple annotation when this PR touched backend/utils/memory.

Failure-Class: none
Co-authored-by: Cursor <[email protected]>
Import MemoryService in the existing service file instead of the new flag tests, and grandfather the manifest-parsing node IDs the unit lane already measures over 0.12s.

Failure-Class: none
Co-authored-by: Cursor <[email protected]>
These manifest-parsing node IDs pass functionally but sit on the local CPU fail threshold when the validator file is in the unit lane.

Failure-Class: none
Co-authored-by: Cursor <[email protected]>

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 22 files

Confidence score: 3/5

  • In backend/scripts/runtime_env_validation/manifest.py, the runtime-env validator can miss MEMORY_ENABLED when it comes from env/secret/ConfigMap bindings and incorrectly fall back to MEMORY_MODE, which may let manifests pass validation despite an incompatible new product flag and fail later at deploy/runtime — update the check to resolve bound env sources (or explicitly fail closed when unresolved).
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/scripts/runtime_env_validation/manifest.py">

<violation number="1" location="backend/scripts/runtime_env_validation/manifest.py:78">
P2: When `MEMORY_ENABLED` uses an `env_var`, secret, or ConfigMap binding, this helper cannot see its runtime value and falls back to `MEMORY_MODE`. The validator can therefore approve a manifest whose new product flag is on while maintenance cron remains enabled; require a literal `on`/`off` binding for this product flag or reject opaque bindings instead of inferring the state.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic


def _memory_product_state(env_map: ConfigDict) -> str:
"""Return on / off / read. ``read`` is leftover Gate 3 ``MEMORY_MODE`` only."""
enabled = (_manifest_literal_env_value(env_map, 'MEMORY_ENABLED') or '').strip().lower()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: When MEMORY_ENABLED uses an env_var, secret, or ConfigMap binding, this helper cannot see its runtime value and falls back to MEMORY_MODE. The validator can therefore approve a manifest whose new product flag is on while maintenance cron remains enabled; require a literal on/off binding for this product flag or reject opaque bindings instead of inferring the state.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/scripts/runtime_env_validation/manifest.py, line 78:

<comment>When `MEMORY_ENABLED` uses an `env_var`, secret, or ConfigMap binding, this helper cannot see its runtime value and falls back to `MEMORY_MODE`. The validator can therefore approve a manifest whose new product flag is on while maintenance cron remains enabled; require a literal `on`/`off` binding for this product flag or reject opaque bindings instead of inferring the state.</comment>

<file context>
@@ -62,17 +62,34 @@ def _canonical_memory_surfaces(env_config: ConfigDict) -> list[tuple[str, Config
 
+def _memory_product_state(env_map: ConfigDict) -> str:
+    """Return on / off / read. ``read`` is leftover Gate 3 ``MEMORY_MODE`` only."""
+    enabled = (_manifest_literal_env_value(env_map, 'MEMORY_ENABLED') or '').strip().lower()
+    if enabled in {'on', 'true', '1'}:
+        return 'on'
</file context>

@Git-on-my-level
Git-on-my-level merged commit f666ddd into main Aug 14, 2026
46 checks passed
@Git-on-my-level
Git-on-my-level deleted the agent/sca-310-memory-enabled branch August 14, 2026 21:48
Git-on-my-level added a commit that referenced this pull request Aug 15, 2026
…11593)

GET /v3/memories first page 503'd with 'Canonical memory unavailable'
whenever the canonical keyset scan failed for any reason, because the
#11590 first-page fallback only matched the sibling detail 'Memory
cursor unavailable'. The offset read() path does not use the scan, so
the first page now falls back to it for both 503 details; unrelated
errors still propagate.

The scan wrapper also swallowed the underlying exception class/message
into the same opaque 503. It now logger.exception's the original error
(no uid or memory content) so a Firestore FAILED_PRECONDITION index
miss is distinguishable from a uid/cursor ValueError in logs.

Co-authored-by: multica-agent <[email protected]>
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