Skip to content

feat(sdk): align Constraint with Rust (threshold+hard) — Sprint 51 T1 audit P6#187

Merged
dp-web4 merged 1 commit into
mainfrom
worker/web4-20260514-120007
May 14, 2026
Merged

feat(sdk): align Constraint with Rust (threshold+hard) — Sprint 51 T1 audit P6#187
dp-web4 merged 1 commit into
mainfrom
worker/web4-20260514-120007

Conversation

@dp-web4
Copy link
Copy Markdown
Owner

@dp-web4 dp-web4 commented May 14, 2026

Summary

  • Audit P6: Align Python SDK Constraint dataclass with Rust web4-core — replace untyped value: Any with typed threshold: float + hard: bool = True
  • Backward-compatible from_dict() accepts legacy "value" key for existing serialized data
  • Updated JSON schemas (schema_registry.json + standalone r7-action-jsonld.schema.json) to require threshold + hard with additionalProperties: false
  • Updated test vector r7-valid-002 and all affected tests (test_r6.py, test_r6_roundtrip.py)
  • Sprint 51 documentation updates in SPRINT.md and SESSION_FOCUS.md

Changes

File What
r6.py Constraint.value → threshold + hard, updated to_dict/from_dict, check_constraint, from_jsonld
schema_registry.json Constraint schema: type/threshold/hard
r7-action-jsonld.schema.json Same schema update (standalone copy)
r7-action-jsonld-validation.json Test vector r7-valid-002 updated
test_r6.py All Constraint constructions updated
test_r6_roundtrip.py New tests: test_hard_default, test_soft_constraint, test_legacy_value_key
__init__.py Docstring count update
SPRINT.md / SESSION_FOCUS.md Sprint 51 T1 entry

Test plan

  • 2670 tests pass (pytest -q)
  • mypy --strict clean
  • ruff check + ruff format --check clean
  • GitNexus detect_changes — LOW risk, 0 affected processes

🤖 Generated with Claude Code

…cs (audit P6)

Cross-language audit fix P6: replace untyped Constraint.value with
typed threshold:float + hard:bool fields matching web4-core Rust crate.
Backward-compatible deserialization accepts legacy "value" key.
Updates JSON schemas, test vectors, and all affected tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dp-web4
Copy link
Copy Markdown
Owner Author

dp-web4 commented May 14, 2026

APPROVED: Sprint 51 T1 audit P6 — cross-language Constraint alignment with Rust web4-core. Clean scope: replaces untyped value:Any with threshold:float + hard:bool=True, updates serialization in both directions, both JSON schemas (schema_registry.json + standalone r7-action-jsonld.schema.json) get additionalProperties:false enforcement, and the affected test vector. Backward-compatible from_dict accepts the legacy 'value' key for existing serialized payloads. Zero new files (within 5-file constraint). 2670/2670 pytest, mypy --strict clean, ruff lint+format clean. Properly scoped against the concurrent #186 mess — this is the version I'm taking.

@dp-web4 dp-web4 merged commit 766611e into main May 14, 2026
5 of 6 checks passed
@dp-web4 dp-web4 deleted the worker/web4-20260514-120007 branch May 14, 2026 23:04
dp-web4 added a commit that referenced this pull request May 16, 2026
Formalizes the open question from session 180024: conformance vectors
authored against an SDK dataclass shape silently test outdated semantics
when the shape later changes, because the adapter's forward-compatible
.get(key, default) masks the drift (concretely: Constraint.hard added in
PR #187 the same day r6-r7-actions.json landed).

Adds web4-standard/testing/conformance/VECTOR-FRESHNESS.md:
- the staleness hazard + why the adapter masks it
- a manual pre-merge checklist (reviewer responsibility)
- a CI-hook design (field-set diff heuristic; design only, no impl)
- a vector-provenance metadata convention

README.md links the checklist under "Contributing Vectors".

Peer session (lead 120725 holds Sprint 54 T1 via PR #196); scope is
disjoint — docs only, no SDK/test/spec files.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
dp-web4 added a commit that referenced this pull request May 16, 2026
…197)

Formalizes the open question from session 180024: conformance vectors
authored against an SDK dataclass shape silently test outdated semantics
when the shape later changes, because the adapter's forward-compatible
.get(key, default) masks the drift (concretely: Constraint.hard added in
PR #187 the same day r6-r7-actions.json landed).

Adds web4-standard/testing/conformance/VECTOR-FRESHNESS.md:
- the staleness hazard + why the adapter masks it
- a manual pre-merge checklist (reviewer responsibility)
- a CI-hook design (field-set diff heuristic; design only, no impl)
- a vector-provenance metadata convention

README.md links the checklist under "Contributing Vectors".

Peer session (lead 120725 holds Sprint 54 T1 via PR #196); scope is
disjoint — docs only, no SDK/test/spec files.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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