Add source-first CLI with guarded writes and reviewed evidence

This commit is contained in:
2026-09-11 05:14:13 -07:00
parent 2ec72d4241
commit 01b76a1e89
16 changed files with 2179 additions and 2 deletions
@@ -0,0 +1,112 @@
arcadia 7;
project alarm_suite "Alarm response" id "a0f5c4c2-f39c-4095-9816-71f1862e24d8" {
description "A complete small OA/SA source-authoring example. Numerical annotations are descriptive. Literal aliases: @alarm_response; @maintenance; @alarm_message; @response_view; @detector_card; @response_procedure; @assessment_refinement;";
oa_actor plant_operator "Plant operator" id "60539571-2921-4e7d-ab83-bae670d0cb15" {}
oa_entity maintenance_staff "Maintenance team" id "6af96577-1b04-4ba1-b91b-6cef61adc6d6" {}
oa_activity manage_alarm "Manage a pressure alarm" id "4154bf39-9fd5-490e-aebf-fba3d67b697c" {
oa_activity detect_alarm "Detect alarm" id "bf9e9d8a-edb2-47f4-93f9-7ae373c42160" {}
// Assessing the alarm is work decomposition, independently allocated below.
oa_activity assess_alarm "Assess alarm" id "8cbd5a4f-1c31-49c9-8a01-987144ce962e" {}
}
oa_capability safe_response "Respond safely" id "c097b1b5-45dc-49de-bcf6-89b5ccb752d1" {}
oa_exchange_item alarm_report "Alarm report" id "0a48a460-964a-4578-97c4-428707e8b201" {
mechanism Flow;
oa_data_field reported_pressure "Reported pressure" id "0bf7f442-cc8d-4782-ba65-f357e91fd477" {
type_ref Real;
unit "kPa";
}
}
allocation operator_detects "Operator detects" id "8653fb7d-529d-495d-abde-897dee36b4bb" {
source @plant_operator; target @detect_alarm;
}
allocation team_assesses "Team assesses" id "bb36afbf-9878-401b-b172-d04b08ecf603" {
source @maintenance_staff; target @assess_alarm;
}
interaction alarm_payload "Pressure alarm report" id "269e5bdd-2478-4a43-9c77-84d99ac4e8a6" {
source @detect_alarm; target @assess_alarm; items [@alarm_report];
}
capability_involvement assessment_supports_response "Assessment supports safe response" id "27633a6d-d962-4d19-9367-9ca3f00de0b0" {
source @assess_alarm; target @safe_response;
}
oa_process triage "Alarm triage" id "9888d781-09f3-4861-b9dc-7a97080d24d6" {
steps [@detect_once, @assess_once];
oa_occurrence detect_once "Detect this alarm" id "6ca87cbe-9579-49b3-884e-e6ee63ba8c5b" {
body { Action { action @detect_alarm; lifeline none; }; };
}
oa_occurrence assess_once "Assess this alarm" id "528d1c78-62d9-4e45-bb4a-cf529d8ed4a9" {
body { Action { action @assess_alarm; lifeline none; }; };
}
}
sequence_link assessment_after_detection "Assess after detecting" id "bfd9c0e7-832b-4983-90aa-fc37d23193e2" {
source @detect_once; target @assess_once;
}
chain_involvement triage_supports_response "Triage supports safe response" id "2aeba184-bf69-49c7-87ff-cc2da82b006c" {
source @triage; target @safe_response;
}
oa_scenario notification "Alarm notification" id "69e23f04-7bb3-4db1-a2a3-d8e65101c546" {
viewpoint OperationalActivity;
context @safe_response;
steps [@notify_once];
oa_lifeline detector_line "Detector" id "57c62024-6d19-4818-ac8c-66fb4a9b3da7" { represented @detect_alarm; }
oa_lifeline assessor_line "Assessor" id "1b421446-9d17-4c8b-90f1-6fbe8b513a04" { represented @assess_alarm; }
oa_occurrence notify_once "Report this pressure" id "a1c37b31-41ed-4e16-a243-a50702ff1bc1" {
body { Exchange {
exchange @alarm_payload; sender @detector_line; receiver @assessor_line;
message_kind Asynchronous; reply_to none;
values [{ field @reported_pressure; path []; expression "420"; }];
}; };
}
}
sa_system alarm_console "Alarm console" id "9ea585b5-be12-4204-8909-02ea9bed49f0" {
sa_state_machine console_status "Console status" id "a6c6f463-5c80-4b02-a2e6-67cd0088b2f2" {
sa_region console_region "Main region" id "e8b62edc-2233-4ec4-a811-2e8baf81a6e9" {
sa_initial console_start "Start" id "5a92c3a8-6af5-452a-849e-c2a17dc33260" {}
sa_state console_ready "Ready" id "9064a197-96ea-4bdf-9dd6-2e9ef66856d8" {}
sa_state console_alerting "Alerting" id "4d167878-2bbe-4acd-abd6-ee7dcd42ec50" {}
}
}
}
sa_function classify_alarm "Classify alarm" id "ad6941ee-f900-4a2b-a368-d8879f1ffece" {}
sa_functional_chain classification_flow "Alarm classification" id "578dbcd5-3c28-43d8-913e-af27bc51ebde" {
steps [@classify_once];
sa_occurrence classify_once "Classify this alarm" id "a6c37863-8e72-44f9-a8a3-fea06341c714" {
body { Action { action @classify_alarm; lifeline none; }; };
}
}
allocation console_classifies "Console classifies" id "294d4262-303f-41db-b01e-fe47c1647693" {
source @alarm_console; target @classify_alarm;
}
sa_event alarm_received "Alarm received" id "7fba860a-721f-4da2-8315-010de2e9c69e" {}
state_transition initialize_console "Initialize" id "839d4359-c78f-414b-867e-5b40b1f145cc" {
source @console_start; target @console_ready;
}
state_transition display_alarm "Display alarm" id "dd383165-1b89-46b9-8ae3-80a6b6406a4e" {
source @console_ready; target @console_alerting; triggers [@alarm_received];
}
trace assessment_alignment "Alarm classification refines assessment" id "34142333-67c2-4972-a64f-47e140ed93ca" {
oa @assess_alarm; sa @classify_alarm;
baseline {
oa { name "Assess alarm"; description ""; };
sa { name "Classify alarm"; description ""; };
};
}
artifact response_handbook "Response procedure" id "6ba54037-c6f1-495b-ba96-6f2e910a218c" {
owner @assess_alarm; uri "procedures/alarm-response.md"; revision "review-1";
}
diagram response_map "Operational work" id "a44d9d69-78a0-49de-8eb8-3757aa6c0919" { projection FunctionalDataflow; }
node detector_tile id "45f016f4-3558-45b9-9559-da8ef9d5dcad" {
diagram @response_map; element @detect_alarm;
position { x 40; y 40; };
}
node assessor_card id "6ee7a0cc-013b-4a0f-8cff-513872e028b7" {
diagram @response_map; element @assess_alarm;
position { x 400; y 40; };
}
}
// Retain these comment references: @alarm_response; @maintenance; @alarm_message; @response_view; @detector_card; @response_procedure; @assessment_refinement;
@@ -0,0 +1,112 @@
arcadia 7;
project alarm_response "Alarm response" id "a0f5c4c2-f39c-4095-9816-71f1862e24d8" {
description "A complete small OA/SA source-authoring example. Numerical annotations are descriptive. Literal aliases: @alarm_response; @maintenance; @alarm_message; @response_view; @detector_card; @response_procedure; @assessment_refinement;";
oa_actor plant_operator "Plant operator" id "60539571-2921-4e7d-ab83-bae670d0cb15" {}
oa_entity maintenance "Maintenance team" id "6af96577-1b04-4ba1-b91b-6cef61adc6d6" {}
oa_activity manage_alarm "Manage a pressure alarm" id "4154bf39-9fd5-490e-aebf-fba3d67b697c" {
oa_activity detect_alarm "Detect alarm" id "bf9e9d8a-edb2-47f4-93f9-7ae373c42160" {}
// Assessing the alarm is work decomposition, independently allocated below.
oa_activity assess_alarm "Assess alarm" id "8cbd5a4f-1c31-49c9-8a01-987144ce962e" {}
}
oa_capability safe_response "Respond safely" id "c097b1b5-45dc-49de-bcf6-89b5ccb752d1" {}
oa_exchange_item alarm_report "Alarm report" id "0a48a460-964a-4578-97c4-428707e8b201" {
mechanism Flow;
oa_data_field reported_pressure "Reported pressure" id "0bf7f442-cc8d-4782-ba65-f357e91fd477" {
type_ref Real;
unit "kPa";
}
}
allocation operator_detects "Operator detects" id "8653fb7d-529d-495d-abde-897dee36b4bb" {
source @plant_operator; target @detect_alarm;
}
allocation team_assesses "Team assesses" id "bb36afbf-9878-401b-b172-d04b08ecf603" {
source @maintenance; target @assess_alarm;
}
interaction alarm_message "Pressure alarm report" id "269e5bdd-2478-4a43-9c77-84d99ac4e8a6" {
source @detect_alarm; target @assess_alarm; items [@alarm_report];
}
capability_involvement assessment_supports_response "Assessment supports safe response" id "27633a6d-d962-4d19-9367-9ca3f00de0b0" {
source @assess_alarm; target @safe_response;
}
oa_process triage "Alarm triage" id "9888d781-09f3-4861-b9dc-7a97080d24d6" {
steps [@detect_once, @assess_once];
oa_occurrence detect_once "Detect this alarm" id "6ca87cbe-9579-49b3-884e-e6ee63ba8c5b" {
body { Action { action @detect_alarm; lifeline none; }; };
}
oa_occurrence assess_once "Assess this alarm" id "528d1c78-62d9-4e45-bb4a-cf529d8ed4a9" {
body { Action { action @assess_alarm; lifeline none; }; };
}
}
sequence_link assessment_after_detection "Assess after detecting" id "bfd9c0e7-832b-4983-90aa-fc37d23193e2" {
source @detect_once; target @assess_once;
}
chain_involvement triage_supports_response "Triage supports safe response" id "2aeba184-bf69-49c7-87ff-cc2da82b006c" {
source @triage; target @safe_response;
}
oa_scenario notification "Alarm notification" id "69e23f04-7bb3-4db1-a2a3-d8e65101c546" {
viewpoint OperationalActivity;
context @safe_response;
steps [@notify_once];
oa_lifeline detector_line "Detector" id "57c62024-6d19-4818-ac8c-66fb4a9b3da7" { represented @detect_alarm; }
oa_lifeline assessor_line "Assessor" id "1b421446-9d17-4c8b-90f1-6fbe8b513a04" { represented @assess_alarm; }
oa_occurrence notify_once "Report this pressure" id "a1c37b31-41ed-4e16-a243-a50702ff1bc1" {
body { Exchange {
exchange @alarm_message; sender @detector_line; receiver @assessor_line;
message_kind Asynchronous; reply_to none;
values [{ field @reported_pressure; path []; expression "420"; }];
}; };
}
}
sa_system alarm_console "Alarm console" id "9ea585b5-be12-4204-8909-02ea9bed49f0" {
sa_state_machine console_status "Console status" id "a6c6f463-5c80-4b02-a2e6-67cd0088b2f2" {
sa_region console_region "Main region" id "e8b62edc-2233-4ec4-a811-2e8baf81a6e9" {
sa_initial console_start "Start" id "5a92c3a8-6af5-452a-849e-c2a17dc33260" {}
sa_state console_ready "Ready" id "9064a197-96ea-4bdf-9dd6-2e9ef66856d8" {}
sa_state console_alerting "Alerting" id "4d167878-2bbe-4acd-abd6-ee7dcd42ec50" {}
}
}
}
sa_function classify_alarm "Classify alarm" id "ad6941ee-f900-4a2b-a368-d8879f1ffece" {}
sa_functional_chain classification_flow "Alarm classification" id "578dbcd5-3c28-43d8-913e-af27bc51ebde" {
steps [@classify_once];
sa_occurrence classify_once "Classify this alarm" id "a6c37863-8e72-44f9-a8a3-fea06341c714" {
body { Action { action @classify_alarm; lifeline none; }; };
}
}
allocation console_classifies "Console classifies" id "294d4262-303f-41db-b01e-fe47c1647693" {
source @alarm_console; target @classify_alarm;
}
sa_event alarm_received "Alarm received" id "7fba860a-721f-4da2-8315-010de2e9c69e" {}
state_transition initialize_console "Initialize" id "839d4359-c78f-414b-867e-5b40b1f145cc" {
source @console_start; target @console_ready;
}
state_transition display_alarm "Display alarm" id "dd383165-1b89-46b9-8ae3-80a6b6406a4e" {
source @console_ready; target @console_alerting; triggers [@alarm_received];
}
trace assessment_refinement "Alarm classification refines assessment" id "34142333-67c2-4972-a64f-47e140ed93ca" {
oa @assess_alarm; sa @classify_alarm;
baseline {
oa { name "Assess alarm"; description ""; };
sa { name "Classify alarm"; description ""; };
};
}
artifact response_procedure "Response procedure" id "6ba54037-c6f1-495b-ba96-6f2e910a218c" {
owner @assess_alarm; uri "procedures/alarm-response.md"; revision "review-1";
}
diagram response_view "Operational work" id "a44d9d69-78a0-49de-8eb8-3757aa6c0919" { projection FunctionalDataflow; }
node detector_card id "45f016f4-3558-45b9-9559-da8ef9d5dcad" {
diagram @response_view; element @detect_alarm;
position { x 40; y 40; };
}
node assessor_card id "6ee7a0cc-013b-4a0f-8cff-513872e028b7" {
diagram @response_view; element @assess_alarm;
position { x 400; y 40; };
}
}
// Retain these comment references: @alarm_response; @maintenance; @alarm_message; @response_view; @detector_card; @response_procedure; @assessment_refinement;
@@ -0,0 +1,200 @@
param(
[Parameter(Mandatory = $true)][string]$Repository,
[ValidatePattern('^[a-z0-9-]+$')][string]$RunName = 'verified'
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
$repoRoot = [IO.Path]::GetFullPath($Repository)
$utf8 = [Text.UTF8Encoding]::new($false, $true)
$exe = Join-Path $repoRoot '.local/source-cli-20260911/verified/arcadia.exe'
$expectedExeHash = 'BAD169F8BE78DCFA74B32714569C886DD2132727080684FC2BA618D5822E3559'
$runRoot = Join-Path $repoRoot ('.local/source-cli-independent-20260911/' + $RunName)
if (Test-Path -LiteralPath $runRoot) { throw "Refusing to replace prior evidence: $runRoot" }
$checks = [Collections.Generic.List[string]]::new()
$operations = [Collections.Generic.List[object]]::new()
function Assert-That([bool]$condition, [string]$label) {
if (!$condition) { throw "Independent contract failed: $label" }
$checks.Add($label)
}
function Put([string]$path, [string]$value) {
[IO.Directory]::CreateDirectory([IO.Path]::GetDirectoryName($path)) | Out-Null
[IO.File]::WriteAllText($path, $value, $utf8)
}
function Read-Exact([string]$path) { [IO.File]::ReadAllText($path, $utf8) }
function Text-Hash([string]$text) {
[Convert]::ToHexString([Security.Cryptography.SHA256]::HashData($utf8.GetBytes($text)))
}
function Invoke-ArcadiaProbe([string[]]$words) {
$info = [Diagnostics.ProcessStartInfo]::new($exe)
$info.UseShellExecute = $false
$info.CreateNoWindow = $true
$info.RedirectStandardOutput = $true
$info.RedirectStandardError = $true
$info.StandardOutputEncoding = $utf8
$info.StandardErrorEncoding = $utf8
foreach ($word in $words) { $info.ArgumentList.Add($word) }
$info.ArgumentList.Add('--json')
$process = [Diagnostics.Process]::new()
$process.StartInfo = $info
$process.Start() | Out-Null
$output = $process.StandardOutput.ReadToEndAsync()
$errorText = $process.StandardError.ReadToEndAsync()
if (!$process.WaitForExit(60000)) {
$process.Kill($true)
throw 'CLI probe exceeded 60 seconds'
}
$raw = $output.GetAwaiter().GetResult()
$err = $errorText.GetAwaiter().GetResult()
$report = $raw | ConvertFrom-Json -Depth 100
Assert-That ($process.ExitCode -eq $report.exit_code) 'process exit agrees with JSON'
Assert-That ($err -ceq '') 'JSON invocation emits no mixed stderr'
$operations.Add([ordered]@{
Arguments = @($words | ForEach-Object { $_.Replace($runRoot, '<fixture>') })
Exit = $process.ExitCode
Status = $report.status
Changes = @($report.changes).Count
Diagnostics = @($report.diagnostics).Count
StdoutSHA256 = Text-Hash $raw
})
$process.Dispose()
return $report
}
Assert-That ((Get-FileHash -LiteralPath $exe).Hash -ceq $expectedExeHash) 'immutable CLI binary pin'
[IO.Directory]::CreateDirectory($runRoot) | Out-Null
# Predict every changed header/reference before the first mutating invocation.
# This fixture has explicit UUIDs for all seven Project::identities families.
$sourcePath = Join-Path $repoRoot 'harness/experiments/textual-authoring-20260911/observed/stabilized.arcadia'
$source = Read-Exact $sourcePath
$sourceHash = Text-Hash $source
$aliases = @(
[pscustomobject]@{ Family = 'project'; Kind = 'project'; Old = 'alarm_response'; New = 'alarm_suite'; References = 0 },
[pscustomobject]@{ Family = 'element'; Kind = 'oa_entity'; Old = 'maintenance'; New = 'maintenance_staff'; References = 1 },
[pscustomobject]@{ Family = 'relation'; Kind = 'interaction'; Old = 'alarm_message'; New = 'alarm_payload'; References = 1 },
[pscustomobject]@{ Family = 'diagram'; Kind = 'diagram'; Old = 'response_view'; New = 'response_map'; References = 2 },
[pscustomobject]@{ Family = 'placement'; Kind = 'node'; Old = 'detector_card'; New = 'detector_tile'; References = 0 },
[pscustomobject]@{ Family = 'artifact'; Kind = 'artifact'; Old = 'response_procedure'; New = 'response_handbook'; References = 0 },
[pscustomobject]@{ Family = 'trace'; Kind = 'trace'; Old = 'assessment_refinement'; New = 'assessment_alignment'; References = 0 }
)
$literal = ($aliases | ForEach-Object { '@' + $_.Old + ';' }) -join ' '
$source = $source.Replace('Numerical annotations are descriptive.', 'Numerical annotations are descriptive. Literal aliases: ' + $literal)
$source += "`r`n// Retain these comment references: $literal`r`n"
$expected = $source
$predictions = [Collections.Generic.List[object]]::new()
foreach ($case in $aliases) {
$header = $case.Kind + ' ' + $case.Old + ' '
Assert-That (([regex]::Matches($expected, [regex]::Escape($header))).Count -eq 1) ($case.Family + ' has one literal declaration header')
$next = $expected.Replace($header, $case.Kind + ' ' + $case.New + ' ')
# The known live references occupy these exact fields; prose/comments are excluded.
$field = switch ($case.Family) { 'element' { 'source' }; 'relation' { 'exchange' }; 'diagram' { 'diagram' }; default { $null } }
if ($null -ne $field) {
$oldReference = $field + ' @' + $case.Old + ';'
Assert-That (([regex]::Matches($next, [regex]::Escape($oldReference))).Count -eq $case.References) ($case.Family + ' live-reference count')
$next = $next.Replace($oldReference, $field + ' @' + $case.New + ';')
}
$predictions.Add([pscustomobject]@{ Case = $case; Before = $expected; After = $next })
$expected = $next
}
$aliasEntry = Join-Path $runRoot 'aliases/project.arcadia'
Put $aliasEntry $source
Put (Join-Path $PSScriptRoot 'alias-input.arcadia') $source
Put (Join-Path $PSScriptRoot 'alias-expected-final.arcadia') $expected
$baseline = Invoke-ArcadiaProbe @('check', $aliasEntry)
Assert-That ($baseline.exit_code -eq 0) 'all-family baseline is admitted before mutation'
Assert-That ($baseline.identities_to_stabilize -eq 0) 'all-family baseline has no missing identities'
Assert-That (([regex]::Matches($source, ' id "[0-9a-f-]{36}"')).Count -eq 40) 'all-family baseline contains exactly 40 authored UUIDs'
foreach ($prediction in $predictions) {
$case = $prediction.Case
$preview = Invoke-ArcadiaProbe @('rename-alias', $aliasEntry, $case.Old, $case.New)
Assert-That ($preview.exit_code -eq 0 -and !$preview.written -and $preview.status -ceq 'preview') ($case.Family + ' preview succeeds without write')
Assert-That ((Read-Exact $aliasEntry) -ceq $prediction.Before) ($case.Family + ' preview preserves exact input bytes')
Assert-That (@($preview.changes).Count -eq 1) ($case.Family + ' reports exactly one changed file')
Assert-That ($preview.changes[0].path -ceq 'project.arcadia') ($case.Family + ' preserves file ownership')
Assert-That ($preview.changes[0].before -ceq $prediction.Before) ($case.Family + ' reports exact captured text')
Assert-That ($preview.changes[0].after -ceq $prediction.After) ($case.Family + ' changes only independently predicted header/live-reference tokens')
Assert-That ($preview.identities_to_stabilize -eq 0 -and $null -eq $preview.migration) ($case.Family + ' invents no identity or migration')
$written = Invoke-ArcadiaProbe @('rename-alias', $aliasEntry, $case.Old, $case.New, '--write')
Assert-That ($written.exit_code -eq 0 -and $written.written -and $written.status -ceq 'written') ($case.Family + ' write succeeds')
Assert-That ($written.changes[0].after -ceq $prediction.After) ($case.Family + ' stable separate write invocation has exact preview text')
Assert-That ((Read-Exact $aliasEntry) -ceq $prediction.After) ($case.Family + ' persisted text equals independent expectation')
}
$afterCheck = Invoke-ArcadiaProbe @('check', $aliasEntry)
Assert-That ($afterCheck.exit_code -eq 0) 'all-family final source is freshly admitted'
$mtime = [IO.File]::GetLastWriteTimeUtc($aliasEntry)
$noop = Invoke-ArcadiaProbe @('stabilize', $aliasEntry, '--write')
Assert-That ($noop.exit_code -eq 0 -and $noop.status -ceq 'unchanged' -and !$noop.written -and @($noop.changes).Count -eq 0) 'stable all-family source is a true no-op'
Assert-That ([IO.File]::GetLastWriteTimeUtc($aliasEntry) -eq $mtime) 'no-op preserves source modification time'
Assert-That ((Read-Exact $aliasEntry) -ceq $expected) 'no-op preserves every source byte'
Assert-That (@(Get-ChildItem -LiteralPath (Split-Path -Parent $aliasEntry) -File -Recurse -Force).Count -eq 1) 'writes leave no unexpected physical file'
# Two warnings in one CRLF/Unicode include expose the shifted-second-span trap.
$rawEntry = Join-Path $runRoot 'raw/project.arcadia'
$workPath = Join-Path $runRoot 'raw/work.arcadia'
$entryText = 'arcadia 7; project diagnostic_case "Diagnostics" id "11000000-0000-4000-8000-000000000001" { include "work.arcadia"; }' + "`r`n"
$rawWork = "// Пролог 😀`r`n" + 'sa_function first "航海" {}' + "`r`n" + 'sa_function second "Deuxième" {}' + "`r`n"
Put $rawEntry $entryText
Put $workPath $rawWork
function Check-Warnings($report, [string]$rawText, [bool]$explicit) {
Assert-That ($report.exit_code -eq 0) 'partial unallocated functions remain valid'
$warnings = @($report.diagnostics | Where-Object { $_.code -ceq 'unallocated_leaf' })
Assert-That ($warnings.Count -eq 2) 'exactly two raw unallocated-leaf diagnostics without stabilized duplicates'
$index = 0
foreach ($alias in @('first', 'second')) {
$start = $utf8.GetByteCount($rawText.Substring(0, $rawText.IndexOf('sa_function ' + $alias, [StringComparison]::Ordinal)))
$warning = @($warnings | Where-Object { $_.location.start -eq $start })
Assert-That ($warning.Count -eq 1) ($alias + ' warning starts at original UTF-8 declaration offset')
Assert-That ($warning[0].coordinate_space -ceq 'input' -and $warning[0].location.path -ceq 'work.arcadia') ($alias + ' warning identifies raw include')
Assert-That ($warning[0].location.line -eq ($index + 2) -and $warning[0].location.column -eq 1) ($alias + ' CRLF/Unicode line and scalar column')
$bytes = $utf8.GetBytes($rawText)
$location = $warning[0].location
Assert-That ($location.end -gt $start -and $location.end -le $bytes.Length) ($alias + ' warning ends inside raw input')
$slice = $utf8.GetString($bytes, $start, $location.end - $start)
Assert-That ($slice.Contains('sa_function ' + $alias)) ($alias + ' raw diagnostic slice identifies intended declaration')
$expectedId = if ($explicit) { '11000000-0000-4000-8000-00000000000' + ($index + 2) } else { $null }
Assert-That ($warning[0].object_id -ceq $expectedId) ($alias + ' diagnostic identity has correct authored/provisional status')
$index++
}
}
$rawCheck = Invoke-ArcadiaProbe @('check', $rawEntry)
Check-Warnings $rawCheck $rawWork $false
$rawPreview = Invoke-ArcadiaProbe @('stabilize', $rawEntry)
Check-Warnings $rawPreview $rawWork $false
Assert-That ((Read-Exact $rawEntry) -ceq $entryText -and (Read-Exact $workPath) -ceq $rawWork) 'raw diagnostics and preview retain both exact source files'
Assert-That (@($rawPreview.changes).Count -eq 1 -and $rawPreview.changes[0].path -ceq 'work.arcadia') 'only missing-ID include is proposed for stabilization'
$candidateText = $rawPreview.changes[0].after
Assert-That ($utf8.GetByteCount($candidateText.Substring(0, $candidateText.IndexOf('sa_function second'))) -gt $utf8.GetByteCount($rawWork.Substring(0, $rawWork.IndexOf('sa_function second')))) 'fixture genuinely shifts second declaration in proposed candidate'
$authoredWork = $rawWork.Replace('first "航海" {', 'first "航海" id "11000000-0000-4000-8000-000000000002" {').Replace('second "Deuxième" {', 'second "Deuxième" id "11000000-0000-4000-8000-000000000003" {')
Put $workPath $authoredWork
$authoredCheck = Invoke-ArcadiaProbe @('lint', $rawEntry)
Check-Warnings $authoredCheck $authoredWork $true
Assert-That ((Read-Exact $workPath) -ceq $authoredWork) 'authored-ID lint is read-only'
# A non-BMP symbol before the bad reference distinguishes scalar columns from UTF-16 units.
$invalidWork = "// Пролог 😀`r`n" + 'sa_function invalid "Deuxième 🚨" { parent @absent; }' + "`r`n"
Put $workPath $invalidWork
$invalid = Invoke-ArcadiaProbe @('stabilize', $rawEntry, '--write')
Assert-That ($invalid.exit_code -eq 1 -and !$invalid.written -and @($invalid.changes).Count -eq 0) 'invalid raw Unicode source is refused before any candidate write'
$referenceIndex = $invalidWork.IndexOf('@absent', [StringComparison]::Ordinal)
$referenceStart = $utf8.GetByteCount($invalidWork.Substring(0, $referenceIndex))
$errorAt = @($invalid.diagnostics | Where-Object { $_.severity -ceq 'error' -and $_.location.start -eq $referenceStart })
Assert-That ($errorAt.Count -eq 1) 'unresolved reference uses exact raw UTF-8 byte start'
$linePrefix = $invalidWork.Substring($invalidWork.IndexOf("`n") + 1, $referenceIndex - $invalidWork.IndexOf("`n") - 1)
$scalarColumn = @($linePrefix.ToCharArray() | Where-Object { ![char]::IsLowSurrogate($_) }).Count + 1
Assert-That ($errorAt[0].location.line -eq 2 -and $errorAt[0].location.column -eq $scalarColumn) 'non-BMP prefix uses Unicode scalar column rather than UTF-16 units'
Assert-That ($errorAt[0].coordinate_space -ceq 'input' -and $null -eq $errorAt[0].object_id) 'invalid input exposes neither candidate coordinate nor ephemeral identity'
Assert-That ((Read-Exact $workPath) -ceq $invalidWork -and (Read-Exact $rawEntry) -ceq $entryText) 'invalid write retains complete input bundle bytes'
Assert-That ((Get-FileHash -LiteralPath $exe).Hash -ceq $expectedExeHash) 'CLI pin remains unchanged after probes'
$result = [ordered]@{
Reviewer = 'Codex-9e8r6t /root/behavior_audit'
RecordedUtc = [DateTime]::UtcNow.ToString('O')
BinarySHA256 = $expectedExeHash
InitialPublishedFixtureSHA256 = $sourceHash
AliasInputSHA256 = Text-Hash $source
AliasExpectedFinalSHA256 = Text-Hash $expected
CheckCount = $checks.Count
Checks = $checks.ToArray()
Operations = $operations.ToArray()
Limits = 'Independent CLI process/source-byte checks only; no production compile, full Project comparison, concurrency proof, Linux or native GUI claim.'
}
Put (Join-Path $PSScriptRoot 'result.json') ($result | ConvertTo-Json -Depth 100)
Write-Output "PASS: $($checks.Count) independent assertions across $($operations.Count) frozen CLI invocations."
@@ -0,0 +1,465 @@
{
"Reviewer": "Codex-9e8r6t /root/behavior_audit",
"RecordedUtc": "2026-09-11T11:59:00.5676616Z",
"BinarySHA256": "BAD169F8BE78DCFA74B32714569C886DD2132727080684FC2BA618D5822E3559",
"InitialPublishedFixtureSHA256": "E68D7162F6F7656AAD51853E5A38DECD2D84F4CC3B6A9120AF86AC7A64AA92A2",
"AliasInputSHA256": "53ACB827AB030203411D0E29907142AA83ECD65C133D5C975DDB9AB74920308B",
"AliasExpectedFinalSHA256": "1DCFFDEDEE6B2647F20442D1A8E74BF72AFBF30F1B067F3C947D52117B032C44",
"CheckCount": 183,
"Checks": [
"immutable CLI binary pin",
"project has one literal declaration header",
"element has one literal declaration header",
"element live-reference count",
"relation has one literal declaration header",
"relation live-reference count",
"diagram has one literal declaration header",
"diagram live-reference count",
"placement has one literal declaration header",
"artifact has one literal declaration header",
"trace has one literal declaration header",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"all-family baseline is admitted before mutation",
"all-family baseline has no missing identities",
"all-family baseline contains exactly 40 authored UUIDs",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"project preview succeeds without write",
"project preview preserves exact input bytes",
"project reports exactly one changed file",
"project preserves file ownership",
"project reports exact captured text",
"project changes only independently predicted header/live-reference tokens",
"project invents no identity or migration",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"project write succeeds",
"project stable separate write invocation has exact preview text",
"project persisted text equals independent expectation",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"element preview succeeds without write",
"element preview preserves exact input bytes",
"element reports exactly one changed file",
"element preserves file ownership",
"element reports exact captured text",
"element changes only independently predicted header/live-reference tokens",
"element invents no identity or migration",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"element write succeeds",
"element stable separate write invocation has exact preview text",
"element persisted text equals independent expectation",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"relation preview succeeds without write",
"relation preview preserves exact input bytes",
"relation reports exactly one changed file",
"relation preserves file ownership",
"relation reports exact captured text",
"relation changes only independently predicted header/live-reference tokens",
"relation invents no identity or migration",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"relation write succeeds",
"relation stable separate write invocation has exact preview text",
"relation persisted text equals independent expectation",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"diagram preview succeeds without write",
"diagram preview preserves exact input bytes",
"diagram reports exactly one changed file",
"diagram preserves file ownership",
"diagram reports exact captured text",
"diagram changes only independently predicted header/live-reference tokens",
"diagram invents no identity or migration",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"diagram write succeeds",
"diagram stable separate write invocation has exact preview text",
"diagram persisted text equals independent expectation",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"placement preview succeeds without write",
"placement preview preserves exact input bytes",
"placement reports exactly one changed file",
"placement preserves file ownership",
"placement reports exact captured text",
"placement changes only independently predicted header/live-reference tokens",
"placement invents no identity or migration",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"placement write succeeds",
"placement stable separate write invocation has exact preview text",
"placement persisted text equals independent expectation",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"artifact preview succeeds without write",
"artifact preview preserves exact input bytes",
"artifact reports exactly one changed file",
"artifact preserves file ownership",
"artifact reports exact captured text",
"artifact changes only independently predicted header/live-reference tokens",
"artifact invents no identity or migration",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"artifact write succeeds",
"artifact stable separate write invocation has exact preview text",
"artifact persisted text equals independent expectation",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"trace preview succeeds without write",
"trace preview preserves exact input bytes",
"trace reports exactly one changed file",
"trace preserves file ownership",
"trace reports exact captured text",
"trace changes only independently predicted header/live-reference tokens",
"trace invents no identity or migration",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"trace write succeeds",
"trace stable separate write invocation has exact preview text",
"trace persisted text equals independent expectation",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"all-family final source is freshly admitted",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"stable all-family source is a true no-op",
"no-op preserves source modification time",
"no-op preserves every source byte",
"writes leave no unexpected physical file",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"partial unallocated functions remain valid",
"exactly two raw unallocated-leaf diagnostics without stabilized duplicates",
"first warning starts at original UTF-8 declaration offset",
"first warning identifies raw include",
"first CRLF/Unicode line and scalar column",
"first warning ends inside raw input",
"first raw diagnostic slice identifies intended declaration",
"first diagnostic identity has correct authored/provisional status",
"second warning starts at original UTF-8 declaration offset",
"second warning identifies raw include",
"second CRLF/Unicode line and scalar column",
"second warning ends inside raw input",
"second raw diagnostic slice identifies intended declaration",
"second diagnostic identity has correct authored/provisional status",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"partial unallocated functions remain valid",
"exactly two raw unallocated-leaf diagnostics without stabilized duplicates",
"first warning starts at original UTF-8 declaration offset",
"first warning identifies raw include",
"first CRLF/Unicode line and scalar column",
"first warning ends inside raw input",
"first raw diagnostic slice identifies intended declaration",
"first diagnostic identity has correct authored/provisional status",
"second warning starts at original UTF-8 declaration offset",
"second warning identifies raw include",
"second CRLF/Unicode line and scalar column",
"second warning ends inside raw input",
"second raw diagnostic slice identifies intended declaration",
"second diagnostic identity has correct authored/provisional status",
"raw diagnostics and preview retain both exact source files",
"only missing-ID include is proposed for stabilization",
"fixture genuinely shifts second declaration in proposed candidate",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"partial unallocated functions remain valid",
"exactly two raw unallocated-leaf diagnostics without stabilized duplicates",
"first warning starts at original UTF-8 declaration offset",
"first warning identifies raw include",
"first CRLF/Unicode line and scalar column",
"first warning ends inside raw input",
"first raw diagnostic slice identifies intended declaration",
"first diagnostic identity has correct authored/provisional status",
"second warning starts at original UTF-8 declaration offset",
"second warning identifies raw include",
"second CRLF/Unicode line and scalar column",
"second warning ends inside raw input",
"second raw diagnostic slice identifies intended declaration",
"second diagnostic identity has correct authored/provisional status",
"authored-ID lint is read-only",
"process exit agrees with JSON",
"JSON invocation emits no mixed stderr",
"invalid raw Unicode source is refused before any candidate write",
"unresolved reference uses exact raw UTF-8 byte start",
"non-BMP prefix uses Unicode scalar column rather than UTF-16 units",
"invalid input exposes neither candidate coordinate nor ephemeral identity",
"invalid write retains complete input bundle bytes",
"CLI pin remains unchanged after probes"
],
"Operations": [
{
"Arguments": [
"check",
"<fixture>\\aliases\\project.arcadia"
],
"Exit": 0,
"Status": "checked",
"Changes": 0,
"Diagnostics": 0,
"StdoutSHA256": "251E0C7CAF9243AFBCDCCD371707B8BFFF63CCF47537DABE9C398B4F3BBDC165"
},
{
"Arguments": [
"rename-alias",
"<fixture>\\aliases\\project.arcadia",
"alarm_response",
"alarm_suite"
],
"Exit": 0,
"Status": "preview",
"Changes": 1,
"Diagnostics": 0,
"StdoutSHA256": "E577D97B27E93CF4395EA67C01177FB7427EC28AE7D83629BD3CAB82849AE712"
},
{
"Arguments": [
"rename-alias",
"<fixture>\\aliases\\project.arcadia",
"alarm_response",
"alarm_suite",
"--write"
],
"Exit": 0,
"Status": "written",
"Changes": 1,
"Diagnostics": 0,
"StdoutSHA256": "1134EA13A5674D0AF0237BFB08C720FF046C0D82C8AE916AA6F97C40A009471F"
},
{
"Arguments": [
"rename-alias",
"<fixture>\\aliases\\project.arcadia",
"maintenance",
"maintenance_staff"
],
"Exit": 0,
"Status": "preview",
"Changes": 1,
"Diagnostics": 0,
"StdoutSHA256": "05CFEFA2CDD8612628906E81BA994446FC2D408642CAD8C8EAE1B0B0BDBFE5D5"
},
{
"Arguments": [
"rename-alias",
"<fixture>\\aliases\\project.arcadia",
"maintenance",
"maintenance_staff",
"--write"
],
"Exit": 0,
"Status": "written",
"Changes": 1,
"Diagnostics": 0,
"StdoutSHA256": "54B496AFCC671910E5109FFF3B65CFE0DC1BEA8D85871BDBC976177F28962AEF"
},
{
"Arguments": [
"rename-alias",
"<fixture>\\aliases\\project.arcadia",
"alarm_message",
"alarm_payload"
],
"Exit": 0,
"Status": "preview",
"Changes": 1,
"Diagnostics": 0,
"StdoutSHA256": "61309AADFF80386FA73FA9E7005C4C45548C56BC015BAF11750DCB00CD379E92"
},
{
"Arguments": [
"rename-alias",
"<fixture>\\aliases\\project.arcadia",
"alarm_message",
"alarm_payload",
"--write"
],
"Exit": 0,
"Status": "written",
"Changes": 1,
"Diagnostics": 0,
"StdoutSHA256": "EB0317BF9C7A6C54644748D7F8BFD04E082469AE98EAAA1F39DCC2AED9EDFDE7"
},
{
"Arguments": [
"rename-alias",
"<fixture>\\aliases\\project.arcadia",
"response_view",
"response_map"
],
"Exit": 0,
"Status": "preview",
"Changes": 1,
"Diagnostics": 0,
"StdoutSHA256": "3D2325D62D6F7D7FB7D7B7E162800DBBB15A4328BC1C5C0BF98EFD794E4AA472"
},
{
"Arguments": [
"rename-alias",
"<fixture>\\aliases\\project.arcadia",
"response_view",
"response_map",
"--write"
],
"Exit": 0,
"Status": "written",
"Changes": 1,
"Diagnostics": 0,
"StdoutSHA256": "E77B284EAFFBB090B73035FD584CE1D184C601112BCC0D5266D42F1CD7D2D185"
},
{
"Arguments": [
"rename-alias",
"<fixture>\\aliases\\project.arcadia",
"detector_card",
"detector_tile"
],
"Exit": 0,
"Status": "preview",
"Changes": 1,
"Diagnostics": 0,
"StdoutSHA256": "8DBA5013A3404CB5719573CDE66C92768C764B363C937646B79D848EA356D275"
},
{
"Arguments": [
"rename-alias",
"<fixture>\\aliases\\project.arcadia",
"detector_card",
"detector_tile",
"--write"
],
"Exit": 0,
"Status": "written",
"Changes": 1,
"Diagnostics": 0,
"StdoutSHA256": "EB444F39F873C58A8192C0A5AFC2C48FCAF1CAB333231C66471F71D1C1D2486A"
},
{
"Arguments": [
"rename-alias",
"<fixture>\\aliases\\project.arcadia",
"response_procedure",
"response_handbook"
],
"Exit": 0,
"Status": "preview",
"Changes": 1,
"Diagnostics": 0,
"StdoutSHA256": "6613EDCABEF4D8AC81E9FC21000FDE7AF10726E882BAF106ECA7991E553C4F53"
},
{
"Arguments": [
"rename-alias",
"<fixture>\\aliases\\project.arcadia",
"response_procedure",
"response_handbook",
"--write"
],
"Exit": 0,
"Status": "written",
"Changes": 1,
"Diagnostics": 0,
"StdoutSHA256": "0B740F86D607AD194EBD93D63DA65210A39DD35B1B3757CE679EC1A84FB8D3B9"
},
{
"Arguments": [
"rename-alias",
"<fixture>\\aliases\\project.arcadia",
"assessment_refinement",
"assessment_alignment"
],
"Exit": 0,
"Status": "preview",
"Changes": 1,
"Diagnostics": 0,
"StdoutSHA256": "101A1D9E89F482E6607B8A4855A673F56897818969333F6ED0D5F5749BFA739D"
},
{
"Arguments": [
"rename-alias",
"<fixture>\\aliases\\project.arcadia",
"assessment_refinement",
"assessment_alignment",
"--write"
],
"Exit": 0,
"Status": "written",
"Changes": 1,
"Diagnostics": 0,
"StdoutSHA256": "DA48C339A3C387BE06F6C3DCD799B3F98E75F6F97F760195EFFB9AB1C86F6EE7"
},
{
"Arguments": [
"check",
"<fixture>\\aliases\\project.arcadia"
],
"Exit": 0,
"Status": "checked",
"Changes": 0,
"Diagnostics": 0,
"StdoutSHA256": "251E0C7CAF9243AFBCDCCD371707B8BFFF63CCF47537DABE9C398B4F3BBDC165"
},
{
"Arguments": [
"stabilize",
"<fixture>\\aliases\\project.arcadia",
"--write"
],
"Exit": 0,
"Status": "unchanged",
"Changes": 0,
"Diagnostics": 0,
"StdoutSHA256": "FD9DF6ECDEF4F60AFDB07C8B37848E65ABE2E995A8A9F21506A322BE173753BE"
},
{
"Arguments": [
"check",
"<fixture>\\raw\\project.arcadia"
],
"Exit": 0,
"Status": "checked",
"Changes": 0,
"Diagnostics": 5,
"StdoutSHA256": "76363050F8B22A12D5A587156C7C6846ABD9CB087378735068CE0AFC5FAA798D"
},
{
"Arguments": [
"stabilize",
"<fixture>\\raw\\project.arcadia"
],
"Exit": 0,
"Status": "preview",
"Changes": 1,
"Diagnostics": 5,
"StdoutSHA256": "4B832B7D683AEED0ABCCE29262561CF3C77DF0CB1E965990C28B860ED0002F7A"
},
{
"Arguments": [
"lint",
"<fixture>\\raw\\project.arcadia"
],
"Exit": 0,
"Status": "checked",
"Changes": 0,
"Diagnostics": 5,
"StdoutSHA256": "00DDDFC5A535317F6D4B5F8FFF46FACEDAF49E89D9D1ED319C4EC3D24B018BEC"
},
{
"Arguments": [
"stabilize",
"<fixture>\\raw\\project.arcadia",
"--write"
],
"Exit": 1,
"Status": "invalid",
"Changes": 0,
"Diagnostics": 1,
"StdoutSHA256": "0813BD7BEF5B4B20D500A3B547C07F52C10C3E074EC6B24B57021F42FC1AE5D1"
}
],
"Limits": "Independent CLI process/source-byte checks only; no production compile, full Project comparison, concurrency proof, Linux or native GUI claim."
}