Skip to content

feat(protocols): declare WebServiceRules protocol for validate_business_rules - #106

Merged
marlon-costa-dc merged 3 commits into
0.12.0-devfrom
feat/v8-s4-declare-own-service-capabilities
Sep 26, 2026
Merged

marlon-costa-dc merged 3 commits into
0.12.0-devfrom
feat/v8-s4-declare-own-service-capabilities

Conversation

@marlon-costa-dc

@marlon-costa-dc marlon-costa-dc commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Slice / bead

V8 slice S4 (bead flext-4jtcb.10), member lane 2/3, consumers-first: before flext-core trims p.Service to (settings, container, context, logger, track, execute), this member declares its own local protocol for the phantom validate_business_rules() member that its six real service classes already implement.

What / why

  • src/flext_web/_protocols/lifecycle.py: add p.Web.WebServiceRules, a @runtime_checkable Protocol declaring only validate_business_rules(self) -> p.Result[bool]. It extends p.Base, not p.Service, because p.Service currently still carries unimplemented members (service_info, ok, fail_op) that would make any protocol extending it structurally unsatisfiable by a real service today.
  • FlextWebApp, FlextWebAuth, FlextWebEntities, FlextWebHandlers, FlextWebHealth, FlextWebServices (all six real p.Service-based service classes) already implement validate_business_rules; bodies unchanged.
  • tests/unit/test_services.py: new behavioral test test_web_satisfies_its_own_service_rules_protocol proving isinstance(web, p.Web.WebServiceRules) is True against the real composed FlextWeb facade singleton, and .validate_business_rules() is callable with its real result. The isinstance check runs through a @staticmethod helper typed (candidate: p.Base) -> bool so pyright does not narrow the argument to the concrete FlextWeb type and flag the check as reportUnnecessaryIsInstance.
  • make upg / make gen refreshed uv.lock, pyproject.toml, Makefile, .gitignore, mkdocs.yml and toolchain-generated docs projections in the same commit.

Runtime proof (E3, before/after)

$ .venv/bin/python -c "
from flext_web import p, web
print('isinstance:', isinstance(web, p.Web.WebServiceRules))
print(web.validate_business_rules())
"
isinstance: True
success=True error=None error_code=None error_data=None

Before this change, p.Web.WebServiceRules did not exist.

Gate exits

Verb Exit
make upg 0
make setup 0
make gen (x2, fixed point) 0 / 0
make fix non-zero — pre-existing, unrelated: the markdown-code gate fails to compile a fence in docs/configuration/README.md:11 (````python malformed fence), a known defect covered by the separate fix/markdown-fences-compile branch per this session's brief. Confirmed with md_fence_scan.py: only docs/configuration/README.md:76 fails, a file this PR does not touch.
make fmt 0
make check 0
make mod 0 (0 actionable; 21 pre-existing detection-only ban-test-tautology findings in files this PR does not touch: tests/unit/test_constants.py, test_fields.py, test_models.py)
make test 0 (11 passed)

Consumer table

No downstream member in this fleet currently declares a sub-protocol over p.Web.WebServiceRules; this PR is additive-only (new protocol + new test), zero call-site changes.

LOC delta

+108 / -40 across 11 files (mostly toolchain-generated: lock, docs projections). Hand-authored delta: _protocols/lifecycle.py +15/-0, tests/unit/test_services.py +9/-1.

DO NOT MERGE.

🤖 Generated with Claude Code


Summary by cubic

Adds p.Web.WebServiceRules, a runtime-checkable protocol declaring validate_business_rules(), so flext-web declares its own service-rules capability before flext-core trims the currently-unimplemented p.Service surface. The change is additive-only: all six real service classes already implement the method, and no call sites change.

Details

  • The protocol extends p.Base, not p.Service, because p.Service still carries unimplemented members (service_info, ok, fail_op) that would make it structurally unsatisfiable.
  • Adds a behavioral test proving the composed FlextWeb facade satisfies the protocol and validate_business_rules() resolves to True; the isinstance check runs through a p.Base-typed static helper to avoid a pyright reportUnnecessaryIsInstance false positive.
  • Merged origin/0.12.0-dev and reran make upg/make gen: the lockfile now pins S2/S3/S5 integration tips, pyproject.toml drops the fail_under coverage floor, and a Git hook validation script plus regenerated docs landing pages arrived with the toolchain refresh.

Written for commit 48b684e. Summary will update on new commits.

Review in cubic

Marlon Costa and others added 3 commits September 26, 2026 13:29
…ss_rules

V8 slice S4 member lane (bead flext-4jtcb.10, consumers-first). Before
flext-core trims the truthful p.Service surface, flext-web declares
its own local protocol for the phantom validate_business_rules()
member that its six real service classes already implement.

- Add p.Web.WebServiceRules (@runtime_checkable Protocol extending
  p.Base, not p.Service, since p.Service still carries unimplemented
  members that would make it structurally unsatisfiable today) in
  _protocols/lifecycle.py, declaring only validate_business_rules.
- FlextWebApp/Auth/Entities/Handlers/Health/Services.validate_business_rules
  already implement it (unchanged bodies).
- Add a behavioral test proving isinstance(web, p.Web.WebServiceRules)
  is True through a protocol-typed static helper (avoids a pyright
  reportUnnecessaryIsInstance false trigger from narrowing on the
  concrete FlextWeb facade type).
- make upg/make gen refreshed the lock and toolchain-generated docs
  projections in the same commit.

make mod: 0 actionable findings; 21 pre-existing detection-only
ban-test-tautology findings remain in files this PR does not touch
(tests/unit/test_constants.py, test_fields.py, test_models.py).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@marlon-costa-dc
marlon-costa-dc merged commit c6f2fe1 into 0.12.0-dev Sep 26, 2026
7 of 9 checks passed
@marlon-costa-dc
marlon-costa-dc deleted the feat/v8-s4-declare-own-service-capabilities branch September 26, 2026 19:11
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