Skip to content
Open
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
6 changes: 0 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
//
// Dev Container configuration for systemet
// Works with: VS Code Dev Containers, GitHub Codespaces, Gitpod
// Container runtime: Podman (recommended) or any OCI-compliant runtime
{
"name": "systemet",

Expand Down
2 changes: 2 additions & 0 deletions .devcontainer/devcontainer.json.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
SPDX-License-Identifier: MPL-2.0
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,25 @@ indent_size = 2
indent_style = space
indent_size = 4

# Prose, legal text and proofs use alignment within paragraphs and expressions.
[*.{md,adoc,agda,lean}]
indent_size = unset

[LICENSES/CC-BY-SA-4.0.txt]
indent_size = unset

[docs/legal/EXHIBIT-{A-ETHICAL-USE,B-QUANTUM-SAFE}.txt]
indent_size = unset

# Embedded shell/JQ and aligned template data use a different indent width.
[{Justfile,.machine_readable/contractiles/Justfile,.github/scripts/classify-issue.jq}]
indent_size = unset

[.github/workflows/{label-triage,labels,openssf-compliance,secret-scanner}.yml]
indent_size = unset

[{scripts/scan-dangerous.sh,scripts/validate-template.sh,tests/e2e/template_instantiation_test.sh}]
indent_size = unset

[{.machine_readable/contractiles/trust/Trustfile.a2ml,machine-readable-design/canonical-directory-structure/Trustfile.a2ml,.machine_readable/contractiles/intend/intend.k9.ncl,systemet_chora.deed,verification/proofs/lean4/lake-manifest.json}]
indent_size = unset
31 changes: 27 additions & 4 deletions .githooks/validate-a2ml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,27 @@ WARNINGS=0
# ---------------------------------------------------------------------------
# Usage: annotate <level> <file> <line> <message>
# level: error | warning | notice
escape_data() {
local value="$1"
value="${value//'%'/'%25'}"
value="${value//$'\r'/'%0D'}"
value="${value//$'\n'/'%0A'}"
printf '%s' "$value"
}

escape_property() {
local value
value="$(escape_data "$1")"
value="${value//':'/'%3A'}"
value="${value//','/'%2C'}"
printf '%s' "$value"
}

annotate() {
local level="$1" file="$2" line="$3" message="$4"
echo "::${level} file=${file},line=${line}::${message}"
printf '::%s file=%s,line=%s::%s\n' \
"$level" "$(escape_property "$file")" \
"$(escape_property "$line")" "$(escape_data "$message")"
}

# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -267,6 +285,8 @@ validate_a2ml() {
# --- Check 4: Section heading syntax ---
# Validate that [section] headings are well-formed (no unclosed brackets)
line_num=0
# report_issue uses the file path as an annotation label; it writes to stdout.
# shellcheck disable=SC2094
while IFS= read -r line; do
line_num=$((line_num + 1))
# Lines starting with [ should have a matching ]
Expand All @@ -288,8 +308,11 @@ echo "::group::A2ML Manifest Validation"
echo "Scanning ${SCAN_PATH} for .a2ml files..."
echo ""

# Find all .a2ml files, excluding .git directory
mapfile -t a2ml_candidates < <(find "$SCAN_PATH" -name '*.a2ml' -not -path '*/.git/*' -type f | sort)
# Null-delimited discovery preserves unusual paths; a broken find/sort must fail.
discovery_tmp="$(mktemp)"
trap 'rm -f "$discovery_tmp"' EXIT
find "$SCAN_PATH" -name '*.a2ml' -not -path '*/.git/*' -type f -print0 | sort -z > "$discovery_tmp"
mapfile -d '' -t a2ml_candidates < "$discovery_tmp"

# Apply paths-ignore filter
a2ml_files=()
Expand Down Expand Up @@ -319,7 +342,7 @@ echo "Found ${#a2ml_files[@]} .a2ml file(s)"
echo ""

for file in "${a2ml_files[@]}"; do
echo " Validating: ${file}"
printf ' Validating: %s\n' "$(escape_data "$file")"
validate_a2ml "$file"
done

Expand Down
138 changes: 66 additions & 72 deletions .githooks/validate-k9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,27 @@
# ---------------------------------------------------------------------------
# Helper: emit GitHub annotation
# ---------------------------------------------------------------------------
escape_data() {
local value="$1"
value="${value//'%'/'%25'}"
value="${value//$'\r'/'%0D'}"
value="${value//$'\n'/'%0A'}"
printf '%s' "$value"
}

escape_property() {
local value
value="$(escape_data "$1")"
value="${value//':'/'%3A'}"
value="${value//','/'%2C'}"
printf '%s' "$value"
}

annotate() {
local level="$1" file="$2" line="$3" message="$4"
echo "::${level} file=${file},line=${line}::${message}"
printf '::%s file=%s,line=%s::%s\n' \
"$level" "$(escape_property "$file")" \
"$(escape_property "$line")" "$(escape_data "$message")"
}

# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -98,13 +116,9 @@
raw="${raw#*=}" # Remove everything before =
raw="${raw//\"/}" # Remove double quotes
raw="${raw//\'/}" # Remove single quotes (Nickel tick)
raw="${raw//,/}" # Remove trailing commas
raw="${raw## }" # Trim leading space
raw="${raw%% }" # Trim trailing space
raw="${raw%%#*}" # Remove inline comments
raw="${raw## }" # Trim again
raw="${raw%% }"
echo "${raw,,}" # Lowercase
raw="${raw#"${raw%%[![:space:]]*}"}" # Trim leading whitespace
raw="${raw%"${raw##*[![:space:]]}"}" # Trim trailing whitespace
echo "${raw,,}" # Lowercase
}

# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -165,77 +179,54 @@
local in_pedigree=false
local pedigree_depth=0

# Split each line at record delimiters outside quoted strings. A comment
# ends the line, so its contents cannot count as assignments or braces.
local segment_re='^(([^"#,{}]|"([^"\\]|\\.)*")*)([#{},]|$)'
local field_re='^[[:space:]]*(name|version|schema_version|leash|security_level|signature|signature_required)[[:space:]]*=(.*)$'
local remaining segment delimiter

line_num=0
while IFS= read -r line; do
while IFS= read -r line || [[ -n "$line" ]]; do
line_num=$((line_num + 1))

# Detect pedigree block start. Note: do NOT `continue` here — the
# `pedigree = {` line itself contains the opening brace that
# establishes the block. Falling through to the brace counter
# below makes depth start at 1, so a subsequent `security = {…},`
# closing brace correctly takes depth to 1 (not 0), keeping us
# inside the pedigree block when later fields (name/version/leash)
# are checked. Previously the `continue` skipped this opening
# brace, depth started at 0, and the first nested block's close
# prematurely terminated the validator's view of the pedigree —
# making `pedigree.metadata.name` invisible.
if [[ "$line" =~ ^[[:space:]]*pedigree[[:space:]]*= ]]; then
has_pedigree=true
in_pedigree=true
pedigree_depth=0
# fall through
fi

if [[ "$in_pedigree" == "true" ]]; then
# Track brace depth to know when pedigree block ends
local opens closes
opens="${line//[^\{]/}"
closes="${line//[^\}]/}"
pedigree_depth=$(( pedigree_depth + ${#opens} - ${#closes} ))

if [[ $pedigree_depth -le 0 && "$has_pedigree" == "true" ]]; then
# Check this final line too before leaving
:
fi

# Check for name field within pedigree.metadata or pedigree directly.
# Two patterns cover both multi-line and single-line pedigrees:
# 1. ^[[:space:]]+name[[:space:]]*= — the normal multi-line case where
# `name = "..."` appears on its own indented line.
# 2. [[:space:]]name[[:space:]]*= — inline within a single-line
# pedigree assignment such as:
# pedigree = component_pedigree & { name = "foo" }
# (root cause: developer-ecosystem@baab1534 — single-line form
# was missed entirely because the pedigree block opened and
# closed in one line, never reaching the ^[[:space:]]+ check on
# a subsequent iteration.)
if [[ "$line" =~ ^[[:space:]]+name[[:space:]]*= ]] || \
[[ "$line" =~ [[:space:]]name[[:space:]]*= ]]; then
has_pedigree_name=true
fi

# Check for version field
if [[ "$line" =~ ^[[:space:]]+(version|schema_version)[[:space:]]*= ]] || \
[[ "$line" =~ [[:space:]](version|schema_version)[[:space:]]*= ]]; then
has_pedigree_version=true
fi

# Check for security level (leash field)
if [[ "$line" =~ ^[[:space:]]+(leash|security_level)[[:space:]]*= ]]; then
has_security_level=true
security_level_value="$(normalise_level "$line")"
security_level_line=$line_num
fi

# Check for signature fields
if [[ "$line" =~ ^[[:space:]]+(signature|signature_required)[[:space:]]*= ]]; then
has_signature_field=true
fi

# End of pedigree block
if [[ $pedigree_depth -le 0 && "$has_pedigree" == "true" && "$line" == *"}"* ]]; then
in_pedigree=false
fi
remaining="$line"
while [[ -n "$remaining" && "$remaining" =~ $segment_re ]]; do
segment="${BASH_REMATCH[1]}"
delimiter="${BASH_REMATCH[4]}"
remaining="${remaining:"${#BASH_REMATCH[0]}"}"

if [[ "$segment" =~ $field_re ]]; then
case "${BASH_REMATCH[1]}" in

Check failure on line 206 in .githooks/validate-k9.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a default case (*) to handle unexpected values.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_systemet&issues=AaIFzw6zm16mPyIawMhM&open=AaIFzw6zm16mPyIawMhM&pullRequest=108
name) has_pedigree_name=true ;;
version|schema_version) has_pedigree_version=true ;;
leash|security_level)
has_security_level=true
security_level_value="$(normalise_level "$segment")"
security_level_line=$line_num
;;
signature|signature_required) has_signature_field=true ;;
esac
fi

case "$delimiter" in

Check failure on line 218 in .githooks/validate-k9.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a default case (*) to handle unexpected values.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_systemet&issues=AaIFzw6zm16mPyIawMhN&open=AaIFzw6zm16mPyIawMhN&pullRequest=108
'{') pedigree_depth=$((pedigree_depth + 1)) ;;
'}')
pedigree_depth=$((pedigree_depth - 1))
if [[ $pedigree_depth -le 0 ]]; then
in_pedigree=false
break
fi
;;
'#'|'') break ;;
esac
done
fi

# Also check for signature fields outside pedigree (top-level)
Expand Down Expand Up @@ -295,8 +286,11 @@
echo "Scanning ${SCAN_PATH} for K9 files (.k9, .k9.ncl)..."
echo ""

# Find all K9 files, excluding .git directory
mapfile -t k9_candidates < <(find "$SCAN_PATH" \( -name '*.k9' -o -name '*.k9.ncl' \) -not -path '*/.git/*' -type f | sort)
# Null-delimited discovery preserves unusual paths; a broken find/sort must fail.
discovery_tmp="$(mktemp)"
trap 'rm -f "$discovery_tmp"' EXIT
find "$SCAN_PATH" \( -name '*.k9' -o -name '*.k9.ncl' \) -not -path '*/.git/*' -type f -print0 | sort -z > "$discovery_tmp"
mapfile -d '' -t k9_candidates < "$discovery_tmp"

# Apply paths-ignore filter
k9_files=()
Expand Down Expand Up @@ -326,7 +320,7 @@
echo ""

for file in "${k9_files[@]}"; do
echo " Validating: ${file}"
printf ' Validating: %s\n' "$(escape_data "$file")"
validate_k9 "$file"
done

Expand Down
25 changes: 25 additions & 0 deletions .githooks/validate-stapeln-manifest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
# Validate the Cerro Torre manifest using a sample numeric template port.
# Usage: validate-stapeln-manifest.sh <manifest.toml>
set -euo pipefail

path="${1:?usage: $0 <manifest.toml>}"
[ -r "$path" ] || { echo "$path: cannot read manifest" >&2; exit 1; }

Check failure on line 8 in .githooks/validate-stapeln-manifest.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_systemet&issues=AaIXj57aVhmlP6Z9cQ9z&open=AaIXj57aVhmlP6Z9cQ9z&pullRequest=108

# Render the template placeholder with a sample port, then pull the
# listen_tcp key out of the [security.network] table.
line=$(sed 's/{{PORT}}/8080/g' "$path" | awk '
/^[[:space:]]*\[/ { in_net = ($0 ~ /^[[:space:]]*\[security\.network\][[:space:]]*(#.*)?$/) ; next }
in_net && /^[[:space:]]*listen_tcp[[:space:]]*=/ { print; exit }
')

if [ -z "$line" ]; then

Check failure on line 17 in .githooks/validate-stapeln-manifest.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_systemet&issues=AaIXj57aVhmlP6Z9cQ90&open=AaIXj57aVhmlP6Z9cQ90&pullRequest=108
echo "$path: security.network.listen_tcp is missing" >&2
exit 1
fi

if ! printf '%s\n' "$line" | grep -Eq '^[[:space:]]*listen_tcp[[:space:]]*=[[:space:]]*\[[[:space:]]*([0-9]+([[:space:]]*,[[:space:]]*[0-9]+)*)?[[:space:]]*,?[[:space:]]*\][[:space:]]*(#.*)?$'; then
echo "$path: security.network.listen_tcp must be an array of integers" >&2
exit 1
fi
2 changes: 1 addition & 1 deletion .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright (c) Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
-->
# Code of Conduct

<!--
<!--
============================================================================
TEMPLATE INSTRUCTIONS (delete this block before publishing)
============================================================================
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ a step-level action with a record in `actions.lock`.
* `sonarqube.yml` — SonarCloud (shell / JS surface; see `sonar-project.properties`).
With no `SONAR_TOKEN` secret, the job says that the scan is not configured
and passes. The SonarCloud app still analyses each pull request.
* `static-analysis-gate.yml` — panic-attack + Hypatia gate (see above).
* `static-analysis-gate.yml` — panic-attack + Hypatia critical-finding gate,
with validated scanner receipts (see `docs/ci-gates/REGISTER.adoc`). Both
scanner sources are full-commit pinned and scanner/build/schema failures are
fatal; the collector refuses to invent empty reports. Patch Bridge is an
explicitly advisory, conditional triage signal, not a blocking security
status. This gate is still awaiting a live Actions run of its pinned builds.

Each targets a different language/surface; together they cover what no single
analyser does.
analyser does. A green status is only evidence for the specifically documented
threshold and applicable scan scope; it is not a proof of absence of all bugs.
Loading
Loading