From 4495509252994d28e76625d8710b7e6894b8f8f9 Mon Sep 17 00:00:00 2001 From: Joe Esquibel Date: Wed, 26 Aug 2026 11:10:10 -0400 Subject: [PATCH] fix(cpp): raise func_start's constructor initializer-list cap from 500 to 2000 chars The cpp func_start regex's member-initializer-list clause for constructors capped the span at 500 characters before requiring the body's opening brace. A real constructor with a long initializer list (many member fields) exceeds this cap, so the regex never reaches the brace and the WHOLE constructor is missed -- not degraded, entirely invisible. Widened the cap to 2000 chars -- still a single bounded negated- character-class repetition, no unbounded quantifiers, consistent with the existing "IRON WALL" ReDoS-avoidance comment. Confirmed via timing probe: sub-millisecond at 2000/4000/8000-char filler inputs, scaling ~1.2x rather than the ~4x that would signal O(n^2) backtracking. Confirmed on language-crucible's mlir/flatbuffer_export.cc: the Translator class constructor (906-char initializer-list span) is now found. Closes #2009 Co-Authored-By: Claude Sonnet 5 --- gitgalaxy/standards/language_standards.py | 4 +- tests/extraction/languages/test_cpp.py | 4 + tests/extraction/languages/test_cpp_strict.py | 1 + tests/golden_master_audit.json | 76 +++++++++---------- tests/golden_master_zero_dep_audit.json | 76 +++++++++---------- tests/tree_sitter_accuracy_baseline_cpp.json | 8 +- 6 files changed, 87 insertions(+), 82 deletions(-) diff --git a/gitgalaxy/standards/language_standards.py b/gitgalaxy/standards/language_standards.py index 6fd372e01..be69e0977 100644 --- a/gitgalaxy/standards/language_standards.py +++ b/gitgalaxy/standards/language_standards.py @@ -36,7 +36,7 @@ | -------- | ----------- | -------------- | ------------ | --------------- | | Apex | 100.0% | 100.0% | 100.0% | 100.0% | | C | 99.0% | 99.5% | 100.0% | 100.0% | -| Cpp | 86.9% | 95.6% | 100.0% | 100.0% | +| Cpp | 87.0% | 95.6% | 100.0% | 100.0% | | Csharp | 100.0% | 100.0% | 100.0% | 100.0% | | Css | 100.0% | 100.0% | N/A | N/A | | Dart | 99.4% | 99.3% | 100.0% | 100.0% | @@ -3273,7 +3273,7 @@ class PrismConfigSchema(TypedDict): # [IRON WALL - CATASTROPHIC BACKTRACKING FIX]: # We enforce strict numeric bounds (`{0,500}` and `{0,100}`) instead of `+` or `*`. # This caps the permutation tree instantly. - r"(?:[ \t\n]*(?![ \t]*#):[^{;]{0,500}|(?:[ \t\n]+(?![ \t]*#)[a-zA-Z_][^(){};]{0,100};){1,20})?" + r"(?:[ \t\n]*(?![ \t]*#):[^{;]{0,2000}|(?:[ \t\n]+(?![ \t]*#)[a-zA-Z_][^(){};]{0,100};){1,20})?" # 10. THE IGNITION (The opening brace confirming it is a definition, not a declaration) r"[ \t\n]*\{", re.M, diff --git a/tests/extraction/languages/test_cpp.py b/tests/extraction/languages/test_cpp.py index 98a1e1972..8fd139725 100644 --- a/tests/extraction/languages/test_cpp.py +++ b/tests/extraction/languages/test_cpp.py @@ -80,6 +80,10 @@ "MyClass::MyClass(int x) : field_(x), other_(0) {", "MyClass::MyClass", ), # out-of-line constructor, multi-field member-init list + ( + "MyClass::MyClass(int x) : " + "field_a(1), " * 60 + "field_z(2) {", + "MyClass::MyClass", + ), # synthetic long initializer-list (over 500 chars, under 2000) ], "invalid": [ "class TargetFunc {", # class decl lookalike diff --git a/tests/extraction/languages/test_cpp_strict.py b/tests/extraction/languages/test_cpp_strict.py index 7dcdcdfd5..198f12303 100644 --- a/tests/extraction/languages/test_cpp_strict.py +++ b/tests/extraction/languages/test_cpp_strict.py @@ -560,6 +560,7 @@ def test_cpp_redos_immunity_sweep(): assert_redos_immune(CPP_RULES["args"], "std::vector<" + "a" * 100000, timeout_sec=3.0) assert_redos_immune(CPP_RULES["func_start"], "std::vector<" + "a," * 16000, timeout_sec=3.0) assert_redos_immune(CPP_RULES["func_start"], "__attribute__((" + "a" * 100000, timeout_sec=3.0) + assert_redos_immune(CPP_RULES["func_start"], "MyClass() :" + "a" * 100000, timeout_sec=3.0) assert_redos_immune(CPP_RULES["class_start"], "struct " + "a" * 100000, timeout_sec=3.0) assert_redos_immune(CPP_RULES["class_start"], "template<" + "a," * 16000, timeout_sec=3.0) assert_redos_immune(CPP_RULES["closures"], "[" + "a" * 100000, timeout_sec=3.0) diff --git a/tests/golden_master_audit.json b/tests/golden_master_audit.json index f2fa25ade..a914fe8e3 100644 --- a/tests/golden_master_audit.json +++ b/tests/golden_master_audit.json @@ -12,8 +12,8 @@ }, "Target Root Name": "data", "Absolute Project Path": "/home/joe/nyx_projects/language-crucible/data", - "Analysis ISO Timestamp": "2026-08-26T14:05:58.751275+00:00", - "Total Scan Duration": "43.62 seconds" + "Analysis ISO Timestamp": "2026-08-26T15:05:30.699506+00:00", + "Total Scan Duration": "75.66 seconds" }, "Source Control Footprint (Immutable Anchor)": { "Active Branch": "HEAD", @@ -295,7 +295,7 @@ "cpp": { "files": 33, "loc": 44831, - "impact": 56859.11999999999 + "impact": 56869.01999999999 }, "csharp": { "files": 8, @@ -2123,7 +2123,7 @@ }, "cpp/mlir": { "file_count": 6, - "total_mass": 4633.54, + "total_mass": 4643.44, "avg_exposures": { "cognitive_load": 44.93, "safety_score": 63.81, @@ -259887,7 +259887,7 @@ } }, "cpp/mlir": { - "Directory Group Magnitude": 4633.54, + "Directory Group Magnitude": 4643.44, "File Count": 6, "Ecosystem Fingerprint (Archetypes)": { "Unclassified": "100.0%" @@ -259921,9 +259921,9 @@ "Identity Proof": "Single Indicator (Ext: .cc)" }, "2. Topological Coordinates": { - "X": 6426.43, + "X": 6426.47, "Y": 61.77, - "Z": 2662.16 + "Z": 2662.18 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -259935,7 +259935,7 @@ "Total LOC": 4731, "Coding LOC": 3850, "Documentation LOC": 414, - "Structural Magnitude": 4089.6, + "Structural Magnitude": 4099.5, "Control Flow Ratio": "44.0%", "Popularity Rank": 0, "Raw Churn Frequency": 0.0, @@ -260119,6 +260119,16 @@ "Start Line": 3359, "End Line": 3394 }, + { + "Function Name": "Translator", + "Structural Impact": 15.1, + "Lines of Code (LOC)": 49, + "Control Flow Branches": 3, + "Input Parameters": 9, + "Control Flow Ratio": "30.0%", + "Start Line": 654, + "End Line": 702 + }, { "Function Name": "Translator::CreateMetadataVector", "Structural Impact": 14.2, @@ -260359,16 +260369,6 @@ "Start Line": 508, "End Line": 523 }, - { - "Function Name": "attribute_buffer_applier_factories_", - "Structural Impact": 5.2, - "Lines of Code (LOC)": 24, - "Control Flow Branches": 3, - "Input Parameters": 0, - "Control Flow Ratio": "42.9%", - "Start Line": 679, - "End Line": 702 - }, { "Function Name": "MlirToFlatBufferTranslateFunction", "Structural Impact": 5.2, @@ -261006,9 +261006,9 @@ "Identity Proof": "Single Indicator (Ext: .cc)" }, "2. Topological Coordinates": { - "X": 6671.97, - "Y": -90.97, - "Z": 2955.91 + "X": 6672.04, + "Y": -90.98, + "Z": 2955.96 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -261191,9 +261191,9 @@ "Identity Proof": "Single Indicator (Ext: .cc)" }, "2. Topological Coordinates": { - "X": 6071.66, - "Y": -25.91, - "Z": 2816.49 + "X": 6071.67, + "Y": -25.92, + "Z": 2816.53 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -261464,9 +261464,9 @@ "Identity Proof": "Single Indicator (Ext: .cc)" }, "2. Topological Coordinates": { - "X": 6867.63, + "X": 6867.71, "Y": 108.15, - "Z": 2504.68 + "Z": 2504.67 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -261637,7 +261637,7 @@ "2. Topological Coordinates": { "X": 5901.47, "Y": 73.35, - "Z": 2437.07 + "Z": 2437.08 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -261825,9 +261825,9 @@ "Identity Proof": "Single Indicator (Ext: .cc)" }, "2. Topological Coordinates": { - "X": 6440.42, - "Y": 102.3, - "Z": 2154.19 + "X": 6440.47, + "Y": 102.31, + "Z": 2154.16 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -425532,9 +425532,9 @@ "Identity Proof": "Single Indicator (Ext: .proto)" }, "2. Topological Coordinates": { - "X": 6613.9, + "X": 6614.01, "Y": -160.84, - "Z": 3711.34 + "Z": 3711.39 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -425689,9 +425689,9 @@ "Identity Proof": "Single Indicator (Ext: .proto)" }, "2. Topological Coordinates": { - "X": 6836.72, + "X": 6836.82, "Y": -103.73, - "Z": 2977.8 + "Z": 2977.85 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -425846,9 +425846,9 @@ "Identity Proof": "Single Indicator (Ext: .proto)" }, "2. Topological Coordinates": { - "X": 6815.61, + "X": 6815.71, "Y": -123.93, - "Z": 3244.2 + "Z": 3244.26 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -432414,9 +432414,9 @@ "Identity Proof": "Ecosystem Consensus Lock (75% Local Dominance)" }, "2. Topological Coordinates": { - "X": 7205.06, + "X": 7205.15, "Y": 164.39, - "Z": 2505.78 + "Z": 2505.81 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", diff --git a/tests/golden_master_zero_dep_audit.json b/tests/golden_master_zero_dep_audit.json index 9f3c2f2c1..6e8ff0d26 100644 --- a/tests/golden_master_zero_dep_audit.json +++ b/tests/golden_master_zero_dep_audit.json @@ -12,8 +12,8 @@ }, "Target Root Name": "data", "Absolute Project Path": "/home/joe/nyx_projects/language-crucible/data", - "Analysis ISO Timestamp": "2026-08-26T14:06:39.153494+00:00", - "Total Scan Duration": "32.81 seconds" + "Analysis ISO Timestamp": "2026-08-26T15:06:37.406693+00:00", + "Total Scan Duration": "57.62 seconds" }, "Source Control Footprint (Immutable Anchor)": { "Active Branch": "HEAD", @@ -295,7 +295,7 @@ "cpp": { "files": 33, "loc": 44831, - "impact": 56859.11999999999 + "impact": 56869.01999999999 }, "csharp": { "files": 8, @@ -2123,7 +2123,7 @@ }, "cpp/mlir": { "file_count": 6, - "total_mass": 4633.54, + "total_mass": 4643.44, "avg_exposures": { "cognitive_load": 44.93, "safety_score": 63.81, @@ -259887,7 +259887,7 @@ } }, "cpp/mlir": { - "Directory Group Magnitude": 4633.54, + "Directory Group Magnitude": 4643.44, "File Count": 6, "Ecosystem Fingerprint (Archetypes)": { "Unclassified": "100.0%" @@ -259921,9 +259921,9 @@ "Identity Proof": "Single Indicator (Ext: .cc)" }, "2. Topological Coordinates": { - "X": 6426.43, + "X": 6426.47, "Y": 61.77, - "Z": 2662.16 + "Z": 2662.18 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -259935,7 +259935,7 @@ "Total LOC": 4731, "Coding LOC": 3850, "Documentation LOC": 414, - "Structural Magnitude": 4089.6, + "Structural Magnitude": 4099.5, "Control Flow Ratio": "44.0%", "Popularity Rank": 0, "Raw Churn Frequency": 0.0, @@ -260119,6 +260119,16 @@ "Start Line": 3359, "End Line": 3394 }, + { + "Function Name": "Translator", + "Structural Impact": 15.1, + "Lines of Code (LOC)": 49, + "Control Flow Branches": 3, + "Input Parameters": 9, + "Control Flow Ratio": "30.0%", + "Start Line": 654, + "End Line": 702 + }, { "Function Name": "Translator::CreateMetadataVector", "Structural Impact": 14.2, @@ -260359,16 +260369,6 @@ "Start Line": 508, "End Line": 523 }, - { - "Function Name": "attribute_buffer_applier_factories_", - "Structural Impact": 5.2, - "Lines of Code (LOC)": 24, - "Control Flow Branches": 3, - "Input Parameters": 0, - "Control Flow Ratio": "42.9%", - "Start Line": 679, - "End Line": 702 - }, { "Function Name": "MlirToFlatBufferTranslateFunction", "Structural Impact": 5.2, @@ -261006,9 +261006,9 @@ "Identity Proof": "Single Indicator (Ext: .cc)" }, "2. Topological Coordinates": { - "X": 6671.97, - "Y": -90.97, - "Z": 2955.91 + "X": 6672.04, + "Y": -90.98, + "Z": 2955.96 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -261191,9 +261191,9 @@ "Identity Proof": "Single Indicator (Ext: .cc)" }, "2. Topological Coordinates": { - "X": 6071.66, - "Y": -25.91, - "Z": 2816.49 + "X": 6071.67, + "Y": -25.92, + "Z": 2816.53 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -261464,9 +261464,9 @@ "Identity Proof": "Single Indicator (Ext: .cc)" }, "2. Topological Coordinates": { - "X": 6867.63, + "X": 6867.71, "Y": 108.15, - "Z": 2504.68 + "Z": 2504.67 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -261637,7 +261637,7 @@ "2. Topological Coordinates": { "X": 5901.47, "Y": 73.35, - "Z": 2437.07 + "Z": 2437.08 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -261825,9 +261825,9 @@ "Identity Proof": "Single Indicator (Ext: .cc)" }, "2. Topological Coordinates": { - "X": 6440.42, - "Y": 102.3, - "Z": 2154.19 + "X": 6440.47, + "Y": 102.31, + "Z": 2154.16 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -425532,9 +425532,9 @@ "Identity Proof": "Single Indicator (Ext: .proto)" }, "2. Topological Coordinates": { - "X": 6613.9, + "X": 6614.01, "Y": -160.84, - "Z": 3711.34 + "Z": 3711.39 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -425689,9 +425689,9 @@ "Identity Proof": "Single Indicator (Ext: .proto)" }, "2. Topological Coordinates": { - "X": 6836.72, + "X": 6836.82, "Y": -103.73, - "Z": 2977.8 + "Z": 2977.85 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -425846,9 +425846,9 @@ "Identity Proof": "Single Indicator (Ext: .proto)" }, "2. Topological Coordinates": { - "X": 6815.61, + "X": 6815.71, "Y": -123.93, - "Z": 3244.2 + "Z": 3244.26 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", @@ -432414,9 +432414,9 @@ "Identity Proof": "Ecosystem Consensus Lock (75% Local Dominance)" }, "2. Topological Coordinates": { - "X": 7205.06, + "X": 7205.15, "Y": 164.39, - "Z": 2505.78 + "Z": 2505.81 }, "3. Architectural Profile": { "Repository Archetype": "Unclassified", diff --git a/tests/tree_sitter_accuracy_baseline_cpp.json b/tests/tree_sitter_accuracy_baseline_cpp.json index ea0e2d7cd..c17b593a5 100644 --- a/tests/tree_sitter_accuracy_baseline_cpp.json +++ b/tests/tree_sitter_accuracy_baseline_cpp.json @@ -1,12 +1,12 @@ { - "args_comparable": 1296, - "args_exact_match": 1233, + "args_comparable": 1297, + "args_exact_match": 1234, "corpus_path": "language-crucible/data/cpp", "extra_classes": 0, - "extra_functions": 60, + "extra_functions": 59, "files_scanned": 29, "found_classes": 65, - "found_functions": 1296, + "found_functions": 1297, "real_classes": 65, "real_functions": 1491 }