Skip to content

fix(config): reject non-finite read consistency intervals - #979

Draft
mamamiii wants to merge 1 commit into
CortexReach:masterfrom
mamamiii:fix/reject-nonfinite-read-consistency
Draft

fix(config): reject non-finite read consistency intervals#979
mamamiii wants to merge 1 commit into
CortexReach:masterfrom
mamamiii:fix/reject-nonfinite-read-consistency

Conversation

@mamamiii

@mamamiii mamamiii commented Aug 2, 2026

Copy link
Copy Markdown

Summary

Related to #920.

This follow-up preserves the cross-process freshness behavior introduced by
#920 while closing a configuration-validation fail-open path for
storageMaintenance.readConsistencyIntervalSeconds.

When JSON5 non-finite values such as Infinity, +Infinity, 1e9999, or
+1e9999 reached the plugin parser, they could previously become
undefined and then silently default to 0, selecting per-read strong
consistency.

Changes

  • Distinguish an omitted value from an invalid value.
  • Preserve the documented default: an omitted value still resolves to 0.
  • Reject non-finite, fractional, negative, and unsupported values at the
    plugin boundary with the full configuration field path.
  • Preserve the existing behavior of unrelated legacy parser callers.

Validation

All validation used isolated artificial fixtures only.

  • L0-A freshness regression: 9/9 PASS.
  • A long-lived reader observed external insert, delete, update, and final
    cleanup without restart, reopen, or checkoutLatest.
  • L0-B configuration matrix: 19/19 PASS.
  • Valid missing/0/5/30 cases remain unchanged.
  • Non-finite JSON5 values and other invalid inputs now fail closed before
    reaching lancedb.connect().

No production data, private configuration, credentials, or endpoints were
used.

Scope

This PR does not change OpenClaw host settings, global AJV options, LanceDB,
the default interval of 0, or any production deployment configuration.

parseNonNegativeInt now accepts an optional fieldPath parameter.
When provided, invalid inputs throw with a field-qualified error message
instead of silently returning undefined (which would default to 0).

- undefined (missing): returned as undefined → caller's ?? 0 applies (unchanged)
- Valid finite non-negative integer: returned as-is
- Non-finite (Infinity, -Infinity): thrown with field path
- Non-integer (0.5, NaN): thrown with field path
- Negative (-1): thrown with field path
- Invalid type (string/boolean/null/object/array): thrown with field path
- String coercion: only env-var reference strings accepted when fieldPath
  is set; plain numeric strings rejected

Backward compatible: callers without fieldPath keep old silent-undefined
behavior.

The readConsistencyIntervalSeconds caller passes the full config field path:
  plugins.entries.memory-lancedb-pro.config.storageMaintenance.readConsistencyIntervalSeconds

Fixes the configuration-validation fail-open edge case where JSON5
Infinity/+Infinity/1e9999 values silently selected per-read strong
consistency. Related to CortexReach#920.
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