Commit Graph

362 Commits

Author SHA1 Message Date
Grigorii Kirgizov e1ff37b815 Document RuleMatchingProbe (most importantly, its matches() contract). 2020-04-30 15:38:34 +03:00
Grigorii Kirgizov 8447081b26 Return from Probe only matches relevant to last expanded Occurrence. Fixes MPSCR-59 2020-04-30 15:38:34 +03:00
Grigorii Kirgizov 49d8507eed Avoid duplicate subscription of Occurrences on LogicalState
Previously it was done twice: at Occurence creation
and in ConstraintsProcessing.processActivated.
Occurrences now constructed in 'dead' state (without observers).
2020-04-30 15:38:34 +03:00
Grigorii Kirgizov 17de7bf9fe Fix tracking of logical observers: avoid duplicates & clear observers correctly
Commit also aligns Observable/Observer interfaces a bit.

Side note: the current role of LogicalState is to only
forward events from Logical to Observers with augmented
information (i.e. providing Controller to handle event).
2020-04-30 15:38:34 +03:00
Grigorii Kirgizov 3f2b7df7b4 Add sanity check that every match has active occurrence in its head (MPSCR-59) 2020-04-30 15:38:33 +03:00
Grigorii Kirgizov 14e4385382 Fix incorrect reset of occurrences that led to invalid occurrences state
Resulted in some in fact dead occurrences being reactivated
2020-04-30 15:38:33 +03:00
Grigorii Kirgizov 5c86ff2d4d Rename notion of 'reactivate' in incremental sense to 'activateContinue' to avoid ambiguity 2020-04-19 13:43:05 +03:00
Grigorii Kirgizov c6dca919ca Fix loss of some rule matcher probes with state crucial for incremental sessions 2020-04-19 13:43:05 +03:00
Fedor Isakov 9cacd25e53 Drop unused class from reactor API. 2020-04-13 17:58:33 +02:00
Grigorii Kirgizov 13e1e10f59 Disable assertion failing for lambdacalc, related to proper parent match tracking
Problem lies in that journal doesn't track all justifications
for reactivated occurrences. For a parent of such occurrence
its original activating match is considered, while
justifications from the Reactivating match aren't tracked.
So, this information about immediate reactivating parent is lost.

lambdacalc lang typesystem heavily uses reactivation, so it fails.
2020-03-26 13:40:42 +03:00
Grigorii Kirgizov 654031c05c Extend docs for Justified.justifiedBy relation, add assertion for its antisymmetric property 2020-03-26 13:40:42 +03:00
Grigorii Kirgizov a2675351b5 Track justifications for all occurrences, but weaken information they carry.
Now Evidence isn't unique for each Chunk: Occurrence Chunks fully
share evidence and justifications with their activating match.
So, less collections of justifications are created, approx. 2 times less.
2020-03-26 13:40:41 +03:00
Grigorii Kirgizov 6a53d15a21 Refactor: move logic related to tracking parent match from ControllerImpl to MatchJournal
Relates to machinery introduced in MPSCR-47.
Previously parent match was maintained in Controller on Java call stack.
Now this stack of parent matches is maintained manually in MatchJournal.

So MatchJournal gains new invariant: parentChunk()
returns correct parent after each logMatch() call.
Several tests fail, also need to maintain this
invariant after logActivation() calls.
2020-03-26 13:40:41 +03:00
Grigorii Kirgizov b10b69545e Refactor: hide mutability of Chunk.entries (both as var and as MutableList). Add a bit of docs. 2020-03-12 18:02:22 +03:00
Grigorii Kirgizov af0a118273 Fix mistake introduced in 591865b9: return copy of invalidated tags, not ref (fixes MPSCR-50) 2020-03-12 11:02:46 +03:00
Fedor Isakov 856c7cc777 Dereference all refs within term on unification.
Method findSolution now walks all refs inside a term.
This guarantees no "hidden" cycles, but also breaks the
"cyclic term" feature.
2020-03-11 12:29:04 +03:00
Fedor Isakov 914507329e Introduce checking flag to context, avoid failure in rule match.
Processing a match may fail because of unification went wrong.
To avoid these transient failures to propagate to program trace,
context can optionally abort instead of fail, which is then
recovered from.
2020-03-11 12:28:23 +03:00
Grigorii Kirgizov 591865b9cb Small opt: skip traversing journal when there're no rules to invalidate/add 2020-03-10 13:31:34 +03:00
Grigorii Kirgizov 441f203084 Revert "Remove throwing NPE on Term.symbol() given updated NotNull contract"
Leave exception because can't strongly rely on NotNull java annotation.
This reverts commit 6f49d63f
2020-03-06 14:04:18 +03:00
Grigorii Kirgizov 54f8c7a6be Change usages of ConstraintsProcessing.parentChunk() to usages of tracker parent 2020-03-06 14:04:18 +03:00
Grigorii Kirgizov 6f49d63fae Remove throwing NPE on Term.symbol() given updated NotNull contract 2020-03-02 22:08:51 +03:00
Grigorii Kirgizov 2ec4abe860 Maintain invariant that justifications of a MatchJournal.Chunk are inherited by all its children Chunks
Retroactive addition of justifications to a parent Chunk (MatchChunk.justifyBy),
introduced by a recent fix for MPSCR-47, can broke this invariant.
2020-03-02 22:08:51 +03:00
Grigorii Kirgizov 81721a0067 Ensure MatchJournalImpl.replay is idempotent operation, add test for it
Add another test for replaying inside Chunk.
Doesn't pass for now for the lack of machinery for tracking precise Pos.
2020-03-02 22:03:05 +03:00
Grigorii Kirgizov 7af3f29a6d Provide additional justifications for nearest relevant Chunks on certain matches. Fixes MPSCR-47
Such cases arise when non-principal rules can match on principal occurrences
(for example, capture_Classifier rule in BaseLanguage typesystem).
We don't want to lost justifications provided by these occurrences,
so store them in the nearest relevant chunk --- which is a parent match chunk.

With this the invalidation of the tracked principal occurrences will lead to invalidation
of this relevant match and so to invalidation of any effects produced by non-principal rules,
because they're logged exactly under the chunk of that relevant match.
See tests from previous commits for example.
2020-03-02 17:11:26 +03:00
Grigorii Kirgizov ccd3ed6d45 Add tracking of last justifying MatchChunk during program eval to avoid searching for it in Journal
Such machinery is needed inside ControllerImpl.processBody
to provide nearest relevant match to feedback handling.
Also required for a fix for MPSCR-47.
Also enables back one assertion in incremental processing on rm stage.
2020-03-02 17:11:26 +03:00
Grigorii Kirgizov a9af387816 Fix IndexedSignatureSet.remove method which didn't clear signatures, clear internal index also 2020-03-02 17:11:26 +03:00
Grigorii Kirgizov 8102080809 Refactor: drop unused on MPS level java interfaces 2020-03-01 17:12:15 +03:00
Grigorii Kirgizov 37dd3ee4a8 Refactoring: extract Justified interface and hide lower-level work with Int sets behind it
Make Occurrence a Justified entity and drop .justifications() from
ConstraintOccurrence.java because justifications are used only internally.
A single justification is now called Evidence (typealias to Int),
so Justified entities are justified by Evidence-s.
2020-03-01 17:12:15 +03:00
Fedor Isakov 3193a9c078 Adjust nullability contract in occurrence matcher.
Term's symbol can't be null.
Also guarantee that when processing a match no null
values occur.
2020-02-28 17:42:54 +01:00
Grigorii Kirgizov f9602c8bbf Throw on null terms in term trie (relates to MPSCR-40)
For more clear errors stemming from usage of constraints with null values, which ain't handled
2020-02-12 20:15:07 +03:00
Grigorii Kirgizov a1682106d8 Let Dispatcher handle future matches and don't store postponed matches (fixes MPSCR-37) 2020-02-05 18:52:18 +03:00
Grigorii Kirgizov 238b9e10cf Fix Rete RuleMatcher .forget method 2020-02-05 18:52:18 +03:00
Grigorii Kirgizov 438d8e6e9a Ensure rule tags of all dropped rule matches are propagated as algo output (MPSCR-32) 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov efd22872a9 Handle case of invalidating stale discarding matches (MPSCR-35) 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov 18fc4592f0 Modify logging methods of MatchJournal to return logged Chunks 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov 7074112b7c Revert "Refine logic for finding activation Pos to correctly handle discarding rules"
This reverts commit 746c4808
2020-02-05 12:29:33 +03:00
Grigorii Kirgizov 3b0008ad22 Remove some unused code 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov 840d02c9f7 Provide restricted version of MatchJournal.replay to utilize the descendants information of chunks
In some cases replay could 'overshoot' because the position replayed to was invalidated.
The natural way is to replay to the last descendant of such activated occurrence
and continue execution from here.
2020-02-05 12:29:33 +03:00
Grigorii Kirgizov ab3eb716ae Refactor ExecPos from ExecQueue to work with OccChunk instead of any Occurrence
This interface change it means that only Occurrences from previous session can be reexecuted.
2020-02-05 12:29:33 +03:00
Grigorii Kirgizov b909706a04 Refine logic for finding activation Pos to correctly handle discarding rules 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov d7c2b7f977 Extend MatchJournal with replayUntil method 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov b2cf46f813 Refactor a bit of logic responsible for finding appropriate place for inserting descendant chunk 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov d69b7bff98 Fix incremental match insertion logic for corner case of rules of equal priority
Behavior was incorrect in the case of discarding rules.
Several discarding matches could appear on the same occurrence,
beacuase newer incremental matches were inserted before later one,
thus seeing their occurrence as still active and stored.
2020-02-05 12:29:33 +03:00
Grigorii Kirgizov a4b28509a8 Provide additional information about parent principal chunk to Feedback (MPSCR-32)
Allows to track connection between invalidated matches and reported feedback.
In future this Journal info can help in simplifying error reporting.
2020-02-05 12:29:33 +03:00
Grigorii Kirgizov e55e67bc08 Modify EvaluationResult to also return the set of tags of all invalidated rules (MPSCR-32) 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov 79c31a44ba Handle journal reset for occurrences: upd their status (eg !alive). Add test for one error caused by it.
Occurrences which weren't yet activated (according to current journal position) can't be reactivated.
Test program is an example of such case.
2020-02-05 12:29:33 +03:00
Grigorii Kirgizov ba8d00c224 Handle incr exec of cases unhandled with introduced mem opt. Added test passes. 2020-02-05 12:29:33 +03:00
Grigorii Kirgizov 9aaf35561a Mem opt: store RuleMatchers only for principal rules between sessions. Add a test for incr processing.
The number of preserved matchers is around 4-10 times less.
The added test is an example of programs handled incorrectly with this opt. Fails now.
2020-02-05 12:29:33 +03:00
Fedor Isakov 8af582f9b2 Refactoring: simplify contract b/w controller and logical state. 2020-01-14 15:34:54 +01:00
Fedor Isakov d208e802b9 Remove unnecessary feature: StateFrameStack is no longer used.
StateFrameStack adds no functionality but requires too much processing.
Rename StateFrameStack -> LogicalState.
Rename ProcessingStateImpl -> ConstraintsProcessing.
Simplify occurrence's logical observer.
Introduce transient dependency on controller to LogicalState.
Keep logical state as part of session token, avoid re-initializing
all logical observers.
Make replaying of match journal independent of controller.
2020-01-10 13:51:07 +01:00