9 Commits
Author SHA1 Message Date
Martin Vogel e628d9d297 test(bench): make the py-lsp time budget a liveness backstop, not a perf gate
test_py_lsp_bench.c:262 failed the v0.10.0 release run TWICE on genuine
attempts (ubuntu-24.04-arm 3/3), while the SAME sha passed that shard in the
morning's dry run. A wall-clock bound on a shared 4-vCPU runner is not a
property of the code, and this repo's testing doctrine says exactly that:
perf tests assert a ratio; a time bound may exist only as a liveness backstop.

This test's perf content already IS ratio-form (resolution ratio with a
sanitizer-aware floor). The 150/1500 ms budget was the anti-pattern half.
It becomes a 30 s liveness backstop so a catastrophic hang still fails the
suite rather than the 900 s shard wall clock, and absolute timings stay where
they belong: scripts/benchmark-*.sh, which record rather than gate.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-08-10 16:40:31 +02:00
Martin Vogel b98f6a99c4 test: sanitizer-keyed budgets and a causality-based httpd interruption proof
The build system now stamps CBM_SANITIZED_BUILD for any non-empty SANITIZE,
so timing budgets key off build-system truth instead of compiler-specific
__SANITIZE_ADDRESS__ probes that miss trap-UBSan and TSan; the two bench
suites use it.

The httpd interrupt test proved 'the interrupt worked' with a wall-clock
bound, which is a lottery under sanitizers. A send-deadline test hook pins
the deadline out of reach so the join itself is the causality proof, and
the stop watchdog becomes a true ten-second hang detector.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-07-23 17:36:00 +02:00
Martin Vogel eed87fd372 Forbid test skips and convert existing skips to hard failures
Add scripts/check-no-test-skips.sh (run from lint) which fails the lint phase on any plain SKIP() or direct tf_skip_count manipulation; only SKIP_PLATFORM() (for genuinely platform-specific tests) is tolerated. Add FAIL() and SKIP_PLATFORM() helpers to the test framework and convert the remaining SKIP()/perf-gated skips across the suite into pass-or-fail assertions, so a suite that cannot meet its preconditions reports a red failure instead of a silent skip.
2026-06-05 21:53:25 +02:00
Martin Vogel 297003aab4 fix(test): use __SANITIZE_ADDRESS__ alone for sanitizer detection (gcc-portable)
GCC's preprocessor doesn't short-circuit 'defined(__has_feature) && __has_feature(...)' — it tries to parse the call syntax of the undefined token and errors with 'missing binary operator before token "("'. Modern GCC and Clang both define __SANITIZE_ADDRESS__ under -fsanitize=address, so use that single check.
2026-05-29 22:30:03 +02:00
Martin Vogel 130b707b35 release: v0.7.0 notes; make LSP-bench tests sanitizer-aware
Free the result before the time-budget assert (no leak on miss) and scale the budget ×10 when ASan/UBSan is active, so the perf benches run cleanly in the release CI (skip_perf=false) instead of only being gated by CBM_SKIP_PERF in dry-run.
2026-05-29 21:58:54 +02:00
Martin Vogel a805668ef8 test: gate LSP benchmarks behind CBM_SKIP_PERF; fix Windows test portability
The py/cs LSP benchmark tests have time-budget asserts (<150ms / <200ms) that ASan+UBSan blow on CI (750-900ms on arm64), so they bailed before cbm_free_result and LeakSanitizer flagged the leaked arena/parser. Gate them behind CBM_SKIP_PERF (set by the dry-run) like the incremental perf tests, so they run only when perf is enabled.

Fix Windows (msys2-clang) compile errors in test code by using the existing compat shims: setenv/unsetenv -> cbm_setenv/cbm_unsetenv (test_store_pragmas, test_ts_lsp), strndup -> cbm_strndup and 2-arg mkdir -> cbm_mkdir (test_path_alias), and guard the utimensat mtime-bump in test_pipeline behind #ifndef _WIN32.
2026-05-29 01:30:11 +02:00
Martin Vogel dd3a816163 feat(py_lsp): builtin/template attribute dispatch + wrappers + dedup
Major parity push. Bench 79% -> 98% (51/52 calls resolved) on a 178-line
fixture exercising the full parity surface.

Annotation wrapping:
- Type-wrapper annotations now unwrap to the inner type:
  ClassVar[T], Final[T], InitVar[T], ReadOnly[T], Required[T],
  NotRequired[T], Annotated[T, ...] (drop metadata),
  Mapped[T] / WriteOnlyMapped[T] / DynamicMapped[T] (SQLAlchemy 2.0),
  Type[T] / type[T]. Same logic in both py_resolve_annotation
  (runtime, scope-aware) and py_parse_type_text_qn (registry-build,
  scope-free).

Builtin / template attribute dispatch:
- obj_type=BUILTIN("str"|"int"|"list"|"dict"|...) now resolves
  attribute access via "builtins.<typename>" in the typeshed-derived
  registry. obj.split(...) on str, list.append(), dict.get() etc all
  emit edges with strategy=lsp_builtin_method.
- obj_type=TEMPLATE("dict"|"list"|...) routes the same way; receiver
  is the unparameterized container's typeshed entry.

Bare-name builtin fallback:
- Bare-name calls (range, len, list, dict, str, int, print, etc.) fall
  through to a "builtins" module symbol lookup, then to a builtins
  type lookup for class constructors. Strategies: lsp_builtin /
  lsp_builtin_constructor.

Emission deduplication:
- py_emit_resolved_call dedupes by (caller_qn, callee_qn). When two
  resolution paths converge on the same edge (expression typing then
  call emission, or attribute walk through wrappers), keep one entry
  with the higher confidence. Previously the same call could emit
  twice — the bench showed >100% ratios as evidence.

Bench fixture expanded from 136 to 178 lines:
- Adds @property access chains, Mapped[Annotated[int, ...]], Final
  fields, generator iteration with method dispatch on element type,
  multi-class match/case, dict comprehension over .values(), instance
  attribute typing through super().__init__, classmethod chained with
  Self return.

All 2898 prior tests stay green; bench at 98% in 11.79 ms (ASan +
UBSan).
2026-05-09 10:32:20 +02:00
Martin Vogel e7dcadc3dd feat(py_lsp): match/case narrowing, await passthrough, expanded bench
Round 3 parity push:

- match/case (PEP 634): when the case pattern is class_pattern (wrapped
  in a case_pattern), narrow the match subject identifier to NAMED(class)
  inside the case body. Push/pop scope per case. Capture sub-patterns
  bind to UNKNOWN (field-type extraction is a v1.1 task — would require
  field type info in the registry).
- await expr: identity passthrough. async def f() -> T registers with
  return T, so `await f()` returning T is the resolved-call shape we
  want without modeling Coroutine[Any, Any, T] explicitly.
- Expanded test_py_lsp_bench.c fixture from 65 lines to 136 lines
  exercising every parity feature: dotted-module walks, dataclass +
  Self chaining, multi-inheritance with super(), Optional/Union
  annotations + narrowing (isinstance / is not None / walrus), generic
  list[T] / dict[K, V] / defaultdict comprehensions, classmethod /
  staticmethod, match/case dispatch, async/await, common stdlib
  (logging.getLogger, json.loads, pathlib.Path, functools.lru_cache).

Bench result on the new fixture: 38 calls, 30 resolved, 79%, 7.50 ms.
Remaining 21% includes patterns where intermediate types lose precision
(e.g. super() constructor, dict subscript), instance attribute typing
(self.x where x isn't annotated at class scope), and decorator
return-type substitution (lru_cache).

All 2888 prior tests stay green; 2 new tests + bench expansion. Total
2890 / 0.
2026-05-09 03:29:51 +02:00
Martin Vogel a8c9ace4a5 feat(py_lsp): Phase 11 benchmark methodology + integration bench
Final phase of Python LSP integration. Adds:

- docs/BENCHMARK_PYTHON.md — methodology document covering target
  metrics (per-file LSP overhead < 10 ms, resolution ratio ≥ 40% on
  application code, ≥ 70% with stdlib, < 5% spot-check false positive
  rate), the declared accepted-failure-class ceiling (metaclass
  __call__, __getattr__/__getattribute__, dynamic setattr, runtime
  importlib, monkey-patching, eval/exec, descriptors beyond the
  standard property/classmethod/staticmethod, dynamic type() classes),
  and instructions for running scripts/benchmark-index.sh against the
  largest Python repos in datadice (falkemedia: 232 files, api-hub:
  188 files).

- tests/test_py_lsp_bench.c — in-process benchmark wired into
  scripts/test.sh. Runs cbm_extract_file on a 65-line Python fixture
  covering imports, dataclasses, classmethods, single-inheritance with
  super(), typed parameters, attribute chains, and stdlib calls.
  Asserts soft floor (resolved >= calls/4) and hard time budget
  (< 50 ms under sanitizers). Initial run reports:

    bench: 65 lines, 16 calls, 13 resolved (81%), 2.45 ms

  81% beats the 40% application-code target and the 70%
  application-plus-stdlib target. 2.45 ms under ASan + UBSan is well
  inside the 10 ms (no-sanitizer) production budget.

This wraps the 11-phase plan documented in PYTHON_LSP_PLAN.md. Total
test count: 2874 / 0 (100% pass). Repository-level benchmarks via
scripts/benchmark-index.sh remain a manual operation against a fresh
production binary; methodology is now in place for when that runs.
2026-05-09 00:47:00 +02:00