Repository navigation
fix(tools): ignore method calls in scan_managed_lines and validate block schemas (fixes #3042) - #4320
Open
gorky117-cell wants to merge 2 commits into
Conversation
…ock schemas (fixes limitlessprojects#3042) - Use negative lookbehind in scan_managed_lines to prevent matching method/field invocations like cfg.managed(...) as managed blocks. - In audit(), enforce that reported blocks contain a non-empty reason string and that tickets (when present) is a list of strings, preventing KeyError in main() and corrupted baseline entries. - In main(), validate that baseline["blocks"] entries follow the '<file>:<line>' key schema and dict value schema with valid reasons. - Add unit test coverage in test_managed_gate.py verifying all three reproducer cases fail closed. Signed-off-by: Gaurav Kumar Singh <gauravatwork117@gmail.com>
gorky117-cell
force-pushed
the
fix/issue-3042-managed-gate-lexical-and-schema-validation
branch
from
November 10, 2026 23:16
f8626d0 to
d93a73b
Compare
…into fix/issue-3042-managed-gate-lexical-and-schema-validation Signed-off-by: gauravatwork117 <gauravatwork117@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #3042 by fixing three validation and lexical scanning bugs in
tools/managed_gate.py:Ignore Method Invocations in
scan_managed_lines:re.finditer(r"\bmanaged\s*\(", masked)previously treated.as a non-word character boundary, matching receiver method calls likecfg.managed("x", "other")orself.managed(...). Replaced withr"(?<!\.)\bmanaged\s*\("so method/field calls are never confused for standalonemanaged(...)block declarations.Enforce
reasonandticketsSchema inaudit():Previously only validated
category in VALID. Now ensuresreasonis present as a non-empty string andtickets(if present) is a list of non-empty strings. Prevents unhandledKeyError: 'reason'crashes inmain()check mode and corrupt writes in--rebaseline.Validate Entries in
baseline["blocks"]inmain():Enforces that baseline keys strictly follow
<file>:<line>format (where<line>is integer digits) and that each value is a dictionary with a non-emptyreasonand validcategory.Verification & Tests
tools/test_managed_gate.pyinManagedGateTests:test_method_calls_do_not_spoof_managed_block: Verifiescfg.managed(...)andself.managed(...)are ignored while validmanaged(...)blocks on line 4 are correctly extracted.test_audit_missing_or_empty_reason_fails_closed: Verifies missingreason, blankreason, and invalidticketsfail closed with exit code2.test_malformed_baseline_entries_fail_closed: Verifies non-dict baseline entries and malformed keys fail closed with exit code2.python tools/test_managed_gate.py ManagedGateTests-> 22 tests, 0 failures, 100% PASS.Signed-off-by: Gaurav Kumar Singh gauravatwork117@gmail.com