From 2af2364947356078ddb08644062c7be2069fdbb1 Mon Sep 17 00:00:00 2001 From: Julian Noble Date: Fri, 31 Jul 2026 05:57:58 +1000 Subject: [PATCH] G-123 increment 2: punk-runtime provenance display + bash info -platform fix (punkshell 0.33.0) Both payloads gain a TABLE-AWARE [provenance] class reader (provenance_class() awk helper / Get-PunkRuntimeProvenanceClass) - the flat first-wins field scans deliberately keep reporting [artifact] class per the documented schema-v2 ordering caveat. Display: compact class=third-party|local tag in the plain-list metadata summary and in list -remote's sparse identity column (suite-built stays quiet; LOCAL record basis only - a listing does no per-row remote fetches, toml-less and remote-only rows keep degrading as no-basis rows); info gains the v2 fields builder/source_url/upstream_ref/retrieved in the flat table plus a derived provenance_class row, disagreement-checked; help texts updated to the v1/v2 wording. bash defect fixed: 'info -platform

' was advertised in both help texts but silently ignored - 'info' was missing from the option-scan action list (punk-runtime.bash case arm). The per-name report now honours the tier argument like the ps1 payload (proven by the tier-named not-found path). bin/punk-runtime.cmd re-wrapped via the documented multishell invocation under punk905. Verification: bash -n clean; staged v2 third-party fixture smoke shows parity output in both payloads ('[tcl=9.9.9 class=third-party]' + provenance_class row); runtimecmd_checkfile PASS (no 512B label crossing after payload growth); runtimecmd_freshness PASS (13 fixture tests, both routes); runtimecmd_roundtrip PASS byte-identical under the tclsh9.0.5-punk baseline runner (plain native tclsh lacks struct::stack for tomlish - runner-choice trap noted in the goal Progress). Assisted-by: harness=claude; primary-model=claude-fable-5; api-location=anthropic.com --- CHANGELOG.md | 21 +++++ bin/punk-runtime.cmd | 106 ++++++++++++++++++++++-- goals/G-123-thirdparty-runtime-tiers.md | 31 +++++++ punkproject.toml | 2 +- src/scriptapps/bin/punk-runtime.bash | 53 +++++++++++- src/scriptapps/bin/punk-runtime.ps1 | 53 +++++++++++- 6 files changed, 253 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f67652fc..3d9f18a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,27 @@ The latest `## [X.Y.Z]` header must match the `version` field in `punkproject.to Entries are newest-first; one bullet per notable change. See the root `AGENTS.md` "Project Versioning" section for the bump policy. +## [0.33.0] - 2026-07-31 + +- Runtime artifact records move to schema v2 (G-123): `[provenance]` gains the + build-origin `class` line (`suite-built | third-party | local`), emitted by + the suite_tcl90 kit-family steps (both record copies; family_check asserts + it) and documented in the punkbin repo alongside 12 retroactive sidecars + authored for every pre-family artifact on the server (evidence-based + classes; additive - artifact bytes and names unchanged). +- `punk-runtime` (both payloads, `bin/punk-runtime.cmd` re-wrapped): local + listings and `list -remote`'s sparse identity column now carry a compact + `class=` tag for third-party/local runtimes (suite-built rows + stay quiet; tags derive from local records only - no per-row remote + fetches), and `info` shows the schema-v2 provenance fields (`builder`, + `source_url`, `upstream_ref`, `retrieved`) plus a table-aware + `provenance_class` row (the flat field scan deliberately keeps reporting + `[artifact] class` per the documented v2 ordering caveat). +- `punk-runtime` bash payload fix: `info -platform

` was advertised but + silently ignored ('info' was missing from the option-scan action list) - + the per-name identity report now honours the tier argument like the ps1 + payload. + ## [0.32.3] - 2026-07-31 - `punk-runtime` bash payload: `fetch` and `list`'s local-file comparison now diff --git a/bin/punk-runtime.cmd b/bin/punk-runtime.cmd index 3c2a6c20..d755955f 100755 --- a/bin/punk-runtime.cmd +++ b/bin/punk-runtime.cmd @@ -1388,7 +1388,7 @@ action="${1:-}" [[ $# -gt 0 ]] && shift platform_opt="" case "$action" in - fetch|list|use|platforms) + fetch|list|use|info|platforms) newargs=() while [[ $# -gt 0 ]]; do if [[ "$1" == "-platform" ]]; then @@ -1502,11 +1502,28 @@ rootname_of() { *) printf '%s' "$1";; esac } +#G-123 schema v2: stdin -> the [provenance] table's class value (build-origin +#class: suite-built | third-party | local). Table-aware ON PURPOSE: '[artifact] +#class' is the FIRST 'class =' line in every record by construction (the +#documented v2 ordering caveat) - a flat first-wins scan must never serve this +#key. Empty output for pre-v2 records / no [provenance] class. +provenance_class() { + awk ' + /^[[:space:]]*\[/ {inprov = /^[[:space:]]*\[provenance\][[:space:]]*$/; next} + inprov && /^[[:space:]]*class[[:space:]]*=[[:space:]]*"/ { + line = $0 + sub(/^[[:space:]]*class[[:space:]]*=[[:space:]]*"/, "", line) + sub(/".*$/, "", line) + print line + exit + } + ' +} #G-103 artifact metadata: a runtime may carry a .toml beside it (emitted #by the buildsuite kit-family-artifacts step / fetched from punkbin). Prints a #short "[variant=... tcl=... rN ...]" summary for list output, "" when absent. metadata_summary() { - local exename="$1" tomlfile parts variant tclpatch revision piperepl artname target + local exename="$1" tomlfile parts variant tclpatch revision piperepl artname target pclass tomlfile="$archdir/$(rootname_of "$exename").toml" [[ -f "$tomlfile" ]] || return 0 variant=$(sed -n 's/^[[:space:]]*variant[[:space:]]*=[[:space:]]*"\(.*\)".*/\1/p' "$tomlfile" | head -n 1) @@ -1523,6 +1540,9 @@ metadata_summary() { elif [[ "$piperepl" == "false" ]]; then parts="$parts piperepl=off"; fi #a materialized working copy records which immutable artifact it came from [[ -n "$artname" && "$artname" != "$exename" ]] && parts="$parts from=$artname" + #G-123 schema v2: build-origin tag - suite-built stays quiet (expected state) + pclass=$(provenance_class < "$tomlfile") + [[ -n "$pclass" && "$pclass" != "suite-built" ]] && parts="$parts class=$pclass" #integrity flag: a runtime filed under a platform folder its metadata says it #was not built for (cross-platform fetch/staging misfiling) [[ -n "$target" && "$target" != "$archtail" ]] && parts="$parts !TARGET-MISMATCH:$target" @@ -1584,7 +1604,9 @@ show_help() { echo " installed candidate. Takes no -platform (foreign binaries are" echo " not runnable here)." echo " info ?-platform

?" - echo " Identity report for a runtime file (G-117 schema v1): the record" + echo " Identity report for a runtime file (schema v1/v2 - G-117/G-123;" + echo " v2 adds the [provenance] build-origin class shown as the" + echo " provenance_class row and the class= tag in listings): the record" echo " EMBEDDED in its attached image and the sidecar toml side by side," echo " with disagreements flagged and the file's sha1 checked against" echo " the sidecar. The embedded read uses a zip central-directory read" @@ -2003,6 +2025,17 @@ case "$action" in fi fi fi + #G-123 schema v2: compact build-origin tag from the LOCAL record + #beside the row's file - suite-built stays quiet (expected state). + #A listing does no per-row remote fetches, so remote-only rows and + #tomlless strays carry no tag (no-basis degradation). + ptoml="$archdir/$(rootname_of "$f").toml" + if [[ -f "$ptoml" ]]; then + pclass=$(provenance_class < "$ptoml") + if [[ -n "$pclass" && "$pclass" != "suite-built" ]]; then + mid="${mid:+$mid }class=$pclass" + fi + fi mark=" " [[ "$f" == "$activename" ]] && mark="* " annot="" @@ -2287,7 +2320,7 @@ case "$action" in if [[ -n "$embedded" || -f "$sidecar" ]]; then printf ' %-20s %-36s %s\n' "field" "embedded" "sidecar" disagreements="" - for k in schema name class variant working_name revision target build_id origin packager project project_url license build_host_platform tcl_patchlevel sha1 size built; do + for k in schema name class variant working_name revision target build_id origin packager builder source_url upstream_ref retrieved project project_url license build_host_platform tcl_patchlevel sha1 size built; do ev=""; sv="" if [[ -n "$embedded" ]]; then ev=$(printf '%s\n' "$embedded" | sed -n 's/^[[:space:]]*'"$k"'[[:space:]]*=[[:space:]]*"\(.*\)".*/\1/p' | head -n 1) @@ -2304,6 +2337,18 @@ case "$action" in disagreements="$disagreements $k" fi done + #G-123 schema v2: [provenance] class shown as its own derived row - the + #flat scan above reports [artifact] class per the documented ordering + #caveat, so this key needs the table-aware read + pcev=""; pcsv="" + [[ -n "$embedded" ]] && pcev=$(printf '%s\n' "$embedded" | provenance_class) + [[ -f "$sidecar" ]] && pcsv=$(provenance_class < "$sidecar") + if [[ -n "$pcev" || -n "$pcsv" ]]; then + printf ' %-20s %-36s %s\n' "provenance_class" "${pcev:--}" "${pcsv:--}" + if [[ -n "$pcev" && -n "$pcsv" && "$pcev" != "$pcsv" ]]; then + disagreements="$disagreements provenance_class" + fi + fi echo "-----------------------------------------------------------------------" if [[ -n "$disagreements" ]]; then echo " !DISAGREE embedded-vs-sidecar on:$disagreements" @@ -2802,7 +2847,9 @@ function Show-PunkRuntimeHelp { write-host " installed candidate. Takes no -platform (foreign binaries are" write-host " not runnable here)." write-host " info ?-platform

?" - write-host " Identity report for a runtime file (G-117 schema v1): the record" + write-host " Identity report for a runtime file (schema v1/v2 - G-117/G-123;" + write-host " v2 adds the [provenance] build-origin class shown as the" + write-host " provenance_class row and the class= tag in listings): the record" write-host " EMBEDDED in its attached image and the sidecar toml side by side," write-host " with disagreements flagged and the file's sha1 checked against" write-host " the sidecar. The embedded read uses a zip central-directory read" @@ -2945,6 +2992,9 @@ function Get-PunkRuntimeMetadataSummary { } #a materialized working copy records which immutable artifact it came from if ($fields.ContainsKey('name') -and $fields['name'] -ne $exename) { $parts += "from=$($fields['name'])" } + #G-123 schema v2: build-origin tag - suite-built stays quiet (expected state) + $pclass = Get-PunkRuntimeProvenanceClass ([string[]](Get-Content -Path $tomlfile)) + if ($pclass -ne "" -and $pclass -ne "suite-built") { $parts += "class=$pclass" } #integrity flag: a runtime filed under a platform folder its metadata says it #was not built for (cross-platform fetch/staging misfiling) if ($expectedplatform -ne "" -and $fields.ContainsKey('target') -and $fields['target'] -ne $expectedplatform) { @@ -2974,6 +3024,26 @@ function Get-PunkRuntimeRecordFields { } return $fields } +#G-123 schema v2: the [provenance] table's class value (build-origin class: +#suite-built | third-party | local). Table-aware ON PURPOSE: '[artifact] class' +#is the FIRST 'class =' line in every record by construction (the documented v2 +#ordering caveat) - the flat first-wins Get-PunkRuntimeRecordFields scan must +#never serve this key. Returns "" for pre-v2 records / no [provenance] class. +function Get-PunkRuntimeProvenanceClass { + param([string[]] $recordlines) + $inprov = $false + foreach ($line in $recordlines) { + if ($line -match '^\s*\[') { + $inprov = ($line -match '^\s*\[provenance\]\s*$') + continue + } + if ($inprov) { + $m = [regex]::Match($line, '^\s*class\s*=\s*"(.*)"\s*$') + if ($m.Success) { return $m.Groups[1].Value } + } + } + return "" +} #G-117 embedded record: zip CENTRAL-DIRECTORY read of the exe-appended archive via #.NET System.IO.Compression (offsets resolve from the end-of-central-directory #record, so the prepended executable data is no obstacle). The target is NEVER @@ -3860,6 +3930,18 @@ function psmain { } } } + #G-123 schema v2: compact build-origin tag from the LOCAL + #record beside the row's file - suite-built stays quiet + #(expected state). A listing does no per-row remote fetches, + #so remote-only rows and tomlless strays carry no tag + #(no-basis degradation). + $ptoml = Join-Path -Path $archfolder -ChildPath ((Get-PunkRuntimeRootName $key) + ".toml") + if (Test-Path -Path $ptoml -PathType Leaf) { + $pclass = Get-PunkRuntimeProvenanceClass ([string[]](Get-Content -Path $ptoml)) + if ($pclass -ne "" -and $pclass -ne "suite-built") { + if ($mid -ne "") { $mid = "$mid class=$pclass" } else { $mid = "class=$pclass" } + } + } #ansi problems from cmd.exe not in windows terminal - review $C = "" $RST = "" @@ -3972,7 +4054,7 @@ function psmain { if ($havesidecar) { $sfields = Get-PunkRuntimeRecordFields ([string[]](Get-Content -Path $sidecarfile)) } write-host (" {0,-20} {1,-36} {2}" -f "field", "embedded", "sidecar") $disagreements = @() - foreach ($k in @('schema','name','class','variant','working_name','revision','target','build_id','origin','packager','project','project_url','license','build_host_platform','tcl_patchlevel','sha1','size','built')) { + foreach ($k in @('schema','name','class','variant','working_name','revision','target','build_id','origin','packager','builder','source_url','upstream_ref','retrieved','project','project_url','license','build_host_platform','tcl_patchlevel','sha1','size','built')) { $ev = ""; $sv = "" if ($efields.ContainsKey($k)) { $ev = $efields[$k] } if ($sfields.ContainsKey($k)) { $sv = $sfields[$k] } @@ -3983,6 +4065,18 @@ function psmain { #schema absent on one side is pre-v1 tolerance, not a disagreement if (($ev -ne "") -and ($sv -ne "") -and ($ev -cne $sv)) { $disagreements += $k } } + #G-123 schema v2: [provenance] class as its own derived row - the + #flat scan above reports [artifact] class per the documented + #ordering caveat, so this key needs the table-aware read + $pcev = ""; $pcsv = "" + if ($null -ne $embedtext) { $pcev = Get-PunkRuntimeProvenanceClass ($embedtext -split "`r?`n") } + if ($havesidecar) { $pcsv = Get-PunkRuntimeProvenanceClass ([string[]](Get-Content -Path $sidecarfile)) } + if (($pcev -ne "") -or ($pcsv -ne "")) { + $pcevd = "-"; if ($pcev -ne "") { $pcevd = $pcev } + $pcsvd = "-"; if ($pcsv -ne "") { $pcsvd = $pcsv } + write-host (" {0,-20} {1,-36} {2}" -f "provenance_class", $pcevd, $pcsvd) + if (($pcev -ne "") -and ($pcsv -ne "") -and ($pcev -cne $pcsv)) { $disagreements += "provenance_class" } + } write-host "-----------------------------------------------------------------------" if ($disagreements.Count) { write-host " !DISAGREE embedded-vs-sidecar on: $($disagreements -join ' ')" diff --git a/goals/G-123-thirdparty-runtime-tiers.md b/goals/G-123-thirdparty-runtime-tiers.md index c709a090..553938c4 100644 --- a/goals/G-123-thirdparty-runtime-tiers.md +++ b/goals/G-123-thirdparty-runtime-tiers.md @@ -196,3 +196,34 @@ see goals/archive/G-058-static-runtime-packages.md). "built using bawt" 9f13f97 commit wording); tclsh901k/t local (interim/test-runtime commit wording). Every such value carries its basis comment in the record, so flipping a class is a one-line edit. +- 2026-07-31 increment 2 (punkshell 0.33.0): client-side provenance display + + tier-argument fix, both payloads, bin/punk-runtime.cmd re-wrapped. + - Table-aware [provenance] class readers added to BOTH payloads + (provenance_class() awk helper / Get-PunkRuntimeProvenanceClass) - the + flat first-wins scans deliberately keep serving [artifact] class per + the documented v2 ordering caveat. + - Compact class= tag (third-party|local; suite-built quiet per the + acceptance) in the plain-list metadata summary and list -remote's + 33-wide sparse identity column, both payloads, LOCAL-record basis only + (design decision: a listing does no per-row remote fetches; toml-less + and remote-only rows keep degrading as no-basis rows). + - info: schema-v2 fields builder/source_url/upstream_ref/retrieved join + the flat field table (whole-file-unique keys), plus a derived + provenance_class row via the table-aware read, disagreement-checked + like other fields; help texts updated (v1/v2 wording). + - bash 'info -platform' DEFECT FIXED: 'info' joined the option-scan + action list; proven by the tier-named error path. + - Verified: bash -n clean; both payloads smoke-tested against a staged + v2 third-party fixture (parity output: '[tcl=9.9.9 class=third-party]' + row tag + provenance_class info row in both); re-wrap via the + documented multishell invocation under punk905; pinned tests GREEN - + runtimecmd_checkfile PASS (no 512B label crossing after growth), + runtimecmd_freshness PASS (13 fixture tests, both routes, no + regression), runtimecmd_roundtrip PASS byte-identical (NOTE: must run + under the tclsh9.0.5-punk baseline runner - plain native tclsh lacks + tcllib's struct::stack for tomlish and fails the wrap-toml read, a + runner-choice trap, not a wrap defect). + - Remaining for the client surface (later increments): third-party + origin tag sourced from REMOTE records was deliberately scoped out of + listings; the per-name detail view for a not-yet-fetched artifact + stays a candidate follow-on if acceptance walking finds it wanted. diff --git a/punkproject.toml b/punkproject.toml index 5bd4cf0f..f5db6e80 100644 --- a/punkproject.toml +++ b/punkproject.toml @@ -1,4 +1,4 @@ [project] name = "punkshell" -version = "0.32.3" +version = "0.33.0" license = "BSD-2-Clause" diff --git a/src/scriptapps/bin/punk-runtime.bash b/src/scriptapps/bin/punk-runtime.bash index c805cf1f..64a361e5 100644 --- a/src/scriptapps/bin/punk-runtime.bash +++ b/src/scriptapps/bin/punk-runtime.bash @@ -108,7 +108,7 @@ action="${1:-}" [[ $# -gt 0 ]] && shift platform_opt="" case "$action" in - fetch|list|use|platforms) + fetch|list|use|info|platforms) newargs=() while [[ $# -gt 0 ]]; do if [[ "$1" == "-platform" ]]; then @@ -222,11 +222,28 @@ rootname_of() { *) printf '%s' "$1";; esac } +#G-123 schema v2: stdin -> the [provenance] table's class value (build-origin +#class: suite-built | third-party | local). Table-aware ON PURPOSE: '[artifact] +#class' is the FIRST 'class =' line in every record by construction (the +#documented v2 ordering caveat) - a flat first-wins scan must never serve this +#key. Empty output for pre-v2 records / no [provenance] class. +provenance_class() { + awk ' + /^[[:space:]]*\[/ {inprov = /^[[:space:]]*\[provenance\][[:space:]]*$/; next} + inprov && /^[[:space:]]*class[[:space:]]*=[[:space:]]*"/ { + line = $0 + sub(/^[[:space:]]*class[[:space:]]*=[[:space:]]*"/, "", line) + sub(/".*$/, "", line) + print line + exit + } + ' +} #G-103 artifact metadata: a runtime may carry a .toml beside it (emitted #by the buildsuite kit-family-artifacts step / fetched from punkbin). Prints a #short "[variant=... tcl=... rN ...]" summary for list output, "" when absent. metadata_summary() { - local exename="$1" tomlfile parts variant tclpatch revision piperepl artname target + local exename="$1" tomlfile parts variant tclpatch revision piperepl artname target pclass tomlfile="$archdir/$(rootname_of "$exename").toml" [[ -f "$tomlfile" ]] || return 0 variant=$(sed -n 's/^[[:space:]]*variant[[:space:]]*=[[:space:]]*"\(.*\)".*/\1/p' "$tomlfile" | head -n 1) @@ -243,6 +260,9 @@ metadata_summary() { elif [[ "$piperepl" == "false" ]]; then parts="$parts piperepl=off"; fi #a materialized working copy records which immutable artifact it came from [[ -n "$artname" && "$artname" != "$exename" ]] && parts="$parts from=$artname" + #G-123 schema v2: build-origin tag - suite-built stays quiet (expected state) + pclass=$(provenance_class < "$tomlfile") + [[ -n "$pclass" && "$pclass" != "suite-built" ]] && parts="$parts class=$pclass" #integrity flag: a runtime filed under a platform folder its metadata says it #was not built for (cross-platform fetch/staging misfiling) [[ -n "$target" && "$target" != "$archtail" ]] && parts="$parts !TARGET-MISMATCH:$target" @@ -304,7 +324,9 @@ show_help() { echo " installed candidate. Takes no -platform (foreign binaries are" echo " not runnable here)." echo " info ?-platform

?" - echo " Identity report for a runtime file (G-117 schema v1): the record" + echo " Identity report for a runtime file (schema v1/v2 - G-117/G-123;" + echo " v2 adds the [provenance] build-origin class shown as the" + echo " provenance_class row and the class= tag in listings): the record" echo " EMBEDDED in its attached image and the sidecar toml side by side," echo " with disagreements flagged and the file's sha1 checked against" echo " the sidecar. The embedded read uses a zip central-directory read" @@ -723,6 +745,17 @@ case "$action" in fi fi fi + #G-123 schema v2: compact build-origin tag from the LOCAL record + #beside the row's file - suite-built stays quiet (expected state). + #A listing does no per-row remote fetches, so remote-only rows and + #tomlless strays carry no tag (no-basis degradation). + ptoml="$archdir/$(rootname_of "$f").toml" + if [[ -f "$ptoml" ]]; then + pclass=$(provenance_class < "$ptoml") + if [[ -n "$pclass" && "$pclass" != "suite-built" ]]; then + mid="${mid:+$mid }class=$pclass" + fi + fi mark=" " [[ "$f" == "$activename" ]] && mark="* " annot="" @@ -1007,7 +1040,7 @@ case "$action" in if [[ -n "$embedded" || -f "$sidecar" ]]; then printf ' %-20s %-36s %s\n' "field" "embedded" "sidecar" disagreements="" - for k in schema name class variant working_name revision target build_id origin packager project project_url license build_host_platform tcl_patchlevel sha1 size built; do + for k in schema name class variant working_name revision target build_id origin packager builder source_url upstream_ref retrieved project project_url license build_host_platform tcl_patchlevel sha1 size built; do ev=""; sv="" if [[ -n "$embedded" ]]; then ev=$(printf '%s\n' "$embedded" | sed -n 's/^[[:space:]]*'"$k"'[[:space:]]*=[[:space:]]*"\(.*\)".*/\1/p' | head -n 1) @@ -1024,6 +1057,18 @@ case "$action" in disagreements="$disagreements $k" fi done + #G-123 schema v2: [provenance] class shown as its own derived row - the + #flat scan above reports [artifact] class per the documented ordering + #caveat, so this key needs the table-aware read + pcev=""; pcsv="" + [[ -n "$embedded" ]] && pcev=$(printf '%s\n' "$embedded" | provenance_class) + [[ -f "$sidecar" ]] && pcsv=$(provenance_class < "$sidecar") + if [[ -n "$pcev" || -n "$pcsv" ]]; then + printf ' %-20s %-36s %s\n' "provenance_class" "${pcev:--}" "${pcsv:--}" + if [[ -n "$pcev" && -n "$pcsv" && "$pcev" != "$pcsv" ]]; then + disagreements="$disagreements provenance_class" + fi + fi echo "-----------------------------------------------------------------------" if [[ -n "$disagreements" ]]; then echo " !DISAGREE embedded-vs-sidecar on:$disagreements" diff --git a/src/scriptapps/bin/punk-runtime.ps1 b/src/scriptapps/bin/punk-runtime.ps1 index 5010fc69..658acab2 100644 --- a/src/scriptapps/bin/punk-runtime.ps1 +++ b/src/scriptapps/bin/punk-runtime.ps1 @@ -163,7 +163,9 @@ function Show-PunkRuntimeHelp { write-host " installed candidate. Takes no -platform (foreign binaries are" write-host " not runnable here)." write-host " info ?-platform

?" - write-host " Identity report for a runtime file (G-117 schema v1): the record" + write-host " Identity report for a runtime file (schema v1/v2 - G-117/G-123;" + write-host " v2 adds the [provenance] build-origin class shown as the" + write-host " provenance_class row and the class= tag in listings): the record" write-host " EMBEDDED in its attached image and the sidecar toml side by side," write-host " with disagreements flagged and the file's sha1 checked against" write-host " the sidecar. The embedded read uses a zip central-directory read" @@ -306,6 +308,9 @@ function Get-PunkRuntimeMetadataSummary { } #a materialized working copy records which immutable artifact it came from if ($fields.ContainsKey('name') -and $fields['name'] -ne $exename) { $parts += "from=$($fields['name'])" } + #G-123 schema v2: build-origin tag - suite-built stays quiet (expected state) + $pclass = Get-PunkRuntimeProvenanceClass ([string[]](Get-Content -Path $tomlfile)) + if ($pclass -ne "" -and $pclass -ne "suite-built") { $parts += "class=$pclass" } #integrity flag: a runtime filed under a platform folder its metadata says it #was not built for (cross-platform fetch/staging misfiling) if ($expectedplatform -ne "" -and $fields.ContainsKey('target') -and $fields['target'] -ne $expectedplatform) { @@ -335,6 +340,26 @@ function Get-PunkRuntimeRecordFields { } return $fields } +#G-123 schema v2: the [provenance] table's class value (build-origin class: +#suite-built | third-party | local). Table-aware ON PURPOSE: '[artifact] class' +#is the FIRST 'class =' line in every record by construction (the documented v2 +#ordering caveat) - the flat first-wins Get-PunkRuntimeRecordFields scan must +#never serve this key. Returns "" for pre-v2 records / no [provenance] class. +function Get-PunkRuntimeProvenanceClass { + param([string[]] $recordlines) + $inprov = $false + foreach ($line in $recordlines) { + if ($line -match '^\s*\[') { + $inprov = ($line -match '^\s*\[provenance\]\s*$') + continue + } + if ($inprov) { + $m = [regex]::Match($line, '^\s*class\s*=\s*"(.*)"\s*$') + if ($m.Success) { return $m.Groups[1].Value } + } + } + return "" +} #G-117 embedded record: zip CENTRAL-DIRECTORY read of the exe-appended archive via #.NET System.IO.Compression (offsets resolve from the end-of-central-directory #record, so the prepended executable data is no obstacle). The target is NEVER @@ -1221,6 +1246,18 @@ function psmain { } } } + #G-123 schema v2: compact build-origin tag from the LOCAL + #record beside the row's file - suite-built stays quiet + #(expected state). A listing does no per-row remote fetches, + #so remote-only rows and tomlless strays carry no tag + #(no-basis degradation). + $ptoml = Join-Path -Path $archfolder -ChildPath ((Get-PunkRuntimeRootName $key) + ".toml") + if (Test-Path -Path $ptoml -PathType Leaf) { + $pclass = Get-PunkRuntimeProvenanceClass ([string[]](Get-Content -Path $ptoml)) + if ($pclass -ne "" -and $pclass -ne "suite-built") { + if ($mid -ne "") { $mid = "$mid class=$pclass" } else { $mid = "class=$pclass" } + } + } #ansi problems from cmd.exe not in windows terminal - review $C = "" $RST = "" @@ -1333,7 +1370,7 @@ function psmain { if ($havesidecar) { $sfields = Get-PunkRuntimeRecordFields ([string[]](Get-Content -Path $sidecarfile)) } write-host (" {0,-20} {1,-36} {2}" -f "field", "embedded", "sidecar") $disagreements = @() - foreach ($k in @('schema','name','class','variant','working_name','revision','target','build_id','origin','packager','project','project_url','license','build_host_platform','tcl_patchlevel','sha1','size','built')) { + foreach ($k in @('schema','name','class','variant','working_name','revision','target','build_id','origin','packager','builder','source_url','upstream_ref','retrieved','project','project_url','license','build_host_platform','tcl_patchlevel','sha1','size','built')) { $ev = ""; $sv = "" if ($efields.ContainsKey($k)) { $ev = $efields[$k] } if ($sfields.ContainsKey($k)) { $sv = $sfields[$k] } @@ -1344,6 +1381,18 @@ function psmain { #schema absent on one side is pre-v1 tolerance, not a disagreement if (($ev -ne "") -and ($sv -ne "") -and ($ev -cne $sv)) { $disagreements += $k } } + #G-123 schema v2: [provenance] class as its own derived row - the + #flat scan above reports [artifact] class per the documented + #ordering caveat, so this key needs the table-aware read + $pcev = ""; $pcsv = "" + if ($null -ne $embedtext) { $pcev = Get-PunkRuntimeProvenanceClass ($embedtext -split "`r?`n") } + if ($havesidecar) { $pcsv = Get-PunkRuntimeProvenanceClass ([string[]](Get-Content -Path $sidecarfile)) } + if (($pcev -ne "") -or ($pcsv -ne "")) { + $pcevd = "-"; if ($pcev -ne "") { $pcevd = $pcev } + $pcsvd = "-"; if ($pcsv -ne "") { $pcsvd = $pcsv } + write-host (" {0,-20} {1,-36} {2}" -f "provenance_class", $pcevd, $pcsvd) + if (($pcev -ne "") -and ($pcsv -ne "") -and ($pcev -cne $pcsv)) { $disagreements += "provenance_class" } + } write-host "-----------------------------------------------------------------------" if ($disagreements.Count) { write-host " !DISAGREE embedded-vs-sidecar on: $($disagreements -join ' ')"