-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ghost facts #2978
Fix ghost facts #2978
Conversation
@guillaume-duong-bib Looks fine code wise. Manually testing now. Question - did you find some easy way to look at the fact_store? For (3) I can confirm if the facts are present by downloading the operation report. But for (4) there is no operation report, so curious how you were getting at the fact_store without doing basically the entire Caldera file read method (with encryptor). |
I have disabled encryption on my test server and just read the file as such (with the server shut down):
Same for
Great to hear. What are your thoughts about (1) and (2)? If you agree that these are bugs though, I will attempt to fix them once I get some free time. |
@guillaume-duong-bib could you re pull in master. Im getting weird mimetype errors now when trying to test your branch...hmm |
@elegantmoose synchronisation done. I haven't seen these errors, where/when do you get them? I will check again later this week, most likely on Wednesday. |
Item 1 & 2 are now fixed, see the updated Status and Tests at the top. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im still testing, but this code LGTM, and a best possible, least effort solution for the moment. (The alternative being extensive changes to data service and knowledge service as crux of problem is that we have 2 services managing the same data)
seeded_facts = [] | ||
if self.source: | ||
seeded_facts = await knowledge_svc_handle.get_facts(criteria=dict(source=self.source.id)) | ||
seeded_facts = await data_svc_handle.get_facts_from_source(self.source.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@clenk How do you feel about this?
Im given pause as all_facts()
is called a lot in code base. However, this change seems to be equivalent as only getting facts for the given source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from fixing the issues mentioned, what does change is that modifying the base fact source will directly be reflected on the seeded_facts part, even during an operation. But is that an expected behavior, or is a simple doc update to warn users enough?
I can't think of/have not found anything else that could be troublesome.
Tested all cases locally. Would like @clenk to take a quick look. |
Bumping. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Apologies for the delay.
(The alternative being extensive changes to data service and knowledge service as crux of problem is that we have 2 services managing the same data)
I hope we can revamp this in the future.
@maxime- @jbaptperez - repull master in and we will merge. |
@elegantmoose Hello, normally it's done I had zero conflicts during the operation. |
Description
Attempt to fix #2930 and close #2971. (update: as of 2024/06/14, it should fix them all)
This PR is an attempt to fix the 4 following issues:
fact_store
even after being deleted from the fact source. Consequences:fact_store
when its value is updated in the fact source (very similar to the first item). Consequences:fact_store
manually.fact_store
even when the fact source is deleted. Consequences:fact_store
even after the operation is deleted, seemingly never to be used again. Consequences:Status (last update 2024/06/14)
At this point, all of the items mentioned are fixed, i.e.:
Type of change
How Has This Been Tested?
Item 1 & 2 and explanations
Situation: I created a Fact Source
FactSource1
with 2 facts in it namedSource1Fact1
&Source1Fact2
, then loaded them in an operation with an adversary that contains a single ability. This ability isecho #{Source1Fact1}
. There is nothing that usesSource1Fact2
.Here's the
fact_store
after running the operation then shutting down the server:Note that facts are loaded all the same whether they are used or not in the operation.
Now for the tests:
PUT
to/api/v2/sources/xxx
with the fact removed from the json, which makes sense. The Fact Source object is then updated, but here's the first issue: both facts, including the deleted one, are still infact_store
exactly the same. For now, this does not raise any visible problem. But start a new operation that usesFactSource1
as Fact Source and has an ability that usesSource1Fact1
... And it somehow finds it, even though this fact does not exist in the Fact Source. The cause seems to beOperation.all_facts()
with the lineseeded_facts = await knowledge_svc_handle.get_facts(criteria=dict(source=self.source.id))
. As we saw, the deleted fact remains in thefact_store
, so this line finds every fact that has ever been loaded from this specific Fact Source.PUT
to/api/v2/sources/xxx
, which updates the Fact Source but keeps previously loaded values the same in the internal store:I tried quite a bit to modify the method that updates fact sources by trying to keep track of old configurations to be able to reflect changes on the internal fact store, but with not much of a satisfactory result. However, a much more straightforward way I found was, at the operation's start, to retrieve the facts directly from the Fact Source object itself instead of the
fact_store
/fact_ram
(commits a253e6b & 3ad8849).This solves the issue and should not have any side effect since it uses a new method without changing
knowledge_svc
.Item 3 & 4
fact_store
(rules are unaffected in my tests)fact_store
fact_store
fact_store
Checklist: