Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This project _loosely_ adheres to [Semantic Versioning](https://semver.org/spec/
- Show an error when the code is wrong. [PR#502](https://github.com/coasys/ad4m/pull/502)
- Error handling in connect when hosting is not working [PR#502](https://github.com/coasys/ad4m/pull/502)
- Make new Rust create_subject() implementation wait for Prolog engine to be updated, reflecting the new instance to avoid race conditions [PR#520](https://github.com/coasys/ad4m/pull/520)
- Fix problems with Subject Classes created by other non-progenitor agents, and make isSubjectInstance() more stable agains race conditions [PR#521](https://github.com/coasys/ad4m/pull/521)

### Added
- Prolog predicates needed in new Flux mention notification trigger:
Expand Down
11 changes: 10 additions & 1 deletion core/src/perspectives/PerspectiveProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,16 @@ export class PerspectiveProxy {
*/
async isSubjectInstance<T>(expression: string, subjectClass: T): Promise<boolean> {
let className = await this.stringOrTemplateObjectToSubjectClass(subjectClass)
return await this.infer(`subject_class("${className}", C), instance(C, "${expression}")`)
let isInstance = false;
const maxAttempts = 5;
let attempts = 0;

while (attempts < maxAttempts && !isInstance) {
isInstance = await this.infer(`subject_class("${className}", C), instance(C, "${expression}")`);
attempts++;
}

return isInstance
}


Expand Down
11 changes: 9 additions & 2 deletions rust-executor/src/perspectives/perspective_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::update_perspective;
use super::utils::{
prolog_get_all_string_bindings, prolog_get_first_string_binding, prolog_resolution_to_string,
};
use crate::agent::create_signed_expression;
use crate::agent::{self, create_signed_expression};
use crate::graphql::graphql_types::{
DecoratedPerspectiveDiff, ExpressionRendered, JsResultType, LinkMutations, LinkQuery,
LinkStatus, NeighbourhoodSignalFilter, OnlineAgent, PerspectiveExpression, PerspectiveHandle,
Expand Down Expand Up @@ -889,8 +889,15 @@ impl PerspectiveInstance {
})
.await?;

let author = agent::did();

let mut sdna_links: Vec<Link> = Vec::new();

let links = links
.into_iter()
.filter(|l| l.author == author)
.collect::<Vec<DecoratedLinkExpression>>();

if (Literal::from_url(sdna_code.clone())).is_err() {
sdna_code = Literal::from_string(sdna_code)
.to_url()
Expand All @@ -905,7 +912,7 @@ impl PerspectiveInstance {
});

sdna_links.push(Link {
source: literal_name,
source: literal_name.clone(),
predicate: Some("ad4m://sdna".to_string()),
target: sdna_code,
});
Expand Down