@prefix this: . @prefix sub: . @prefix np: . @prefix dct: . @prefix nt: . @prefix npx: . @prefix xsd: . @prefix rdfs: . @prefix orcid: . @prefix prov: . @prefix foaf: . sub:Head { this: a np:Nanopublication; np:hasAssertion sub:assertion; np:hasProvenance sub:provenance; np:hasPublicationInfo sub:pubinfo . } sub:assertion { sub:get-intro-recommendations a ; dct:description "Returns recommended introduction actions for a given user, only when the viewer is that user themselves (owner gate ?__CURRENTUSER_multi_iri = ?_user_iri). One row per applicable recommendation, each carrying a ?recommendation text. A 'local introduction' is defined exactly as the UI's isIntroWithLocalKey: SIGNED BY the local key (?__LOCALPUBKEY_multi), DECLARING it, with the local-key declaration's location absent or matching ?__SITEURL_multi (nanobench->nanodash); localCount counts those. Branches: (1) create — localCount=0 (directs the user to the 'Create Introduction' button above); (2) get-approval — localCount=1 and the local key is not approved in the trust repo (carries the intro nanopub); (3) derive — localCount=0 but the user has introductions elsewhere; (4) retract — localCount>1; (5) update-approved — localCount>0, the local key is not approved, but the user has another approved key in the trust repo. No rows for non-owners or logged-out viewers."; dct:license ; rdfs:label "Get introduction recommendations"; ; """prefix np: prefix npx: prefix npa: select ?recommendation ?intro_np where { values ?__CURRENTUSER_multi_iri {} filter(?_user_iri = ?__CURRENTUSER_multi_iri) { # (1) create: no local introduction yet values ?__LOCALPUBKEY_multi {} values ?__SITEURL_multi {} filter(bound(?__LOCALPUBKEY_multi)) { select (count(distinct ?lnp) as ?localCount) where { values ?__LOCALPUBKEY_multi {} values ?__SITEURL_multi {} graph npa:graph { ?lnp npa:hasValidSignatureForPublicKey ?lsign . filter not exists { ?lnpx npx:invalidates ?lnp ; npa:hasValidSignatureForPublicKey ?lsign . } ?lnp np:hasAssertion ?la . } graph ?la { ?lkd npx:declaredBy ?_user_iri ; npx:hasPublicKey ?lpubkey . optional { ?lkd npx:hasKeyLocation ?lloc . } } filter(coalesce(str(?lsign) = str(?__LOCALPUBKEY_multi), false)) filter(coalesce(str(?lpubkey) = str(?__LOCALPUBKEY_multi), false)) filter(!bound(?lloc) || coalesce(str(?lloc) = str(?__SITEURL_multi), false) || coalesce(replace(str(?lloc), \"nanobench\", \"nanodash\") = str(?__SITEURL_multi), false)) } } filter(?localCount = 0) bind(\"The local key from this site is not part of an introduction yet. Use the 'Create Introduction' button above to link it to your identity.\" as ?recommendation) } union { # (2) get-approval: exactly one local introduction, not yet approved values ?__LOCALPUBKEY_multi {} values ?__SITEURL_multi {} filter(bound(?__LOCALPUBKEY_multi)) { select (count(distinct ?lnp) as ?localCount) (sample(?lnp) as ?localIntroNp) where { values ?__LOCALPUBKEY_multi {} values ?__SITEURL_multi {} graph npa:graph { ?lnp npa:hasValidSignatureForPublicKey ?lsign . filter not exists { ?lnpx npx:invalidates ?lnp ; npa:hasValidSignatureForPublicKey ?lsign . } ?lnp np:hasAssertion ?la . } graph ?la { ?lkd npx:declaredBy ?_user_iri ; npx:hasPublicKey ?lpubkey . optional { ?lkd npx:hasKeyLocation ?lloc . } } filter(coalesce(str(?lsign) = str(?__LOCALPUBKEY_multi), false)) filter(coalesce(str(?lpubkey) = str(?__LOCALPUBKEY_multi), false)) filter(!bound(?lloc) || coalesce(str(?lloc) = str(?__SITEURL_multi), false) || coalesce(replace(str(?lloc), \"nanobench\", \"nanodash\") = str(?__SITEURL_multi), false)) } } filter(?localCount = 1) bind(lcase(sha256(str(?__LOCALPUBKEY_multi))) as ?lpkHash) filter not exists { service { graph npa:graph { npa:thisRepo npa:hasCurrentTrustState ?tg . } graph ?tg { ?acct npa:agent ?_user_iri ; npa:pubkey ?lpkHash ; npa:trustStatus npa:loaded . } } } bind(\"Your introduction with the local key is not approved yet. Share it so a maintainer can approve it:\" as ?recommendation) bind(?localIntroNp as ?intro_np) } union { # (3) derive: no local introduction, but the user has introductions elsewhere values ?__LOCALPUBKEY_multi {} values ?__SITEURL_multi {} filter(bound(?__LOCALPUBKEY_multi)) { select (count(distinct ?lnp) as ?localCount) where { values ?__LOCALPUBKEY_multi {} values ?__SITEURL_multi {} graph npa:graph { ?lnp npa:hasValidSignatureForPublicKey ?lsign . filter not exists { ?lnpx npx:invalidates ?lnp ; npa:hasValidSignatureForPublicKey ?lsign . } ?lnp np:hasAssertion ?la . } graph ?la { ?lkd npx:declaredBy ?_user_iri ; npx:hasPublicKey ?lpubkey . optional { ?lkd npx:hasKeyLocation ?lloc . } } filter(coalesce(str(?lsign) = str(?__LOCALPUBKEY_multi), false)) filter(coalesce(str(?lpubkey) = str(?__LOCALPUBKEY_multi), false)) filter(!bound(?lloc) || coalesce(str(?lloc) = str(?__SITEURL_multi), false) || coalesce(replace(str(?lloc), \"nanobench\", \"nanodash\") = str(?__SITEURL_multi), false)) } } filter(?localCount = 0) filter exists { graph npa:graph { ?unp npa:hasValidSignatureForPublicKey ?uk . filter not exists { ?unpx npx:invalidates ?unp ; npa:hasValidSignatureForPublicKey ?uk . } ?unp np:hasAssertion ?ua . } graph ?ua { ?ukd npx:declaredBy ?_user_iri ; npx:hasPublicKey ?ukey . } } bind(\"You have introductions elsewhere, but none with this site's local key. Use 'derive new introduction' in the table below to declare those keys alongside the local key.\" as ?recommendation) } union { # (4) retract: more than one local introduction values ?__LOCALPUBKEY_multi {} values ?__SITEURL_multi {} filter(bound(?__LOCALPUBKEY_multi)) { select (count(distinct ?lnp) as ?localCount) where { values ?__LOCALPUBKEY_multi {} values ?__SITEURL_multi {} graph npa:graph { ?lnp npa:hasValidSignatureForPublicKey ?lsign . filter not exists { ?lnpx npx:invalidates ?lnp ; npa:hasValidSignatureForPublicKey ?lsign . } ?lnp np:hasAssertion ?la . } graph ?la { ?lkd npx:declaredBy ?_user_iri ; npx:hasPublicKey ?lpubkey . optional { ?lkd npx:hasKeyLocation ?lloc . } } filter(coalesce(str(?lsign) = str(?__LOCALPUBKEY_multi), false)) filter(coalesce(str(?lpubkey) = str(?__LOCALPUBKEY_multi), false)) filter(!bound(?lloc) || coalesce(str(?lloc) = str(?__SITEURL_multi), false) || coalesce(replace(str(?lloc), \"nanobench\", \"nanodash\") = str(?__SITEURL_multi), false)) } } filter(?localCount > 1) bind(\"You have multiple introductions from this site. Use 'retract' in the table below to remove the redundant ones.\" as ?recommendation) } union { # (5) update-approved: local key not approved, but the user has another approved key values ?__LOCALPUBKEY_multi {} values ?__SITEURL_multi {} filter(bound(?__LOCALPUBKEY_multi)) { select (count(distinct ?lnp) as ?localCount) where { values ?__LOCALPUBKEY_multi {} values ?__SITEURL_multi {} graph npa:graph { ?lnp npa:hasValidSignatureForPublicKey ?lsign . filter not exists { ?lnpx npx:invalidates ?lnp ; npa:hasValidSignatureForPublicKey ?lsign . } ?lnp np:hasAssertion ?la . } graph ?la { ?lkd npx:declaredBy ?_user_iri ; npx:hasPublicKey ?lpubkey . optional { ?lkd npx:hasKeyLocation ?lloc . } } filter(coalesce(str(?lsign) = str(?__LOCALPUBKEY_multi), false)) filter(coalesce(str(?lpubkey) = str(?__LOCALPUBKEY_multi), false)) filter(!bound(?lloc) || coalesce(str(?lloc) = str(?__SITEURL_multi), false) || coalesce(replace(str(?lloc), \"nanobench\", \"nanodash\") = str(?__SITEURL_multi), false)) } } filter(?localCount > 0) bind(lcase(sha256(str(?__LOCALPUBKEY_multi))) as ?lpkHash) filter not exists { service { graph npa:graph { npa:thisRepo npa:hasCurrentTrustState ?tg . } graph ?tg { ?acct npa:agent ?_user_iri ; npa:pubkey ?lpkHash ; npa:trustStatus npa:loaded . } } } filter exists { service { graph npa:graph { npa:thisRepo npa:hasCurrentTrustState ?tg2 . } graph ?tg2 { ?acct2 npa:agent ?_user_iri ; npa:pubkey ?okHash ; npa:trustStatus npa:loaded . filter(?okHash != ?lpkHash) } } } bind(\"Your local key is not approved, but you have an approved introduction elsewhere. Add this site's local key to that approved introduction, at the site where you created it.\" as ?recommendation) } }""" . } sub:provenance { sub:assertion prov:wasAttributedTo orcid:0000-0002-1267-0234 . } sub:pubinfo { orcid:0000-0002-1267-0234 foaf:name "Tobias Kuhn" . this: dct:created "2026-06-10T11:23:58Z"^^xsd:dateTime; dct:creator orcid:0000-0002-1267-0234; dct:license ; npx:embeds sub:get-intro-recommendations; npx:supersedes ; nt:wasCreatedFromProvenanceTemplate ; nt:wasCreatedFromPubinfoTemplate , , ; nt:wasCreatedFromTemplate . sub:sig npx:hasAlgorithm "RSA"; npx:hasPublicKey "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwUtewGCpT5vIfXYE1bmf/Uqu1ojqnWdYxv+ySO80ul8Gu7m8KoyPAwuvaPj0lvPtHrg000qMmkxzKhYknEjq8v7EerxZNYp5B3/3+5ZpuWOYAs78UnQVjbHSmDdmryr4D4VvvNIiUmd0yxci47dTFUj4DvfHnGd6hVe5+goqdcwIDAQAB"; npx:hasSignature "Yiy+3fqb9YhejrAdlHI+0Hya50+MdF1+E5N+T08bFE8MS3g5prRh7+7Uc9yEaEdPYET1x2vRUVIOXF+K0IiVMKfRmbkd1QWaUiKBUPnuriMhlD3JWVMalU37IkLv54qlvZHQQBPNiNNletcEYlECkuwhtfu6kEs8xU0NTA/MEb0="; npx:hasSignatureTarget this:; npx:signedBy orcid:0000-0002-1267-0234 . }