feat(python): add missing ingest_working_state and contest methods#2
Merged
feat(python): add missing ingest_working_state and contest methods#2
Conversation
The Python client was missing 2 of 15 gRPC methods. This adds ingest_working_state() for working memory snapshots and contest() for marking records as contested with conflicting evidence.
Adds ValidityMode, TaskState, AuditAction, ProvenanceKind, and EdgeKind enums that were present in pkg/schema/enums.go but missing from the Python types module.
Previously only 6 types were in __all__. Now exports all enums and dataclasses so users can do `from membrane import DecayCurve` instead of reaching into `membrane.types`.
The Python client previously only supported insecure channels. Now accepts tls, tls_ca_cert, api_key, and timeout parameters. All RPC calls pass metadata/timeout automatically. Updates README with missing methods (ingest_working_state, contest) and TLS docs.
- Fix import from non-existent 'membrane_client' to 'membrane' - Fix getting-started example to use actual client API signature (positional args, TrustContext object instead of loose kwargs) - Replace raw protobuf example in examples.md with the actual Python client library usage
listRecords previously fetched IDs then called getRecord per ID, resulting in 7*N queries. Now uses getRecordsBatch which does one query per table (7 total) for batches >3. Also fixes orphaned relations on update (tags and provenance were replaced but relations were not) and adds compound indexes on (type, salience) and (scope, sensitivity) for common query patterns.
Reinforce() previously had no upper bound on salience, allowing repeated reinforcement to push values arbitrarily high. Now capped at 1.0. Also makes Reinforce atomic by setting salience on the record struct before calling Update (previously called UpdateSalience and Update separately). ApplyDecay() now guards against NaN/Inf values from misconfigured decay curves, falling back to MinSalience.
Previously, srv.Stop() was called before cancel(), meaning gRPC could still be draining in-flight requests while background schedulers ran. Now cancels context first (stopping schedulers), then gracefully drains gRPC, then closes the database.
IngestOutcome was missing validation for source, target_record_id, and outcome_status fields. Merge was missing bounds check on the ids slice, allowing unbounded payloads.
The Snapshot struct had no timestamp indicating when metrics were collected, making staleness invisible to consumers. Now includes a CollectedAt field set at the start of collection.
- Test on Go 1.22 and 1.23 for forward compatibility - Add gofmt check to catch unformatted code - Add go mod tidy check to catch stale dependency state - Generate coverage profile with -coverprofile - Run staticcheck (was in Makefile but missing from CI)
Adds protoc version requirement, Python prerequisites, instructions for keeping SDKs in sync with proto changes, and scoped commit message examples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Python client was missing 2 of 15 gRPC methods. This adds
ingest_working_state() for working memory snapshots and contest()
for marking records as contested with conflicting evidence.