Commit Graph

594 Commits

Author SHA1 Message Date
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 60f838eb28 Add tests for unification of terms with var refs 2020-03-10 12:22:22 +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 5c4b1f8263 Add test that ensures that justifications invariant is preserved by a fix to MPSCR-47
Invariant ensures that retroactively added justifications
(added on past parent chunk, see fix commit) are propagated
for all relevant children of justified parent chunk.
2020-03-02 22:03:05 +03:00
Grigorii Kirgizov 2b92e5df04 minor: rename test method princConstraint to pconstraint 2020-03-02 17:58: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 38924ef64d Add 2 tests on incremental engine, reproduces case of MPSCR-47 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 f61c436809 Add tests to verify expected behavior of repeated expansion of the same occurrence (MPSCR-37)
Tests are structured similar to how occurrences are processes with ExecQueue
and its 'postponedFutureMatches' in incremental processing in ConstraintProcessing.
Also don't ignore one old test.
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 51ec8973d2 Add test to reproduce MPSCR-35 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 e763b0a3eb Fix maven source plugin's version 2020-01-20 19:43:56 +01: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
Fedor Isakov 01195cb1ac Drop unused methods from Rule interface. To be reinstated in RuleEx. 2020-01-02 17:20:13 +01:00
Grigorii Kirgizov ecc948c1fc Add, remove and merge observers on Logical always on their roots. Fixes MPSCR-28 2019-12-23 21:13:07 +03:00
Grigorii Kirgizov 1f69ff7d57 Reproduce MPSCR-28 with a test in Reactor 2019-12-23 18:14:41 +03:00
Fedor Isakov 271df160bb Optimize rete rule matcher for dropping occurrences.
Introduce a reactive scheme: alpha node has "dependent" nodes which
it can invalidate transitively. Drop block initiates invalidation,
intro block actually drops the nodes.
2019-12-08 17:48:01 +01:00
Fedor Isakov 2199905ea2 Enhance profiler to report actual time spent at probe locations.
Instead of just reporting the times each probe has been called,
collect and calculate the actual time taken by each probe location from
the whole backtrace pool.
2019-12-08 16:28:31 +01:00
Fedor Isakov 4eb93f20f9 Re-organize places in reactor to gather profiling information. 2019-12-08 15:44:36 +01:00
Fedor Isakov 5d63ec31e1 Remember probes for activated occurrences, optimize drop time.
Avoid searching for matching rules again when discarding occurrence.
2019-12-08 15:37:56 +01:00
Fedor Isakov 818d1a4dbc Fix linked list implementation. Fixes MPSCR-18
New implementation enables the previously failing tests to pass.
2019-11-26 23:07:42 +01:00
Fedor Isakov 65daa76c6b Remove droppedTrail. Optimize operation with consumed signatures. Restore test.
It appears the feature that tracks the occurrences that have been
dropped
requires too much memory.
2019-11-26 11:26:42 +01:00
Fedor Isakov 9fab2e9d34 Refactor and redesign ReteRuleMatcher for better memory footprint.
Drop layer prototype, make layer mutable.
Keep nodes in a layer in a linked list with fail-safe iterator.
Introduce update queue for update blocks.
Update blocks run incrementally unless reset.
Maintain trail of introduced and dropped occurrences.
Generation iterates over nodes in the last (final) layer incrementally,
unless reset.
Introduce new test.
2019-11-24 13:34:59 +01:00
Fedor Isakov 65f7b493be Revert "Add ReactivateBlock in Rete Matcher to correctly handle reactivation. Fixes MPSCR-17"
This reverts commit f96155496f.
I need to revert this commit to avoid merging problems. Going to reapply
it later if necessary.
2019-11-24 13:34:07 +01:00
Grigorii Kirgizov f96155496f Add ReactivateBlock in Rete Matcher to correctly handle reactivation. Fixes MPSCR-17 2019-11-19 15:43:15 +03:00
Grigorii Kirgizov 32a1ef77c9 Add test (fails now) for a new bug MPSCR-17 in Rete Matcher concerned with reactivation 2019-11-19 15:43:15 +03:00
Grigorii Kirgizov e7b374ce50 Fix calls to trace.reactivate (there were extra calls in some exec paths) 2019-11-19 15:43:15 +03:00
Grigorii Kirgizov 716e285c0c Small cleanup of EvaluationTrace usage 2019-11-07 17:14:40 +03:00
Grigorii Kirgizov f80371e148 MPSCR-14: Correctly trace incrementally reactivated occurrences. Fixes the bug. 2019-11-07 15:43:02 +03:00
Grigorii Kirgizov 45df4d845f Minor cleanup: remove DependentRulesSpec and its usages in RulesDiff
for historical documentation purposes, why it was needed:
It was used for specifying and handling rules which must be simply removed
without all related incremental invalidation machinery.
Long time ago some of these dependencies weren't captured
and such "simply dependent" rules must have been handled separately.
Currently it's handled by general invalidation case.
2019-11-06 19:10:29 +03:00
Grigorii Kirgizov 572a2cbfd5 Revert "Revert "MPSCR-4: Upd refs to new RuleIndex on Dispatcher construction in incremental case.""
This reverts commit a0b2af95
This together with preceding changes concerned with preserving Rules finally fixes MPSCR-4.
2019-11-06 19:10:29 +03:00
Grigorii Kirgizov 95214fcae9 Rename 'handlers' in Program to 'rulesLists' 2019-11-06 19:10:29 +03:00
Grigorii Kirgizov 87e9251242 Add RulesDiff.getPreserved() accessor to preserved rules 2019-11-06 19:10:29 +03:00
Grigorii Kirgizov f343ba0d3b Adjust to changes in SessionToken & RulesDiff interfaces 2019-11-06 19:10:29 +03:00
Grigorii Kirgizov bfcee33ec9 Modify SessionToken to preserve old rules instead of tags & RulesDiff to also distinguish preserved rules 2019-11-06 19:10:29 +03:00
Grigorii Kirgizov 3caeddcb63 Upd docs for StateFrame & add docs for StateFrameStack 2019-11-06 12:43:03 +03:00
Grigorii Kirgizov 510c3cd479 MPSCR-5: Clear all logicals from current StateFrameStack observer on incremental session teardown. 2019-11-06 12:16:11 +03:00
Fedor Isakov a0b2af95c9 Revert "MPSCR-4: Upd refs to new RuleIndex on Dispatcher construction in incremental case."
This reverts commit 0dd7f8c70f.
2019-11-04 15:58:54 +01:00
Grigorii Kirgizov 0dd7f8c70f MPSCR-4: Upd refs to new RuleIndex on Dispatcher construction in incremental case.
Slightly extend RuleMatcher interface.
Store RuleMatcher instances instead of RuleMatcherProbe in SessionToken.
2019-10-31 22:20:19 +03:00
Grigorii Kirgizov a095b2e222 Provide better (hopefully) name & explanation, undeprecate and provide missing impl for 'forgetSeen' method 2019-10-15 21:17:24 +03:00
Fedor Isakov 17f5bd64b0 Optimize Dispatcher: ensure allMatches are calculated lazily on request. 2019-10-08 13:20:40 +02:00
Fedor Isakov 445108da74 Fix RuleIndex returning too many matches for a constraint w/wildcard arg. 2019-10-08 13:16:56 +02:00
Fedor Isakov b283f657cf Fix a nasty bug in logical context.
A meta logical within a pattern was not properly initialized before the rule body is processed.
2019-10-02 13:54:11 +02:00
Fedor Isakov e69909f3be Some more optimizations in Rete rule matcher. 2019-10-01 16:25:12 +02:00
Fedor Isakov 31c95cd069 Bump up reactor version to 0.9.14. 2019-09-30 16:31:59 +02:00
Fedor Isakov c7b07f3b1a Adapt to the new persistent collections API. 2019-09-30 16:31:59 +02:00
Fedor Isakov 8ce96ec41e Introduce an abstraction layer of type aliases for persistent collections. 2019-09-30 16:31:59 +02:00
Fedor Isakov 04164e1039 Add some more profiling blocks. 2019-09-30 16:31:59 +02:00
Fedor Isakov 38e71db7e8 Revive and refactor ReteNetwork-based rule matching algorithm.
ReteNetwork is faster on large samples.
RuleMatchingProbe is mutable and not persistent, no need to update value.
2019-09-30 16:31:59 +02:00
Fedor Isakov f9b38113f5 Refactor and cleanup Dispatcher for better readability. Drop hacky stuff. 2019-09-30 16:31:59 +02:00
Fedor Isakov 60c39f2811 Add a test for a peculiar use case. Only triggered in production. 2019-09-30 16:31:59 +02:00
Fedor Isakov f21c01246f Introduce feature: optimize rule index for arguments matching.
RuleIndex indexes rules by constraint arguments value.
The additional feature allows to keep indexed also the head position
of the matched constraint.
2019-09-30 16:31:59 +02:00
Fedor Isakov 7d308cb0e3 Experimental feature: Rules segmentation.
The rules index is extended to observe the segment path a rule belongs to.
An occurrence is bound to the rule that activated it and thus has an
associated segment path.
Rules to be picked for activation can be selected on the basis
of matched segment path.
2019-09-27 21:59:58 +02:00
Fedor Isakov 6b2a14511f A little documentation for RuleMatcher. 2019-09-27 21:59:57 +02:00
Fedor Isakov d5bdcc971f Remove accidental modules from the project. 2019-09-27 21:59:57 +02:00
Fedor Isakov 3ff016d989 Optimizing rule matching algorithm for performance. 2019-09-23 11:27:54 +02:00
Fedor Isakov b8cf79e8e2 Renamed JB SDK to JB JDK 2019-09-23 11:27:54 +02:00
Grigorii Kirgizov 0f1460bb67 Add typechecking of array literals handling nested literals
Array literals always belong to some variable decl and their elements
are recursively checked against declared component type [JLS 10.6].
2019-09-11 13:24:01 +03:00
Fedor Isakov 1c61352068 Bump up reactor lib's version to 0.9.13. 2019-09-10 13:21:07 +02:00
Fedor Isakov 5cb4e0b289 Deprecate getting "current" EvaluationSession. 2019-09-10 13:19:59 +02:00
Fedor Isakov 487df639e5 Drop unused methods from EvaluationSession.
Having unused methods is confusing.
2019-09-10 13:17:34 +02:00
Fedor Isakov af212ca92e Refactoring EvaluationSession(Ex): drop controller accessor.
The inverse reference to controller from Evaluation session considered harmful.
Drop controller from EvaluationSession, drop ask/tell from EvaluationSession, extend InvocationContext with controller and supervisor accessors.
2019-09-10 13:08:53 +02:00
Fedor Isakov 279678b219 Ensure all feedback gets reported to trace. 2019-09-03 14:53:11 +02:00
Fedor Isakov a6aed2c22c Bump up the reactor lib version to 0.9.12. 2019-09-02 17:27:47 +02:00
Fedor Isakov 4080ab519a Extend EvaluationFeedback with specific methods for creating details feedback; introduce details parameter. 2019-09-02 17:18:02 +02:00
Fedor Isakov 13526ded21 Prevent ephemeral messages caused by failed ask to propagate.
A failed ask predicate constitutes normal evaluation flow, no need to report
this to the user.
2019-08-28 17:46:34 +02:00
Grigorii Kirgizov 98356f25cc rebase on master. remove extra deps in coderules generator 2019-08-22 15:16:17 +02:00
Grigorii Kirgizov 906f919e16 Run coderules program analyses at generation stage. Extend Rule with basetag(). Adjust how rule_tag is generated for reuse in generator.
basetag() returns name of ConstraintRule without node id.
Check on whether Rule is principal are now done through basetag(), it's sufficient.
Add part of future analysis: CallerTableBuilder.
2019-08-22 15:16:17 +02:00
Grigorii Kirgizov b4a012c61b fix type error in kotlin smart cast 2019-08-22 15:16:17 +02:00
Grigorii Kirgizov 9b472f5c15 Fix last() behavior for history: use constant-time getLast() in case of LinkedList 2019-08-22 15:16:17 +02:00
Fedor Isakov ed79a8b9b9 Fix TermTrie not processing correctly ref to a Nil.
The code in ClassicTermTrie that is responsible for recursion guarding
when processing cyclic terms, used to mismatch valid pattern term
containing ref to a Nil term, which is a constant.
2019-08-10 15:18:04 +02:00
Fedor Isakov a74831ad95 Bump up reactor version to 0.9.11. 2019-07-30 13:28:31 +02:00
Fedor Isakov d647a31e1d Switch reactor to JDK 11, kotlin lib to 1.3.31. 2019-07-30 13:27:27 +02:00
Grigorii Kirgizov b7b5ece832 Adjust notion of principal rule in analysis. Reenable assert in ProcessingStateImpl.
Now any rule matching on or activating principal constraints counts as principal.
2019-07-29 20:25:25 +03:00
Fedor Isakov 9a5b9f0b51 Temporarily disable failing assertion. 2019-07-29 13:42:33 +02:00
Fedor Isakov ba604c2f80 Use ArrayList for history, avoid linear time for last() method. 2019-07-29 13:42:33 +02:00
Grigorii Kirgizov cf5d2ae712 Fix incorrect behavior in journal.reset() in some cases, reenable tests for that. 2019-07-26 17:00:31 +02:00
Grigorii Kirgizov fb384dab39 Use embedded profiling for incremental passes 2019-07-26 17:00:31 +02:00
Grigorii Kirgizov 8ed7eb3c02 Change signature of Supervisor to handle RuleMatch instead of Rule 2019-07-26 17:00:31 +02:00
Grigorii Kirgizov be7283190f Propagate FeedbackStatus out of reactivate for incremental execution. 2019-07-26 17:00:30 +02:00
Grigorii Kirgizov f7ea5f7a0d Add entries to ExecutionQueue only once 2019-07-26 17:00:30 +02:00
Grigorii Kirgizov 2dba8890f3 Refactor ProcessingStateImpl: move logic related to execution queue to its own class 2019-07-26 17:00:30 +02:00
Grigorii Kirgizov 577662e202 Fix problem with some recovering rules not being reexecuted 2019-07-26 17:00:30 +02:00
Grigorii Kirgizov 5414fe7e67 Move RulesDiff construction from reactor to coderules runtime. 2019-07-26 17:00:30 +02:00
Grigorii Kirgizov d96ef01f98 Extend ProcessingStateImpl & RulesDiff for additional part of invalidation stage 2019-07-26 17:00:30 +02:00
Grigorii Kirgizov 769e7fd2ba Fix small issue related to mutable justifications in Occurrence. Upd tests with latest changes. 2019-07-26 17:00:30 +02:00
Grigorii Kirgizov ef2627cab4 MatchJournal now adds chunks for principal occurrences: search is simplified, case of several principal occs in rule is handled. 2019-07-26 17:00:30 +02:00
Grigorii Kirgizov b560bbbd30 Separate incremental tests on testlang and baselang into their own models. 2019-07-26 17:00:30 +02:00
Grigorii Kirgizov ed93865359 Refactor MatchJournal.Pos. Make RulesDiff usable in coderules mps code. Extend EvaluationTrace. 2019-07-26 17:00:30 +02:00
Grigorii Kirgizov 49aa913556 Move MatchJournalImpl to its own file. Some docs for it. Hide underlying mutable history behind immutable List. Add string tag() to Rule. 2019-07-26 17:00:30 +02:00
Grigorii Kirgizov 6c4667e066 Add basic coderules program analysis for determining principal constraints 2019-07-26 17:00:30 +02:00
Grigorii Kirgizov 155266d8ca Abstract java interfaces for incrementality-related classes for interop between reactor and coderules 2019-07-26 17:00:30 +02:00
Grigorii Kirgizov 5995b3a2f9 Simplify last test in TestStoreAwareJournal 2019-06-17 19:31:43 +03:00
Grigorii Kirgizov 022a9c372e Avoid searches of principal occurrence by utilizing MatchJournal.Index 2019-06-13 21:30:20 +03:00
Grigorii Kirgizov 65f1198a60 Prune the whole related state in RuleMatchers on removal-phase. Add test case. 2019-06-13 20:10:08 +03:00
Grigorii Kirgizov 7acbbc3988 Fix tests 2019-06-13 18:01:35 +03:00
Grigorii Kirgizov d1152128da Remove kotlin imports 2019-06-13 18:00:04 +03:00
Grigorii Kirgizov 9863569323 Tests for incrementally removing and removing+adding rules 2019-06-12 19:09:06 +03:00
Grigorii Kirgizov d7b7d40f8a Don't expose InitialRule to RuleDiff. Add first test for rm algo stage. 2019-06-12 14:56:57 +03:00
Grigorii Kirgizov 0bfe9e8a47 minor: remove usages of Constraint.isPrincipal in ProcessingStateImpl, use IncrementalProgramSpec instead 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov ae20c334b4 Discern incremental reactivation from usual one. Fix postponedMatches logic. 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov b3e0770939 minor: slightly rearrange code in ProcessingStateImpl 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov a5a46d6c67 Add incrementality test for one nontrivial case in RuleMatchFront.expand 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov db80dc7ab6 Extract rule ordering logic from ProcessingStateImpl 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 175d9f7623 Move StateFrameStack class to its own file 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov a2d55e92b9 Remove accidental line duplication 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 2a5f9e28dc Fix handling of postponed matches (match order comparison was slightly wrong) 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 5a9019e85c Fix bits of logic responsible for launching 'at-start' rules through 'main'. Fix handling of discarded occs 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 767eb057f5 Add helper method in Tests builder, adjust few tests with it 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 50fcfd0d8a Add initial version of logic for handling future matches in processActivated() 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov fa380c9f36 Fix failing build of coderules because of changed interfaces 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 3e50f47f73 Add MatchJournal.Index for additional queries and operations involving ordering of occurrences 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov eec343f902 Add stub code for handling case of adding headless ('at-start') rules 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov c0cb26d598 Add two more tests for addition phase. Handle one additional case and make one test pass. 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov ddb67690f4 Add partial sketch of removal phase of incremental algorithm.
For that: Extend DispatchingFront and RuleMatcherImpl interface with
'forget' methods which completely drops related matches from matchers' state;
Extend MatchJournal & Chunk interfaces with helper methods.
2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 8b4d98f6e2 Add few more checks in TestIncrementalProgram tests and one test in TestStoreAwareJournal 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 5b500340e5 Make StoreAwareJournal a pure interface, move delegated inheritance to StoreAwareJournalImpl (hide journal) 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 71eac08775 Move replayOccurrences back to MatchJournal again, fix tests 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 8d615852c6 Remove Controller from Occurrence and instead pass a new one each time through OccurrenceObserver
It caused a situation when on the very next incremental evaluation session
occurrences carried a stale Controller along with all the state from previous session.
As a result, incorrect logic of program evaluation.
2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 4e60ef9909 Add tests for incremental additions (one fails for now). Don't log reactivations in journal. 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov 95b5f97869 Add equals() to MatchJournal.Pos. Handle corner case in 'replay', when it happens to the same pos. Same for 'reset'. 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov e33df7aac2 Hide mutable collection of occurrences in Chunk and add 'principleConstraint' fun to its interface 2019-06-12 13:28:06 +03:00
Grigorii Kirgizov c9b486c170 Fix StoreAwareJournal test given updated journal's iterator starting pos 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 97d36d8d1f Fix corner case in algo stage. Add test for it. 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 6a3aad364c Add SessionToken to preserve eval state between sessions. Add IncrementalProgramSpec. Add impl of one algo stage, in ProcessingStateImpl.
SessionToken includes MatchJournal.View and a state of all RuleMatchers.
IncrementalProgramSpec specifies information needed for incremental evaluation.
In essence, it answers on queries of type 'isPrincipal' for Rules and Constraints.
It decouples specific incremental info from entities, allows to inject it easily in tests.
Its presence also enables incremental version of evaluation, in EvaluationSessionImpl.
2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 6932e99774 Enable tracking justification in Controller for principal constraints' occ-s 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 76194a62ae Refactor tests to make them more readable. Remove unsafe cast from journal's reset. 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 11bec29410 Use journal for aborting execution of alternative branches, fix 'reset' method
All tests for Controller pass, but one test from StoreAwareJournal fails, mute for now
2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 0fb54fc5ba Add invariant to Journal that it always has at least initial chunk, with EmptyRuleMatch
Also slightly fix tests and add tracking (i.e. using journal) to ProcessingStateImpl
2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 225bd9861e Separate concerns b/w ProcessingStateImpl and StateAwareJournal, construct in a new way
ProcessingStateImpl has only processing logic and inherits frame stack logic from StateAwareJournal
2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 77bc7538a4 Prepare before merging StoreAwareJournal & ProcessingStateImpl: extract FrameStack from ProcState, inherit StoreAwareJ from MatchJ by delegation 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 799b57c74e minor: remove usages of rule.tag() in tests 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 0cbc32d4a0 Get rid off nullability of Justs 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 52fd54afce Hide use of TIntSet from trove behind typealias; one usage in ConstraintOccurrence.java is left 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov f8b7ac1d50 Few renames in MatchJournal; throw exceptions at invalid iteration states 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov d3883effaf Extract frame-independent logic from MatchHistory to its base class MatchJournal
Small changes: rename MatchHistory -> StateAwareJournal; use referential
eq when iterating through chunks; provide only Pos, not Chunk from
current()/currentPos(); fix tests according to all this.
2019-06-12 13:28:05 +03:00
Grigorii Kirgizov e5942d2c77 Fix MatchHistory tests: fix impl of storeView, taking into account current pos in history (not all of it) 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov c4309084c5 Refactor: remove match-logic from StateFrame (now it's only about Observers), mvoe it to ProcessingState 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov b2f65e1510 Implement storeView() method to MatchHistory, remove it from ProcessingImpl (but not its single usage yet) and stored occurrences from StateFrame 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov cbddd108bb Subst FrameStack in MatchHistory for ProcessingImpl 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov cd5ad91caf minor: fix type in 'logOccurence' method 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov c322cf5c70 Add test with more complex and representative manipulation of MatchHistory 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov a360abc59e Add MatchHistory.View class (snapshot of history), refine one test, fix mistake in history.reset() 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 612f0a212c Refine MatchHistory impl, extract interface for tests, add several tests. 2019-06-12 13:28:05 +03:00
Grigorii Kirgizov 9a7838fdc7 Add initial sketch of MatchHistory; add justifications to ConstraintOccurence interface 2019-06-12 13:28:05 +03:00
Fedor Isakov eba51e8a9b Bump up conreactor's version to 0.9.10 in anticipation of new features. 2019-06-04 18:24:31 +02:00
Fedor Isakov c051542440 Replace usages of java.util.HashMap with persistent map to optimize
memory allocation.
2019-05-17 18:01:34 +02:00
Fedor Isakov 0e02bab768 Replace tag() method in rule with uniqueTag() returning Object. This
allows for further memory optimization.
2019-05-17 17:10:52 +02:00
Fedor Isakov 0697437ec7 Optimize code for fewer transient memory allocations. 2019-05-17 17:10:20 +02:00
Fedor Isakov 658963903d Refactor controller: extract component for managing dispatching front,
drop Store, introduce ProcessingState and StateFrame.

ProcessingState class to represent current state, including the
dispatching front and all the logical observers.
StateFrame is a persistent class that reacts to activated constraint
and launches processing via Controller.
Breaking change: the frames correspond to an activated constraint occurrence,
and not to a triggered rule match as it has been the case before.
2019-05-16 12:35:52 +02:00
Fedor Isakov 11a9505ee9 Decompose controller's processing of constraints for better separation of concerns.
Restructure the code in controller to enable being called from an
external component.
2019-05-14 11:38:19 +02:00
Fedor Isakov bfc4b641bb Refactor constraint occurrence to depend on controller directly.
Drop creating of a frame stack from a store view.
2019-05-13 10:48:10 +02:00
Fedor Isakov b482de1ce5 Rename reactor classes: Handler -> RulesList, IdWrapper -> Id 2019-05-10 12:00:02 +02:00
Fedor Isakov eb5b38384f Rename Handler class in reactor API to RulesList. 2019-05-09 17:30:14 +02:00
Fedor Isakov d70bc2509d Rename for better readability: fringe -> front, matchRule -> ruleMatch. 2019-05-09 17:30:14 +02:00
Fedor Isakov 915bc1442a Update project structure after API pom has been deleted. 2019-05-09 14:22:23 +02:00
Fedor Isakov fa2476fabb Drop deprecated stuff from conreactor API. 2019-05-05 14:30:19 +02:00
Fedor Isakov 7e7dba455e Move Kotlin compiler to "process-source" phase of Maven build. 2019-05-05 14:29:51 +02:00
Fedor Isakov cc2774d66d Refactorings in conreactor: better separation of concerns, cleaner interfaces.
Introduce Supervisor, extract evaluation-related stuff from Program, merge with EvaluationFeedbackHandler.
Move implementation of EvaluationFeedback to internal API, reduce number of public interfaces.
Cleaner interface for reporting feedback.
2019-05-05 13:52:26 +02:00