• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanopub-query / 24898561524

24 Apr 2026 03:49PM UTC coverage: 59.461% (-5.1%) from 64.515%
24898561524

push

github

web-flow
Merge pull request #80 from knowledgepixels/feature/62-spaces-materializer-2a

feat: materializer scaffolding — mirror + pointer + orphan cleanup (#62, PR 2a/3)

385 of 738 branches covered (52.17%)

Branch coverage included in aggregate %.

1048 of 1672 relevant lines covered (62.68%)

9.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.67
src/main/java/com/knowledgepixels/query/vocabulary/SpacesVocab.java
1
package com.knowledgepixels.query.vocabulary;
2

3
import org.eclipse.rdf4j.model.IRI;
4
import org.eclipse.rdf4j.model.ValueFactory;
5
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
6
import org.nanopub.vocabulary.NPA;
7

8
/**
9
 * IRIs, prefixes and subject-minting helpers used by the space-extraction layer
10
 * (see {@code doc/plan-space-repositories.md}).
11
 *
12
 * <p>Every extraction entry in {@code npa:spacesGraph} has a dedicated subject IRI
13
 * derived from the originating nanopub's trusty-URI artifact code, so subjects
14
 * never collide with user nanopub IRIs, role IRIs, or anything else a nanopub
15
 * might declare types on. Prefixes:
16
 *
17
 * <ul>
18
 *   <li>{@link #NPAS_NAMESPACE} ({@code npas:}) — {@link #forSpaceRef(String) space-ref} IRIs for aggregate {@link #SPACE_REF} entries.
19
 *   <li>{@link #NPADEF_NAMESPACE} ({@code npadef:}) — {@link #forSpaceDefinition(String) per-contributor} {@link #SPACE_DEFINITION} entries.
20
 *   <li>{@link #NPARI_NAMESPACE} ({@code npari:}) — {@link #forRoleInstantiation(String) role-instantiation} entries.
21
 *   <li>{@link #NPARA_NAMESPACE} ({@code npara:}) — {@link #forRoleAssignment(String) role-attachment} entries (from {@code gen:hasRole} nanopubs).
22
 *   <li>{@link #NPARD_NAMESPACE} ({@code npard:}) — {@link #forRoleDeclaration(String) role-declaration} entries (from {@code gen:SpaceMemberRole} nanopubs).
23
 *   <li>{@link #NPAINV_NAMESPACE} ({@code npainv:}) — {@link #forInvalidation(String) invalidation} entries.
24
 *   <li>{@link #NPASS_NAMESPACE} ({@code npass:}) — space-state graph IRIs (used by the materializer in a later PR).
25
 * </ul>
26
 */
27
public final class SpacesVocab {
28

29
    private static final ValueFactory vf = SimpleValueFactory.getInstance();
6✔
30

31
    /** Namespace for aggregate space-ref entries ({@code npas:<spaceRef>}). */
32
    public static final String NPAS_NAMESPACE = "http://purl.org/nanopub/admin/space/";
33
    /** Namespace for per-contributor space-definition entries ({@code npadef:<artifactCode>}). */
34
    public static final String NPADEF_NAMESPACE = "http://purl.org/nanopub/admin/spacedef/";
35
    /** Namespace for role-instantiation entries ({@code npari:<artifactCode>}). */
36
    public static final String NPARI_NAMESPACE = "http://purl.org/nanopub/admin/roleinst/";
37
    /** Namespace for role-attachment entries ({@code npara:<artifactCode>}). */
38
    public static final String NPARA_NAMESPACE = "http://purl.org/nanopub/admin/roleassign/";
39
    /** Namespace for role-declaration entries ({@code npard:<artifactCode>}). */
40
    public static final String NPARD_NAMESPACE = "http://purl.org/nanopub/admin/roledecl/";
41
    /** Namespace for invalidation entries ({@code npainv:<artifactCode>}). */
42
    public static final String NPAINV_NAMESPACE = "http://purl.org/nanopub/admin/invalidation/";
43
    /** Namespace for space-state graph IRIs ({@code npass:<trustStateHash>_<loadCounter>}). */
44
    public static final String NPASS_NAMESPACE = "http://purl.org/nanopub/admin/spacestate/";
45

46
    // -------- RDF types on extraction entries --------
47

48
    /** RDF type for the aggregate per-space entry keyed by its space ref. */
49
    public static final IRI SPACE_REF = vf.createIRI(NPA.NAMESPACE, "SpaceRef");
15✔
50

51
    /** RDF type for the per-contributor space-definition entry. */
52
    public static final IRI SPACE_DEFINITION = vf.createIRI(NPA.NAMESPACE, "SpaceDefinition");
15✔
53

54
    /** RDF type for the summarized role-definition entry. */
55
    public static final IRI ROLE_DECLARATION = vf.createIRI(NPA.NAMESPACE, "RoleDeclaration");
15✔
56

57
    /** RDF type for an invalidation event recorded as add-only data. */
58
    public static final IRI INVALIDATION = vf.createIRI(NPA.NAMESPACE, "Invalidation");
15✔
59

60
    // -------- Properties on extraction entries --------
61

62
    /** Links a space-ref aggregate to its user-facing Space IRI. */
63
    public static final IRI SPACE_IRI = vf.createIRI(NPA.NAMESPACE, "spaceIri");
15✔
64

65
    /** Links a space-ref aggregate to its root nanopub URI. */
66
    public static final IRI ROOT_NANOPUB = vf.createIRI(NPA.NAMESPACE, "rootNanopub");
15✔
67

68
    /** Links a {@link #SPACE_REF} to each contributing nanopub URI (root + updates). */
69
    public static final IRI HAS_DEFINITION = vf.createIRI(NPA.NAMESPACE, "hasDefinition");
15✔
70

71
    /** Links a {@link #SPACE_DEFINITION} back to its parent {@link #SPACE_REF}. */
72
    public static final IRI FOR_SPACE_REF = vf.createIRI(NPA.NAMESPACE, "forSpaceRef");
15✔
73

74
    /** Trust-seed admin agents attached to a root {@link #SPACE_DEFINITION}. */
75
    public static final IRI HAS_ROOT_ADMIN = vf.createIRI(NPA.NAMESPACE, "hasRootAdmin");
15✔
76

77
    /** Links any extraction entry to the nanopub it was derived from. */
78
    public static final IRI VIA_NANOPUB = vf.createIRI(NPA.NAMESPACE, "viaNanopub");
15✔
79

80
    /** Links an extraction entry to its target space by Space IRI. */
81
    public static final IRI FOR_SPACE = vf.createIRI(NPA.NAMESPACE, "forSpace");
15✔
82

83
    /** Links an extraction entry to the assigned/admin'd agent (multi-valued for root admin lists). */
84
    public static final IRI FOR_AGENT = vf.createIRI(NPA.NAMESPACE, "forAgent");
15✔
85

86
    /** The "regular" direction predicate used in the source assertion (space &rarr; agent). */
87
    public static final IRI REGULAR_PROPERTY = vf.createIRI(NPA.NAMESPACE, "regularProperty");
15✔
88

89
    /** The "inverse" direction predicate used in the source assertion (agent &rarr; space). */
90
    public static final IRI INVERSE_PROPERTY = vf.createIRI(NPA.NAMESPACE, "inverseProperty");
15✔
91

92
    /** Literal pubkey hash stamped alongside {@link org.nanopub.vocabulary.NPX#SIGNED_BY}. */
93
    public static final IRI PUBKEY_HASH = vf.createIRI(NPA.NAMESPACE, "pubkeyHash");
15✔
94

95
    /** Links a {@link #ROLE_DECLARATION} to the actual role IRI embedded in the defining nanopub. */
96
    public static final IRI ROLE = vf.createIRI(NPA.NAMESPACE, "role");
15✔
97

98
    /** Tier class of a {@link #ROLE_DECLARATION}: gen:MaintainerRole / MemberRole / ObserverRole. */
99
    public static final IRI HAS_ROLE_TYPE = vf.createIRI(NPA.NAMESPACE, "hasRoleType");
15✔
100

101
    /** Links an {@link #INVALIDATION} entry to the nanopub it invalidates. */
102
    public static final IRI INVALIDATES = vf.createIRI(NPA.NAMESPACE, "invalidates");
15✔
103

104
    // -------- Named graphs & repo pointers --------
105

106
    /** Named graph in the {@code spaces} repo that holds all extraction triples. */
107
    public static final IRI SPACES_GRAPH = vf.createIRI(NPA.NAMESPACE, "spacesGraph");
15✔
108

109
    /** Pointer predicate for the currently-active space-state graph. */
110
    public static final IRI HAS_CURRENT_SPACE_STATE = vf.createIRI(NPA.NAMESPACE, "hasCurrentSpaceState");
15✔
111

112
    /** Repo-wide counter tracking the highest load number seen by the extractor. */
113
    public static final IRI CURRENT_LOAD_COUNTER = vf.createIRI(NPA.NAMESPACE, "currentLoadCounter");
15✔
114

115
    /** Load-number horizon that a given space-state graph has been brought up to. */
116
    public static final IRI PROCESSED_UP_TO = vf.createIRI(NPA.NAMESPACE, "processedUpTo");
18✔
117

118
    // -------- Subject-minting helpers --------
119

120
    /** Mints {@code npas:<spaceRef>} for an aggregate space-ref entry. */
121
    public static IRI forSpaceRef(String spaceRef) {
122
        return vf.createIRI(NPAS_NAMESPACE, spaceRef);
15✔
123
    }
124

125
    /** Mints {@code npadef:<artifactCode>} for a space-definition entry. */
126
    public static IRI forSpaceDefinition(String artifactCode) {
127
        return vf.createIRI(NPADEF_NAMESPACE, artifactCode);
15✔
128
    }
129

130
    /** Mints {@code npari:<artifactCode>} for a role-instantiation entry. */
131
    public static IRI forRoleInstantiation(String artifactCode) {
132
        return vf.createIRI(NPARI_NAMESPACE, artifactCode);
15✔
133
    }
134

135
    /** Mints {@code npara:<artifactCode>} for a role-attachment entry. */
136
    public static IRI forRoleAssignment(String artifactCode) {
137
        return vf.createIRI(NPARA_NAMESPACE, artifactCode);
15✔
138
    }
139

140
    /** Mints {@code npard:<artifactCode>} for a role-declaration entry. */
141
    public static IRI forRoleDeclaration(String artifactCode) {
142
        return vf.createIRI(NPARD_NAMESPACE, artifactCode);
15✔
143
    }
144

145
    /** Mints {@code npainv:<artifactCode>} for an invalidation entry. */
146
    public static IRI forInvalidation(String artifactCode) {
147
        return vf.createIRI(NPAINV_NAMESPACE, artifactCode);
15✔
148
    }
149

150
    /**
151
     * Mints {@code npass:<trustStateHash>_<loadCounterAtBuildStart>} for a space-state graph.
152
     *
153
     * @param trustStateHash       the source trust-state hash
154
     * @param loadCounterAtBuildStart the value of {@code npa:currentLoadCounter} when the build kicked off
155
     * @return the graph IRI
156
     */
157
    public static IRI forSpaceState(String trustStateHash, long loadCounterAtBuildStart) {
158
        return vf.createIRI(NPASS_NAMESPACE, trustStateHash + "_" + loadCounterAtBuildStart);
×
159
    }
160

161
    private SpacesVocab() {
162
    }
163

164
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc