Repository navigation
Conversation
update_rea_economic_event declared eleven update params and applied only `note`, discarding the rest while still returning a success record. It now merges the params sparsely with merge_partial, like the other entities: a present field replaces the stored value, an absent one is left alone. ValueFlows treats an EconomicEvent as an observed fact, so the update splits the params in two: - context, applied when present: note, agreed_in, realization_of, reciprocal_realization_of, settles, in_scope_of, triggered_by, fulfills, satisfies. agreed_in, reciprocal_realization_of and settles are new on the zome struct; the GraphQL update input already exposed them and serde dropped them silently. - the fact, fixed at creation: provider and receiver are applied and the integrity rule vf_validate_unchanged rejects a change (that rule was unreachable before); input_of, output_of and corrects have no integrity rule, so the coordinator rejects a change with a message naming the field. Resending the stored value is accepted. Relationship indexes are now maintained against old and new values, so a changed realization_of, triggered_by, settles, fulfills or satisfies drops the link under the old base. The settles index is re-pointed at the new revision like the others. Seven Sweettest cases cover the read-back of every mutable field, sparse semantics, the moved agreement index, the three rejections and the unchanged echo. docs/graphql-api.md documents what updateEconomicEvent can change. Closes #416
Create checks that reciprocal_realization_of references an Agreement, but the update path did not and no link index validates that field. Also cover the outputOf guard, the settles index move, and the fulfills/satisfies link deletion with failing-first Sweettest cases.
Every other EconomicEvent field carries economic meaning that a report computed earlier relies on, so the integrity zome now refuses a change to any of them by name. The coordinator guards it supersedes are removed.
…raphQL boundaries
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.
Intent
update_rea_economic_eventdeclared eleven update params and applied onlynote, discarding the other ten while still returning a success record (#416). This PR makes the update honest, and settles what it may change.Lynn's rule, from the maintenance discussion: any field that could change the economic meaning of an event (anything that would move a periodic accounting report) cannot be changed after creation. Every EconomicEvent field except
notefails that test: who and what, how much and when, and also which agreement it realizes, which commitment it fulfils, which intent it satisfies, which claim it settles and whose scope it is in, since each of those decides which balance or report the event counts toward. So onlynotemay change, and a wrong event is fixed the ValueFlows way, with a new event thatcorrectsit.Changes
The rule lives in the integrity zome.
validate_economic_event_updatenow refuses a change to any field butnote(andid, which is bookkeeping set on the first update), withEconomicEvent <field> cannot be changed after creation. It previously guardedprovider,receiverandactiononly. Because it is integrity, every peer enforces it, so a modified client cannot slip a change past the network. An exhaustive destructure of the entry makes a field added later fail to compile until it is classified as fixed or mutable.The coordinator stops discarding fields. It merges the params with
merge_partial, the sparse-update pattern the other entities got in449b17a3, so a changed field reaches the integrity rule and is refused by name instead of silently dropped, an absentnoteleaves the stored one alone, and a client that echoes the whole event back with a new note succeeds.agreed_in,reciprocal_realization_ofandsettlesare added to the params struct for the same reason: the GraphQL input already exposed them and serde dropped them. The relationship indexes now follow the latest revision,settlesincluded (ClaimToSettlingEventswas never re-pointed on update before).Visible behaviour changes for clients: an update that omits
noteno longer clears it; an update that sends a newagreedIn,triggeredBy,realizationOf,reciprocalRealizationOforsettlesthrough GraphQL is now refused, where before it was silently ignored.Decisions
EconomicEventUpdateParamsin@valueflows/vf-graphqldeclaresnote,agreedIn,triggeredByandrealizationOf, which is probably the earlier decision.realizationOffails Lynn's test (it moves an agreement's balance), so this PR follows the test rather than the schema. The schema is left as it is here; whether VF itself should drop those three is a question for the VF repo.inputOf,outputOfandcorrectsin the coordinator to keep the DNA hash. Soushi chose to close it at the DHT gate instead: this changes the DNA hash, so the next release is a new network for anyone onhapp-0.5.0-beta.1. Beta is the cheapest moment for that.reject_immutable_changeand its Agreement type check onreciprocal_realization_ofare gone, since no change to either can now pass integrity.How to test
Sweettest cases for the update, in
tests/sweettest/tests/economic_event.rs: a note change reads back with every other field identical and the agreement, claim, commitment and intent indexes on the new revision; an absent note is left alone; a change to each of the thirteen non-note params is refused with the message naming that field, and leaves no revision behind; every field resent unchanged is accepted. The acceptance step inrea-flowsrefuses a newrealizationOfand a newagreedInby name through GraphQL, then updates the note and checks the agreement still lists the event.Results, all inside
nix developata37e6469:cargo test -p hrea-sweettest→ exit 0, 51 passed, 0 failed (economic_event17).provider,receiverandaction,cargo test -p hrea-sweettest --test economic_event→ exit 101,update_rejects_a_change_to_any_field_but_the_notethe only failure; restored, 17 passed.yarn install --frozen-lockfile && yarn run build:graphql:adapter && yarn run test:acceptance→ACCEPTANCE PASSED — 74/74 steps green.Not covered
resourceQuantity,hasPointInTimeand the rest) can only change through a hand-crafted write, which Sweettest does not build; the integrity rule covers them by the same macro line as the tested fields.reindex_singleandreindex_manyare now reachable only if the rule is relaxed, so they have no test.Documentation
docs/graphql-api.md: whatupdateEconomicEventcan change, why, and how to fix a wrong event.tests/sweettest/README.mdandclients/acceptance/README.md: the new coverage.Pre-open review
Re-reviewed 2026-10-09 after Lynn's feedback reshaped the rule.
sprout, no conflict.docs/graphql-api.mdand both test READMEs updated.a37e6469.Related
Closes #416