Prune terminal self-state audit residue
This commit is contained in:
parent
8b4ded235b
commit
ae9fedd3eb
6 changed files with 38 additions and 29 deletions
|
|
@ -395,7 +395,7 @@ function Test-CandidateMatchesPressure {
|
|||
[Parameter(Mandatory = $true)]
|
||||
[string] $PressureId,
|
||||
[string] $PressureTargetKey,
|
||||
[string[]] $AllowedStatuses = @("queued", "spoken")
|
||||
[string[]] $AllowedStatuses = @("queued", "deferred")
|
||||
)
|
||||
|
||||
$status = Get-ObjectPropertyString -Value $Candidate -Name "status"
|
||||
|
|
@ -511,7 +511,7 @@ function Get-SpeechPressureObligations {
|
|||
$pressureId = Get-ObjectPropertyString -Value $_ -Name "pressureId"
|
||||
$pressureTargetKey = Get-ThoughtTargetKey -Target (Get-ObjectPropertyValue -Value $_ -Name "target")
|
||||
-not ($candidateInterventions | Where-Object {
|
||||
Test-CandidateMatchesPressure -Candidate $_ -PressureId $pressureId -PressureTargetKey $pressureTargetKey -AllowedStatuses @("queued")
|
||||
Test-CandidateMatchesPressure -Candidate $_ -PressureId $pressureId -PressureTargetKey $pressureTargetKey -AllowedStatuses @("queued", "deferred")
|
||||
} | Select-Object -First 1)
|
||||
} |
|
||||
ForEach-Object {
|
||||
|
|
@ -845,17 +845,17 @@ function Assert-SpokenCandidateApplied {
|
|||
$candidate = @(
|
||||
@(Convert-ToValueArray -Value $state.candidateInterventions.interventions) |
|
||||
Where-Object { (Get-ObjectPropertyString -Value $_ -Name "interventionId") -eq $InterventionId }
|
||||
)[0]
|
||||
) | Select-Object -First 1
|
||||
$receipt = @(
|
||||
@(Convert-ToValueArray -Value $state.speechReceipts.recentReceipts) |
|
||||
Where-Object { (Get-ObjectPropertyString -Value $_ -Name "receiptKey") -eq $ReceiptKey }
|
||||
)[0]
|
||||
) | Select-Object -First 1
|
||||
|
||||
if ($null -eq $candidate -or (Get-ObjectPropertyString -Value $candidate -Name "status") -ne "spoken") {
|
||||
throw "Delivery receipt '$ReceiptKey' was recorded without retiring candidate '$InterventionId' as spoken."
|
||||
if ($null -ne $candidate) {
|
||||
throw "Delivery receipt '$ReceiptKey' was recorded but terminal candidate '$InterventionId' stayed in current state."
|
||||
}
|
||||
if ($null -eq $receipt -or (Get-ObjectPropertyString -Value $receipt -Name "candidateInterventionId") -ne $InterventionId) {
|
||||
throw "Candidate '$InterventionId' was marked spoken without a linked delivery receipt '$ReceiptKey'."
|
||||
throw "Candidate '$InterventionId' was delivered without a linked delivery receipt '$ReceiptKey'."
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,8 +139,8 @@ try {
|
|||
if ($activeMemories.Count -ne 1 -or $identityMemory.memoryId -ne "identity-memory-plasticity") {
|
||||
throw "Memory lifecycle fixture expected one active crystallized identity memory."
|
||||
}
|
||||
if ($retiredMemories.Count -lt 2) {
|
||||
throw "Memory lifecycle fixture expected superseded durable memories to be retired."
|
||||
if ($retiredMemories.Count -ne 0) {
|
||||
throw "Memory lifecycle fixture left superseded durable memories in current state."
|
||||
}
|
||||
if ($null -eq $value) {
|
||||
throw "Memory lifecycle fixture did not crystallize a self-profile value."
|
||||
|
|
@ -149,7 +149,7 @@ try {
|
|||
@{
|
||||
status = "ok"
|
||||
activeMemoryCount = $activeMemories.Count
|
||||
retiredMemoryCount = $retiredMemories.Count
|
||||
retainedRetiredMemoryCount = $retiredMemories.Count
|
||||
value = $value.label
|
||||
} | ConvertTo-Json -Compress
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -242,7 +242,8 @@ process.stdout.write(JSON.stringify({ ok: true, mode: "channel", channelId }) +
|
|||
|
||||
$status = Get-Content -LiteralPath $statusPath -Raw -Encoding UTF8 | ConvertFrom-Json
|
||||
if ($status.status -ne "ok") {
|
||||
throw "Speech fixture did not finish ok."
|
||||
$failureMessage = if ($null -ne $status.PSObject.Properties["failureMessage"]) { [string]$status.failureMessage } else { "(no failure message)" }
|
||||
throw "Speech fixture did not finish ok: $failureMessage"
|
||||
}
|
||||
if ([int]$status.proposedOperationCount -ne 3 -or [int]$status.appliedOperationCount -ne 5 -or [int]$status.deliveredCandidateCount -ne 1) {
|
||||
throw "Speech fixture expected three proposals, five applied operations, and one delivered candidate."
|
||||
|
|
@ -250,25 +251,25 @@ process.stdout.write(JSON.stringify({ ok: true, mode: "channel", channelId }) +
|
|||
|
||||
$stateJson = node -e "const core=require('./packages/core/dist/index.js'); core.loadVoidSelfStateTypedDocuments({canonicalPath: process.argv[1]}).then((state)=>console.log(JSON.stringify(state))).catch((error)=>{ console.error(error); process.exit(1); })" $stateFilePath
|
||||
$state = $stateJson | ConvertFrom-Json
|
||||
$candidate = @($state.candidateInterventions.interventions | Where-Object { $_.interventionId -eq "fixture-parent-owned-speech" })[0]
|
||||
$duplicateCandidate = @($state.candidateInterventions.interventions | Where-Object { $_.interventionId -eq "fixture-duplicate-same-reply-target" })[0]
|
||||
$alreadyAnsweredCandidate = @($state.candidateInterventions.interventions | Where-Object { $_.interventionId -eq "fixture-already-answered-reply-target" })[0]
|
||||
$candidate = @($state.candidateInterventions.interventions | Where-Object { $_.interventionId -eq "fixture-parent-owned-speech" }) | Select-Object -First 1
|
||||
$duplicateCandidate = @($state.candidateInterventions.interventions | Where-Object { $_.interventionId -eq "fixture-duplicate-same-reply-target" }) | Select-Object -First 1
|
||||
$alreadyAnsweredCandidate = @($state.candidateInterventions.interventions | Where-Object { $_.interventionId -eq "fixture-already-answered-reply-target" }) | Select-Object -First 1
|
||||
$receipt = @(
|
||||
$state.speechReceipts.recentReceipts |
|
||||
Where-Object {
|
||||
$property = $_.PSObject.Properties["candidateInterventionId"]
|
||||
$null -ne $property -and $property.Value -eq "fixture-parent-owned-speech"
|
||||
}
|
||||
)[0]
|
||||
) | Select-Object -First 1
|
||||
|
||||
if ($candidate.status -ne "spoken") {
|
||||
throw "Speech fixture did not mark the candidate spoken."
|
||||
if ($null -ne $candidate) {
|
||||
throw "Speech fixture left the delivered candidate in current state."
|
||||
}
|
||||
if ($duplicateCandidate.status -ne "retired") {
|
||||
throw "Speech fixture did not retire the duplicate same-target candidate."
|
||||
if ($null -ne $duplicateCandidate) {
|
||||
throw "Speech fixture left the duplicate same-target candidate in current state."
|
||||
}
|
||||
if ($alreadyAnsweredCandidate.status -ne "retired") {
|
||||
throw "Speech fixture did not retire the already-answered reply target candidate."
|
||||
if ($null -ne $alreadyAnsweredCandidate) {
|
||||
throw "Speech fixture left the already-answered reply target candidate in current state."
|
||||
}
|
||||
if ($receipt.channelId -ne "fixture-channel-id" -or $receipt.replyToMessageId -ne "fixture-message-id") {
|
||||
throw "Speech fixture did not preserve the delivery receipt target."
|
||||
|
|
@ -276,9 +277,9 @@ process.stdout.write(JSON.stringify({ ok: true, mode: "channel", channelId }) +
|
|||
if ($receipt.candidateInterventionId -ne "fixture-parent-owned-speech") {
|
||||
throw "Speech fixture did not link the delivery receipt back to the spoken candidate."
|
||||
}
|
||||
$answeredCase = @($state.moderationCursor.openCases | Where-Object { $_.sourceMessageId -eq "fixture-answered-message-id" })[0]
|
||||
if ($answeredCase.status -ne "answered" -or $answeredCase.summary -match "not answered") {
|
||||
throw "Speech fixture did not normalize the answered open-case summary."
|
||||
$answeredCase = @($state.moderationCursor.openCases | Where-Object { $_.sourceMessageId -eq "fixture-answered-message-id" }) | Select-Object -First 1
|
||||
if ($null -ne $answeredCase) {
|
||||
throw "Speech fixture left an answered open case in current state."
|
||||
}
|
||||
$lastMessage = Get-Content -LiteralPath (Join-Path $fixtureStatusDir "moderation-rumination-last-message.txt") -Raw -Encoding UTF8
|
||||
if ($lastMessage -notmatch "deliveredCandidates=1") {
|
||||
|
|
@ -287,8 +288,8 @@ process.stdout.write(JSON.stringify({ ok: true, mode: "channel", channelId }) +
|
|||
|
||||
@{
|
||||
status = "ok"
|
||||
candidateStatus = $candidate.status
|
||||
staleDuplicateStatus = $alreadyAnsweredCandidate.status
|
||||
candidateRetained = $null -ne $candidate
|
||||
staleDuplicateRetained = $null -ne $alreadyAnsweredCandidate
|
||||
receiptCount = @($state.speechReceipts.recentReceipts).Count
|
||||
deliveredCandidateCount = [int]$status.deliveredCandidateCount
|
||||
} | ConvertTo-Json -Compress
|
||||
|
|
|
|||
|
|
@ -269,8 +269,8 @@ try {
|
|||
$stateJson = Invoke-NodeChecked -Arguments @("-e", "const core=require('./packages/core/dist/index.js'); core.loadVoidSelfStateTypedDocuments({canonicalPath: process.argv[1]}).then((state)=>console.log(JSON.stringify(state))).catch((error)=>{ console.error(error); process.exit(1); })", $candidate.stateFilePath)
|
||||
$state = $stateJson | ConvertFrom-Json
|
||||
$queued = @($state.candidateInterventions.interventions | Where-Object { $_.interventionId -eq "fixture-pressure-candidate" })[0]
|
||||
if ($null -eq $queued -or $queued.status -ne "queued" -or -not @($queued.tags).Contains("source_pressure:fixture-pressure-wants-a-mouth")) {
|
||||
throw "Candidate speech-pressure fixture did not preserve the queued pressure candidate."
|
||||
if ($null -eq $queued -or $queued.status -ne "deferred" -or -not @($queued.tags).Contains("source_pressure:fixture-pressure-wants-a-mouth")) {
|
||||
throw "Candidate speech-pressure fixture did not preserve the live deferred pressure candidate."
|
||||
}
|
||||
|
||||
@{
|
||||
|
|
|
|||
Loading…
Reference in a new issue