httk.workflow.projects¶
Expose workflow project policy over the project anchor owned by httk.core.project.
The project anchor — the httk_project directory, project.json and its
validation, upward discovery, the identity key, and key pinning and trust —
moved to httk-core as httk.core.project so a core-only installation has
projects. This module re-exports that API unchanged (this is an internal move,
so no deprecation is warranted and every public name keeps working) and keeps
the pieces that are workflow policy rather than anchor:
DEFAULT_MANIFEST_EXCLUSIONSandproject_exclusions()— what a signed manifest never records, which is a property of the manifest format and therefore stays here besidehttk.workflow.manifests. The manifest walker omits directattempts,logs, and.httk-jobchildren only below a directory whose regularjob.jsonparses as anhttk-workflow-joband whose id matches the UUID in its valid job-key basename.initialize_project()andimport_v1_project()— the anchor plus the project’s registered default execution workspace.
Attributes¶
Exceptions¶
Raised when discovery finds an httk v1 |
Functions¶
|
Normalize any accepted public key spelling to the recorded one. |
|
Find the nearest project root, or refuse a legacy one, at or above start. |
|
Return the recorded representation of one raw Ed25519 public key. |
|
Return the stable display fingerprint of one public key. |
|
Decode a recorded public key, accepting the bare base64 spelling too. |
|
Adopt the project's current |
|
Return the project's own pinned public key, or None when absent. |
|
Return where a project keeps its own signing key's public half. |
|
Read and validate the |
|
Return one named object member of |
|
Read one public-key file and return its recorded public key. |
|
Return the nearest project root, refusing when there is none. |
|
Adopt one further public key as a trust anchor of this project. |
|
Return every key metadata pins: the project's own and any adopted one. |
|
Store one named object member of |
|
Initialize the project anchor without creating a workspace. |
|
Create v2 project metadata from a legacy |
|
Return default and configured manifest exclusions. |
Module Contents¶
- httk.workflow.projects.PROJECT_DIRECTORY = 'httk_project'¶
- httk.workflow.projects.PROJECT_FILE = 'project.json'¶
- httk.workflow.projects.PUBLIC_KEY_PREFIX = 'ed25519:'¶
- exception httk.workflow.projects.LegacyProjectError(message, *, root)¶
Bases:
ValueErrorRaised when discovery finds an httk v1
ht.projectdirectory.Carries the offending directory as
rootso a caller that deliberately handles it (for example read-only verification of a v1 manifest) does not have to parse the message.- Parameters:
message (str) – Diagnostic explaining the legacy project and its remedy.
root (pathlib.Path) – Directory containing the legacy project marker.
- root¶
- httk.workflow.projects.canonical_public_key(value)¶
Normalize any accepted public key spelling to the recorded one.
- Parameters:
value (str) – Accepted public-key text to normalize.
- Returns:
Canonical prefixed public-key text.
- Raises:
ValueError – If the public-key text is invalid.
- Return type:
- httk.workflow.projects.discover_project(start=None)¶
Find the nearest project root, or refuse a legacy one, at or above start.
Discovery walks from start and its parents, treating a file start as its containing directory. If it finds a legacy ht.project marker, the exception identifies the required remedy: run httk project import-v1 PATH.
- Parameters:
start (str | os.PathLike[str] | None) – Directory or file from which to begin the upward search, or None for the current directory.
- Returns:
Nearest project root, or None when no marker is found.
- Raises:
httk.core.project.LegacyProjectError – If discovery finds a v1 project marker.
- Return type:
pathlib.Path | None
- httk.workflow.projects.format_public_key(raw)¶
Return the recorded representation of one raw Ed25519 public key.
- Parameters:
raw (bytes) – Raw public-key bytes to record.
- Returns:
Canonical prefixed public-key text.
- Raises:
ValueError – If the key is not 32 bytes long.
- Return type:
- httk.workflow.projects.key_fingerprint(value)¶
Return the stable display fingerprint of one public key.
- Parameters:
value (str) – Public-key text whose fingerprint is calculated.
- Returns:
Stable SHA-256 fingerprint text.
- Raises:
ValueError – If the public-key text is invalid.
- Return type:
- httk.workflow.projects.parse_public_key(value)¶
Decode a recorded public key, accepting the bare base64 spelling too.
- Parameters:
value (str) – Public-key text to decode.
- Returns:
Raw public-key bytes.
- Raises:
ValueError – If the algorithm, encoding, or key length is invalid.
- Return type:
- httk.workflow.projects.pin_project_key(root=None)¶
Adopt the project’s current
keys/project.pubas its trust anchor.Pinning is always an explicit act. Verification trusts the key recorded in
project.jsonand never the key a manifest carries in its own header, so adopting the key that is in the tree right now is exactly the decision an operator has to make consciously for an older project that has no pin.- Parameters:
root (str | os.PathLike[str] | None) – Project root, or None to discover the nearest project.
- Returns:
Updated project metadata.
- Raises:
ValueError – If no project exists or its public key is invalid.
- Return type:
- httk.workflow.projects.pinned_project_key(metadata)¶
Return the project’s own pinned public key, or None when absent.
- Parameters:
metadata (collections.abc.Mapping[str, object]) – Project metadata containing the optional public-key member.
- Returns:
Canonical pinned key, or None when the metadata has no key.
- Raises:
ValueError – If the pinned key is present but invalid.
- Return type:
str | None
- httk.workflow.projects.project_public_key_path(root)¶
Return where a project keeps its own signing key’s public half.
- Parameters:
root (str | os.PathLike[str]) – Project root containing the anchor.
- Returns:
Path to the project’s public key file.
- Return type:
- httk.workflow.projects.read_project(root)¶
Read and validate the
project.jsonof the project rooted at root.- Parameters:
root (str | os.PathLike[str]) – Project root whose manifest is read.
- Returns:
Validated project metadata.
- Raises:
ValueError – If the manifest is not an httk project manifest.
- Return type:
- httk.workflow.projects.read_project_section(root, name)¶
Return one named object member of
project.json, empty when absent.A section is a top-level member of the project manifest that some layer above the anchor owns — the workflow workspace registry, a campaign map — and reads and writes as a whole. The anchor does not interpret the member; it only guarantees that what a caller stores under a name comes back as the object it was, and refuses a member that some other writer has left as a non-object so a caller never silently reads a scalar as a mapping.
- Parameters:
root (str | os.PathLike[str]) – Project root whose manifest is read.
name (str) – Top-level manifest member to retrieve.
- Returns:
A copy of the named object, or an empty object when absent.
- Raises:
ValueError – If the named manifest member is not an object.
- Return type:
- httk.workflow.projects.read_public_key_file(path)¶
Read one public-key file and return its recorded public key.
- Parameters:
path (str | os.PathLike[str]) – Public-key file to read.
- Returns:
Canonical public-key text from the first line.
- Raises:
ValueError – If the file cannot be read, is empty, or contains an invalid key.
- Return type:
- httk.workflow.projects.require_project(start=None)¶
Return the nearest project root, refusing when there is none.
- Parameters:
start (str | os.PathLike[str] | None) – Directory or file from which to begin the upward search, or None for the current directory.
- Returns:
Nearest project root.
- Raises:
httk.core.project.LegacyProjectError – If discovery finds a v1 project marker.
ValueError – If no project marker is found.
- Return type:
- httk.workflow.projects.trust_project_key(root, key)¶
Adopt one further public key as a trust anchor of this project.
- Parameters:
root (str | os.PathLike[str] | None) – Project root, or None to discover the nearest project.
key (str) – Public key to add to the project’s trusted anchors.
- Returns:
Updated project metadata.
- Raises:
ValueError – If no project exists, the key is invalid, or trusted_keys is invalid.
- Return type:
- httk.workflow.projects.trusted_project_keys(metadata)¶
Return every key metadata pins: the project’s own and any adopted one.
The pinned key of
project.jsonis the trust anchor a manifest is checked against.trusted_keyscarries the additional anchors an operator has adopted deliberately — most often the legacy identities an imported httk v1 project signed its old manifests with.- Parameters:
metadata (collections.abc.Mapping[str, object]) – Project metadata whose trust anchors are read.
- Returns:
Unique canonical project and adopted trust anchors.
- Raises:
ValueError – If trusted_keys is not a string array or contains an invalid key.
- Return type:
- httk.workflow.projects.write_project_section(root, name, value)¶
Store one named object member of
project.jsonand return the metadata.The write is an ordinary read-modify-write of the validated manifest, so the members the anchor owns are preserved untouched and only the named section is replaced. The section must be a mapping; the anchor stores its members verbatim without interpreting them.
- Parameters:
root (str | os.PathLike[str]) – Project root whose manifest is updated.
name (str) – Top-level manifest member to replace.
value (collections.abc.Mapping[str, object]) – Object members to store under the name.
- Returns:
Updated project metadata.
- Raises:
ValueError – If the named section is not a mapping.
- Return type:
- httk.workflow.projects.DEFAULT_MANIFEST_EXCLUSIONS¶
- httk.workflow.projects.initialize_project(root, *, name, description='', manifest_exclusions=())¶
Initialize the project anchor without creating a workspace.
- Parameters:
root (str | os.PathLike[str]) – Directory in which to create the project anchor.
name (str) – Project name.
description (str) – Optional project description.
manifest_exclusions (collections.abc.Iterable[str]) – Relative paths excluded from the manifest.
- Returns:
Created project metadata.
- Return type:
- httk.workflow.projects.import_v1_project(root, *, source=None, name=None)¶
Create v2 project metadata from a legacy
ht.projectdirectory.- Parameters:
root (str | os.PathLike[str]) – Directory in which to create the project anchor.
source (str | os.PathLike[str] | None) – Legacy project directory, or the default legacy location.
name (str | None) – Replacement project name, or the legacy name.
- Returns:
Created project metadata.
- Return type:
- httk.workflow.projects.project_exclusions(metadata)¶
Return default and configured manifest exclusions.