Metadata-Version: 2.5
Name: cf-package-registry
Version: 0.1.3
Summary: Package-local Cogniflow developer services for UDE GitLab CF package admission.
Author: Cogniflow Maintainers
Requires-Python: >=3.13
Description-Content-Type: text/markdown

# cf-package-registry

An optional developer CF package. The GitLab Knowledge Hub owns registration and semantic admission authority. The original five package operations remain available as Python functions and through Cogniflow's existing `cf.service.executor.v1` and `PythonFunctionExecutorV1`:

- `preflight_cf_package`: bounded read-only structure and Stonecastle dependency preflight. Advisory only, no SHACL admission or candidate-code execution.
- `register_cf_package`: explicitly confirmed, token-authenticated GitLab pipeline request identifying a **published Production PyPI distribution/version**, not a local wheel upload.
- `get_cf_package_registration_status`: inspect pipeline progress and the exact reviewed admission record on the protected GitLab branch. **Pipeline success is not registration.**
- `list_registered_cf_modules`: read the public catalog without credentials, or read the reviewed catalog at an immutable GitLab commit with a token. Select latest stable versions and optionally a capability IRI.
- `get_cf_module_semantics`: retrieve the exact named RDF sources for a catalog entry at that same commit (refresh discovery if main advanced), checking snapshot and individual source hashes.

Source layout and semantic metadata follow `cf_concept_package` (the concept contract), `cf_package_template_basic` (the template implementation), and `cf_concept_service` (the service contract). `pyproject.toml` publishes `cogniflow.semantic_sources`. The optional developer-profile integration must be added to a governed Cogniflow release only after validation; this branch does **not** alter any currently accepted/frozen installation profile.

## GitLab configuration

The HTTPS origin, project path and ref are currently bound to the institutional GitLab project:

`https://git.uni-due.de/odea-project/cogniflow/knowledge-hub` (provisioned; admission remains gated)

For authenticated requests, the local environment variable `CF_REGISTRY_GITLAB_TOKEN` must contain a GitLab token with the appropriate authorized API scope. Never place the token in service inputs, manifests, logs, repository files or evidence. The user must explicitly confirm every submission. This is a real GitLab API client, not a fake or locally admitted service.

**Deployed foundation:** SDK 0.1.0 is published on [PyPI](https://pypi.org/project/cf-package-registry/0.1.0/) and registered through [Hub MR !7](https://git.uni-due.de/odea-project/cogniflow/knowledge-hub/-/merge_requests/7). Its actual Production PyPI validation pipeline [198485](https://git.uni-due.de/odea-project/cogniflow/knowledge-hub/-/pipelines/198485) passed. The existing shared runner and fixed private Java/Jena image require no UDE operator involvement.

**Historical 0.1.1 source work:** the package manifest now declares its description and authoring team as linked semantic attributes, with matching Python metadata. Paired `cf_concept_package` shapes make descriptions and named authors mandatory for future validation. The Hub exposes these under `package_metadata` in snapshots and discovery entries; legacy wheel `authors` and authenticated GitLab registrators remain separate. Names and optional identifiers are declarations, not verified identities. Historical 0.1.0 evidence remains unchanged. This candidate has not been released or registered.

**Status authority:** REGISTERED requires a successful API pipeline on protected main, positive validation, matching artifact hash and policy revisions, and a separately reviewed admission record. Discovery grants no bootstrap installation authority.

Without a token, listing uses the [public GitLab Pages catalog](https://knowledge-hub-b945cd.gitpages.uni-due.de/catalog.json). Public entries provide versions, capabilities, concept assignments and declared package metadata when available. They return `source_commit=None`. Set a token and list again to retrieve entries for `get_cf_module_semantics`, which reads the full RDF sources from the protected Hub.

## Dependency rule and account identity

The unchanged Stonecastle scanner is vendored from upstream commit
`e3b89012651c4db749491df0a3df07c5df4c1cac`; its exact source hash and original path
are recorded in `src/cf_package_registry/dependency-rules-provenance.json` and
checked before use. Direct dependencies on other CF modules are rejected in
project metadata, Python imports and statically visible module invocations.
Normal third-party libraries are allowed. Historical repository exemptions do
not apply to new submissions. Static inspection cannot prove the absence of
arbitrary dynamic behavior.

Each user supplies their own GitLab token locally. Submission receipts and
status responses take the registrator ID/username from GitLab's pipeline user,
never from a service input. A missing server identity is returned as null and
cannot become a complete reviewed catalog record. Package authors and
maintainers are declared wheel metadata, explicitly distinct from authenticated
registrators and reviewers.

## Python API

```python
from cf_package_registry import (
    preflight_cf_package, register_cf_package,
    get_cf_package_registration_status,
    list_registered_cf_modules, get_cf_module_semantics,
)

preflight = preflight_cf_package("/path/to/repository", "stonecastle/cf_example")
# After the reviewed Hub changes are merged and submission is explicitly authorized:
# receipt = register_cf_package("cf-example", "1.0.0", confirm_submit=True)
# status = get_cf_package_registration_status(receipt["submission_id"], receipt["pipeline_id"])

# Once a reviewed catalog has actually been published:
# listing = list_registered_cf_modules(latest_only=True)
# details = get_cf_module_semantics(
#     source_commit=listing["source_commit"], entry=listing["entries"][0])
```

The catalog includes versions, artifact hashes, authors, registrators, reviewed
validation provenance, capabilities and explicit concept/type assignments.
Full sources preserve relationships beyond the search index. Discovery returns
`installation_authorized=False`: a future bootstrap must separately verify its
installation policy and signed selection. Missing catalog data raises
`CATALOG_NOT_PUBLISHED`; it never produces a fabricated list.

## Semantic metadata contract

`cf_concept_package` defines `PackageDescription`, `PackageAuthor`, `PackageAuthorName` and optional `PackageAuthorIdentifier`. The manifest links them through their matching `hasX` relations. Descriptions may be language-tagged. Author names must be non-empty; email addresses are not required. PyPI author metadata cannot fill missing semantic declarations.

The full exact RDF sources preserve this information, while the Hub's `package_metadata` search fields make it directly accessible to the later bootstrap. The original five Python/service operations and service protocol are preserved. Concept assignments remain explicit; no package is assigned to a concept merely from its name.

See [the contract decision](../docs/adr/package-description-authorship.md). The new policy and this source candidate require coordinated review. No frozen installation profile, signing policy or existing PyPI artifact is modified.

An installer can discover the anonymous registry reader through the
`cogniflow.registry_discovery.v1` entry-point group. It uses JSON-RPC over
stdio with protocol `cf.registry.discovery.v1` and method `registry/list`.
The subprocess uses the public catalog even when a GitLab token is present.

## Independent profiles — source candidate 0.1.3.dev0

**Not uploaded or frozen.** The new profile endpoints and admission contracts
are fixture-tested contracts for the companion Hub stage, **not deployed endpoint
claims**. No TUI/installer integration or package-registration behavior changes.

An InstallationProfile is standalone bounded UTF-8 TriG data, never a dummy
package or service. Its immutable identity is (absolute profile IRI, canonical
SemVer content version), bound to SHA256 of the exact raw document bytes. Hub
admission must reject different bytes for an existing identity. Line endings are
significant. The independent document schema is cf.installation-profile.v1;
it does not pin profile content to 1.0.0.

### Python/service API

Six additional functions are exposed through cf.service.executor.v1 with the
same keyword inputs and JSON-valued service inputs (document is a JSON string):

- preflight_cf_profile(document, profile_iri, version, *, expected_sha256=None)
- register_cf_profile(document, profile_iri, version, *, expected_sha256=None, confirm_submit=False)
- get_cf_profile_registration_status(receipt)
- list_registered_cf_profiles(*, snapshot_revision=None, snapshot_sha256=None)
- get_registered_cf_profile(profile_iri, version, *, snapshot_revision, snapshot_sha256)
- list_cf_profile_candidates(profile_iri, version, *, snapshot_revision, snapshot_sha256)

Python accepts bytes or str documents, limited to 256 KiB strict UTF-8, without
line-ending normalization. Local checks cover IRI/version arguments, bounds,
checksum and submission envelope only. Preflight reports envelope_passed=true,
authority=LOCAL_ADVISORY_ONLY, semantic_validation=SERVER_SIDE_PENDING,
admission_validated=false and installation_authorized=false. It deliberately
**does not parse RDF or claim semantic admission**. The SDK imports no other CF
package and has no rdflib runtime dependency.

The reusable full parser is
cf_bootstrap_source_local.profile_document.parse_profile_document(bytes,
requested_iri=None, requested_version=None). It uses the existing InstallationProfile
vocabulary and bounded absolute semantic capability IRIs (including snake_case URNs
and HTTPS IRIs), rejecting malformed TriG/UTF-8,
more than 4096 statements, duplicate statements/attributes/capabilities, extra
subjects, ontology definitions, literal shortcuts and unrequested verification
capabilities. Independent canonical SemVer versions (including prereleases) are
accepted. All four single bounded string documentation properties are required:
skos:prefLabel, skos:definition, skos:scopeNote and skos:example. Results expose
label, description, scope_note and example as {text, language}. This RDF-dependent module is for isolated validation, not SDK imports.
The companion Hub worker must run full RDF/SHACL and approved-capability policy
validation with no candidate-code execution. The historical local adapter keeps
its previous Version("1.0.0") equality behavior, including equivalent supported
spellings, and LF-normalized digest. Local catalogs/frozen profiles are unchanged.

~~~python
from cf_package_registry import (
    preflight_cf_profile, list_registered_cf_profiles,
    get_registered_cf_profile, list_cf_profile_candidates,
)
report = preflight_cf_profile(document_bytes, "urn:cf:profile:example", "2.0.0")
# Only after companion Hub deployment:
# listing = list_registered_cf_profiles()
# pins = {k: listing[k] for k in ("snapshot_revision", "snapshot_sha256")}
# profile = get_registered_cf_profile("urn:cf:profile:example", "2.0.0", **pins)
# candidates = list_cf_profile_candidates("urn:cf:profile:example", "2.0.0", **pins)
~~~

### Anonymous profiles.json v1

The fixed public origin is https://knowledge-hub-b945cd.gitpages.uni-due.de/ .
No token is read/sent even if CF_REGISTRY_GITLAB_TOKEN exists. Redirects are
rejected and final URLs must exactly match the requested URL. No caller URL/path
is fetched. Network errors, oversized responses, invalid UTF-8/JSON, duplicate
JSON keys, malformed identities and checksum mismatches fail closed.

The mutable profiles.json pointer is at most 4096 bytes:

~~~json
{
  "schema": "cf.hub.public-profiles.v1",
  "snapshot_revision": "<64 lowercase hex content revision>",
  "snapshot_sha256": "<64 lowercase hex raw snapshot SHA256>",
  "installation_authorized": false
}
~~~

Fetch profiles/snapshots/<snapshot_sha256>.json (maximum 8 MiB), verifying raw
SHA256 before JSON interpretation. The immutable snapshot has schema
cf.hub.public-profile-snapshot.v1, the same snapshot_revision, installation_authorized=false,
and profiles/candidates arrays of at most 1000 entries each. Independently verify
the content revision as SHA256(json.dumps({"profiles": profiles, "candidates": candidates},
sort_keys=True, separators=(",", ":"), ensure_ascii=True).encode("ascii")), with no
trailing newline. The file contains only schema, snapshot_revision, profiles,
candidates and installation_authorized; publication actors/timestamps are not identity.
Both pins are returned
unchanged in every result. Historical content-addressed snapshots/documents must
remain published when the mutable pointer advances. Hashes provide integrity,
**not signatures, semantic admission or installation trust**.

Profile entries:

- kind="installation-profile", profile=absolute IRI, version=canonical exact SemVer;
- document_schema="cf.installation-profile.v1";
- document_sha256=raw UTF-8 checksum, document_path=profiles/documents/<checksum>.trig;
- capabilities=nonempty unique semantic capability IRIs (maximum 256);
- optional post_install_verification_capability, which must be requested;
- identifier: bounded nonempty string; label, description, scope_note and example:
  bounded nonempty {"text": "...", "language": null or language tag};
- optional/null authors: up to 32 declared objects with bounded nonempty name and
  optional email/iri. Missing authors stay missing. Authenticated registrator/reviewer
  metadata is distinct and must never be used to fabricate authors.

Duplicate (IRI, version) identities fail closed. Exact retrieval re-reads the
pinned snapshot, derives the content-addressed path and verifies bounded strict
UTF-8 and raw checksum. It returns schema=cf.registry.profile-result.v1, entry,
document, document_sha256, both pins and installation_authorized=false. Listing
uses cf.registry.profiles-result.v1 with entries and the same pins/authority flag.
There is no silent latest-version fallback.

Provider entries have kind="provider", normalized distribution, exact version,
artifact_sha256, unique capabilities, compatibility="UNASSESSED" and
installation_authorized=false. Their semantic_snapshot descriptor is exactly
{"path": "profiles/providers/<sha256>.json", "sha256": "<sha256>"}. On candidate
consumption the SDK verifies the exact blob checksum, existing
cf.hub.semantic-snapshot.v1 identity, index capabilities and each embedded source's
raw UTF-8 checksum and safe unique relative path. It never parses or runs provider
Python. There is no profile_contracts eligibility gate: independently authored
profiles requesting the same capabilities match the same registered providers.
Duplicate distribution/version identities fail closed, including conflicting digests.
Matching capabilities does not assess host compatibility.

Candidate results use cf.registry.profile-candidates-result.v1. They return all
registered providers matching any required capability from the same snapshot,
entries de-duplicated per distribution/version, per-capability identity references
in matches, missing_capabilities, ambiguous_capabilities and selected_provider=null.
All eligible versions remain visible; multiple versions count as ambiguity. A
provider satisfying several capabilities appears only once in entries. No names
are hardcoded, no provider is selected, and installation_authorized remains false.

### Data-only submission and reviewed status

Submission requires literal confirm_submit=true and the caller's GitLab token.
The SDK authenticates /api/v4/user before writes; the pipeline user must match.
Authors are document declarations, not the token owner. Approved origin/project
and the no-redirect transport are reused. No submission branch code/CI is run.

submission_id = SHA256 of compact ASCII JSON
["installation-profile", profile_iri, version, document_sha256]. POST /repository/commits uses:

- fixed branch profile-submissions/<submission_id>, start_sha from protected main;
- one create action at profile-submissions/<submission_id>.trig, base64 exact bytes;
- commit message beginning [skip ci], suppressing submission-branch CI;
- returned parent_ids exactly [selected main SHA]. The returned immutable commit's
  data is re-read and checksum-verified before pipeline creation.

POST /pipeline runs ref=main only, never the submission branch. Exactly seven small
variables bind the data: CF_PROFILE_ADMISSION_REQUEST=1,
CF_SUBMISSION_KIND=installation-profile, CF_SUBMISSION_ID, CF_PROFILE_IRI,
CF_PROFILE_VERSION, CF_PROFILE_DOCUMENT_SHA256 and CF_PROFILE_SOURCE_COMMIT.
There is no source-path variable. Document bytes are **never pipeline variables**.
The protected-main worker must rederive identity/path, verify immutable source,
checksum and profile IRI/version, then validate RDF as data. It must never execute
submission-branch code or CI. No arbitrary branch/path is a caller input.

Receipts (cf.registry.profile-submission-receipt.v1, kind=installation-profile) bind submission ID,
profile/version, document checksum, source commit/path, policy commit, pipeline ID
and authenticated registrator. They report SUBMITTED_NOT_ADMITTED, approval=false,
installation_authorized=false. A commit may remain if pipeline creation fails;
errors are not admission. There is no destructive cleanup, branch overwrite or
silent retry under a different identity. Repeated submissions reuse the deterministic
source only after verifying its exact bytes, single data-file commit and main
ancestry. Conflicting bytes/provenance are rejected without overwrite; concurrent
creation and lost source responses are resolved by rereading the winner.
Pipeline response loss triggers bounded recovery over at most 20 main/API pipelines
and exact variables/actor checks. If unresolved, the receipt reports
SUBMISSION_OUTCOME_UNRESOLVED and can be checked again or identically resubmitted.
Exactly-once pipeline creation is not promised. A durable reviewed admission for
this submission points to its own original approved pipeline/source/evidence;
a later retry does not replace that chain or need to have the same pipeline ID.
Without admission, pipeline status remains visible as pending/failed/etc., never
registration. Tests use actual Hub-generated current/retained export fixtures;
the supplied admission evidence is explicitly synthetic/offline, not a real
registration or a claim that public endpoints are deployed.

Status requires the complete receipt and authenticated access. It verifies the
pipeline ID, main/API channel, policy SHA, actual pipeline variables, pipeline
registrator and immutable source checksum. A green pipeline alone is NOT_ADMITTED.
REGISTERED additionally requires a separately reviewed protected-main record at
profiles/admissions/<submission_id>.json: schema=cf.hub.profile-admission.v1,
kind=installation-profile, status=REGISTERED, positive integer owner_gitlab_id bound to
the authenticated registrator, nonempty reviewer and exact common evidence bindings.
The owner is bound across versions by Hub policy, never inferred from authors.
The SDK reads the actual successful profile_admission_validate job artifacts
profile-validation-report.json (cf.hub.profile-validation-report.v1) and
profile-snapshot.json (cf.hub.profile-snapshot.v1), verifies both raw SHA256 values
against admission, and binds their job, source, policy, pipeline, actor, profile,
version and document identity. The report must be VALIDATED_AWAITING_APPROVAL,
registered=false, installation_authorized=false with conforming SHACL, verified
data-only/main ancestry, network filter and scratch-only filesystem checks. Its
semantic snapshot checksum must match the actual snapshot and reviewed admission.
The snapshot raw document hash and metadata must match, and report checks.profile
must equal snapshot metadata. Missing or mismatched evidence never registers.
The record is Hub-reviewed semantic-validation evidence,
not a local preflight or package admission. A successful matching main pipeline is
required. Status returns cf.registry.profile-registration-status.v1 and always
installation_authorized=false, including after registration.

### Versioned stdio discovery

The separate cogniflow.registry_discovery.v2 entry point uses the same JSON-RPC
process with protocol=cf.registry.discovery.v2:

- registry/profiles/list: {} or both snapshot pins;
- registry/profiles/get: profile_iri, version and both snapshot pins;
- registry/profiles/candidates: profile_iri, version and both snapshot pins.

Requests contain exactly jsonrpc="2.0", protocol, string id, method and params.
Unknown arguments/operations fail closed. The process exposes reads only, never
submission or installation. cogniflow.registry_discovery.v1 and registry/list v1
byte-level result/envelope contracts are preserved.
