test: add proactive system integrity contracts

Replaces reactive bug-specific tests with 4 structural CONTRACTS
that make entire categories of bugs impossible:

1. Serialization Contract (13 parametrized hostile payloads):
   Proves SessionStateEncoder NEVER crashes regardless of what
   gets injected onto args (datetime, lambda, bytes, inf, nan, etc.)

2. Persistence Contract:
   Forces the REAL persist() path by removing PYTEST_CURRENT_TEST guard.
   Validates write → read round-trip with poisoned sessions.

3. Production Parity Contract:
   Scans ALL GramAddict source for pytest/test-mode divergence guards.
   Any unaudited divergence point fails the build. New guards require
   explicit justification in KNOWN_DIVERGENCES registry.

4. Import Integrity Contract:
   Imports every single GramAddict module to catch syntax errors,
   circular imports, and missing dependencies at test time.

This addresses the root systemic failure: tests were running in a
parallel universe where serialization was silently skipped, allowing
a datetime injection to corrupt sessions.json and kill production.
This commit is contained in:
2026-05-02 20:15:35 +02:00
parent 4af4ddb060
commit cd6cecbe27
4 changed files with 533 additions and 140 deletions

BIN
tests/fixtures/dm_thread_no_message.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

224
tests/fixtures/dm_thread_no_message.xml vendored Normal file

File diff suppressed because one or more lines are too long