Let Void present authored artifacts
This commit is contained in:
parent
ad6c3df62e
commit
b53289d14f
11 changed files with 185 additions and 12 deletions
|
|
@ -273,6 +273,31 @@ function Project-InterventionsForRumination {
|
|||
)
|
||||
}
|
||||
|
||||
function Project-PublicSpeechTargetForRumination {
|
||||
param(
|
||||
[string] $ChannelId,
|
||||
[string] $PersonaName,
|
||||
[string] $PersonaAvatarUrl
|
||||
)
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($ChannelId)) {
|
||||
return $null
|
||||
}
|
||||
|
||||
$target = @{
|
||||
mode = "channel"
|
||||
channelId = $ChannelId.Trim()
|
||||
personaName = if ([string]::IsNullOrWhiteSpace($PersonaName)) { "Void" } else { $PersonaName.Trim() }
|
||||
reason = "Configured public room for Void to present self-authored public artifacts and other ripe public thoughts."
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PersonaAvatarUrl)) {
|
||||
$target.personaAvatarUrl = $PersonaAvatarUrl.Trim()
|
||||
}
|
||||
|
||||
return $target
|
||||
}
|
||||
|
||||
function Project-AgencyPressureForRumination {
|
||||
param($Pressures, [DateTime] $Now)
|
||||
|
||||
|
|
@ -346,6 +371,30 @@ function Project-CursorForRumination {
|
|||
}
|
||||
}
|
||||
|
||||
function Get-VoidAuthoredArtifactsFromContentHints {
|
||||
param($ContentHints)
|
||||
|
||||
return @(
|
||||
@(Convert-ToValueArray -Value $ContentHints) |
|
||||
Where-Object {
|
||||
$frontmatter = Get-ObjectPropertyValue -Value $_ -Name "frontmatter"
|
||||
$author = Get-ObjectPropertyValue -Value $frontmatter -Name "author"
|
||||
@(Convert-ToValueArray -Value $author) |
|
||||
Where-Object { ([string]$_).Trim().ToLowerInvariant() -eq "void" } |
|
||||
Select-Object -First 1
|
||||
} |
|
||||
ForEach-Object {
|
||||
$frontmatter = Get-ObjectPropertyValue -Value $_ -Name "frontmatter"
|
||||
@{
|
||||
path = Get-ObjectPropertyString -Value $_ -Name "path"
|
||||
title = Get-ObjectPropertyString -Value $frontmatter -Name "title"
|
||||
description = Get-ObjectPropertyString -Value $frontmatter -Name "description"
|
||||
socialDeck = Get-ObjectPropertyString -Value $frontmatter -Name "socialDeck"
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function Project-RepoCommitForRumination {
|
||||
param($Commit, [DateTime] $Now)
|
||||
|
||||
|
|
@ -354,6 +403,8 @@ function Project-RepoCommitForRumination {
|
|||
}
|
||||
|
||||
$hash = Get-ObjectPropertyString -Value $Commit -Name "hash"
|
||||
$contentHints = @(Convert-ToValueArray -Value (Get-ObjectPropertyValue -Value $Commit -Name "contentHints"))
|
||||
$authoredPublicArtifacts = @(Get-VoidAuthoredArtifactsFromContentHints -ContentHints $contentHints)
|
||||
return @{
|
||||
hash = if ($hash -and $hash.Length -gt 12) { $hash.Substring(0, 12) } else { $hash }
|
||||
committed = Project-RelativeTimestamp -Value $Commit -Name "committedAt" -Now $Now
|
||||
|
|
@ -361,10 +412,25 @@ function Project-RepoCommitForRumination {
|
|||
subject = Get-ObjectPropertyString -Value $Commit -Name "subject"
|
||||
diffstat = Get-ObjectPropertyValue -Value $Commit -Name "diffstat"
|
||||
changedPaths = @(Convert-ToValueArray -Value (Get-ObjectPropertyValue -Value $Commit -Name "changedPaths"))
|
||||
contentHints = @(Convert-ToValueArray -Value (Get-ObjectPropertyValue -Value $Commit -Name "contentHints"))
|
||||
contentHints = $contentHints
|
||||
authoredPublicArtifacts = $authoredPublicArtifacts
|
||||
}
|
||||
}
|
||||
|
||||
function Test-RepoHasVoidAuthoredArtifact {
|
||||
param($Repo)
|
||||
|
||||
$commits = @(Convert-ToValueArray -Value (Get-ObjectPropertyValue -Value $Repo -Name "commits"))
|
||||
foreach ($commit in $commits) {
|
||||
$contentHints = @(Convert-ToValueArray -Value (Get-ObjectPropertyValue -Value $commit -Name "contentHints"))
|
||||
if (@(Get-VoidAuthoredArtifactsFromContentHints -ContentHints $contentHints).Count -gt 0) {
|
||||
return $true
|
||||
}
|
||||
}
|
||||
|
||||
return $false
|
||||
}
|
||||
|
||||
function Select-RuminationRepoActivity {
|
||||
param($RepoActivity, [DateTime] $Now)
|
||||
|
||||
|
|
@ -388,6 +454,9 @@ function Select-RuminationRepoActivity {
|
|||
$repoStatus = Get-ObjectPropertyString -Value $_ -Name "status"
|
||||
$null -ne $recent -and $repoStatus -eq "ok" -and [int]$recent -gt 0
|
||||
} |
|
||||
Sort-Object -Property @{
|
||||
Expression = { if (Test-RepoHasVoidAuthoredArtifact -Repo $_) { 0 } else { 1 } }
|
||||
} |
|
||||
Select-Object -First 8
|
||||
)
|
||||
$projectedRepos = @(
|
||||
|
|
|
|||
|
|
@ -139,6 +139,25 @@ function Read-DotEnv {
|
|||
return $values
|
||||
}
|
||||
|
||||
function Get-ConfigValue {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string] $Name,
|
||||
[hashtable] $Values
|
||||
)
|
||||
|
||||
$environmentValue = [Environment]::GetEnvironmentVariable($Name)
|
||||
if (-not [string]::IsNullOrWhiteSpace($environmentValue)) {
|
||||
return $environmentValue
|
||||
}
|
||||
|
||||
if ($null -ne $Values -and $Values.ContainsKey($Name) -and -not [string]::IsNullOrWhiteSpace($Values[$Name])) {
|
||||
return $Values[$Name]
|
||||
}
|
||||
|
||||
return $null
|
||||
}
|
||||
|
||||
function Split-CommandArgs {
|
||||
param(
|
||||
[string] $Value
|
||||
|
|
@ -224,6 +243,44 @@ function Invoke-CodexExec {
|
|||
}
|
||||
}
|
||||
|
||||
function Get-RepoActivityCursorOperations {
|
||||
param(
|
||||
$RepoActivity,
|
||||
[DateTime] $ObservedAt
|
||||
)
|
||||
|
||||
if ($null -eq $RepoActivity) {
|
||||
return @()
|
||||
}
|
||||
|
||||
$repos = @(Convert-ToValueArray -Value (Get-ObjectPropertyValue -Value $RepoActivity -Name "repos"))
|
||||
return @(
|
||||
$repos |
|
||||
Where-Object {
|
||||
$repoStatus = Get-ObjectPropertyString -Value $_ -Name "status"
|
||||
$recentCount = Get-ObjectPropertyValue -Value $_ -Name "recentCommitCount"
|
||||
$latestCommit = Get-ObjectPropertyValue -Value $_ -Name "latestCommit"
|
||||
$repoStatus -eq "ok" -and
|
||||
$null -ne $recentCount -and
|
||||
[int]$recentCount -gt 0 -and
|
||||
$null -ne $latestCommit -and
|
||||
-not [string]::IsNullOrWhiteSpace((Get-ObjectPropertyString -Value $latestCommit -Name "hash"))
|
||||
} |
|
||||
ForEach-Object {
|
||||
$latestCommit = Get-ObjectPropertyValue -Value $_ -Name "latestCommit"
|
||||
@{
|
||||
operation = "update_repo_activity_cursor"
|
||||
cursor = @{
|
||||
repo = Get-ObjectPropertyString -Value $_ -Name "repoName"
|
||||
lastCommitAt = Get-ObjectPropertyString -Value $latestCommit -Name "committedAt"
|
||||
lastCommitSha = Get-ObjectPropertyString -Value $latestCommit -Name "hash"
|
||||
updatedAt = $ObservedAt.ToString("o")
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function Invoke-NodeJson {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
|
|
@ -718,6 +775,9 @@ $codexExecArgs = if (-not [string]::IsNullOrWhiteSpace($env:CODEX_EXEC_ARGS)) {
|
|||
} else {
|
||||
@()
|
||||
}
|
||||
$publicRoomChannelId = Get-ConfigValue -Name "VOID_PUBLIC_ROOM_CHANNEL_ID" -Values $envValues
|
||||
$publicRoomPersonaName = Get-ConfigValue -Name "VOID_PUBLIC_ROOM_PERSONA_NAME" -Values $envValues
|
||||
$publicRoomPersonaAvatarUrl = Get-ConfigValue -Name "VOID_PUBLIC_ROOM_PERSONA_AVATAR_URL" -Values $envValues
|
||||
|
||||
$typedContext = Get-TypedSelfState
|
||||
$typedState = $typedContext.typedState
|
||||
|
|
@ -778,6 +838,7 @@ Write-JsonFile -Path $contextPath -Data @{
|
|||
incubation = @(Project-IncubationForRumination -Threads $typedState.thoughtMemory.incubation -Now $startedAtUtc)
|
||||
agencyPressure = @(Project-AgencyPressureForRumination -Pressures $typedState.agencyPressure.pressures -Now $startedAtUtc)
|
||||
speechPressureObligations = $speechPressureObligations
|
||||
publicSpeechTarget = Project-PublicSpeechTargetForRumination -ChannelId $publicRoomChannelId -PersonaName $publicRoomPersonaName -PersonaAvatarUrl $publicRoomPersonaAvatarUrl
|
||||
deliverableCandidateCount = [int]$deliverableCandidates.Count
|
||||
candidateInterventions = @(Project-InterventionsForRumination -Interventions $typedState.candidateInterventions.interventions -Now $startedAtUtc)
|
||||
scheduledRuntime = Project-ScheduledRuntimeForRumination -Runtime $typedState.scheduledRuntime -Now $startedAtUtc
|
||||
|
|
@ -907,6 +968,18 @@ if (
|
|||
}
|
||||
}
|
||||
|
||||
$repoCursorOperations = @()
|
||||
$disableRepoCursorAdvance = -not [string]::IsNullOrWhiteSpace($env:VOID_RUMINATION_DISABLE_REPO_CURSOR_ADVANCE)
|
||||
if (-not $NoPost -and -not $SkipModel -and -not $disableRepoCursorAdvance) {
|
||||
$repoCursorOperations = @(Get-RepoActivityCursorOperations -RepoActivity $repoActivity -ObservedAt ([DateTime]::UtcNow))
|
||||
if ($repoCursorOperations.Count -gt 0) {
|
||||
Append-RunLog ("recording repo activity cursors: {0}" -f $repoCursorOperations.Count)
|
||||
foreach ($operation in $repoCursorOperations) {
|
||||
$appliedOperations += Apply-TypedOperation -Operation $operation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$deliveredCandidateCount = 0
|
||||
if (-not $NoPost) {
|
||||
$refreshedTypedContext = Get-TypedSelfState
|
||||
|
|
@ -955,6 +1028,7 @@ $finalStatus = [ordered]@{
|
|||
observedCursorTimestamp = [string]$observedCursorTimestamp
|
||||
proposedOperationCount = [int]@($proposedOperations).Count
|
||||
appliedOperationCount = [int]@($appliedOperations).Count
|
||||
repoCursorOperationCount = [int]@($repoCursorOperations).Count
|
||||
deliveredCandidateCount = [int]$deliveredCandidateCount
|
||||
stateUpdated = [bool](@($appliedOperations).Count -gt 0)
|
||||
tracePath = [string]$tracePath
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ process.stdin.on("end", () => {
|
|||
console.error("fixture prompt did not contain the self-orbit guard");
|
||||
process.exit(3);
|
||||
}
|
||||
if (!prompt.includes("publicSpeechTarget")) {
|
||||
console.error("fixture prompt did not contain the public speech target contract");
|
||||
process.exit(3);
|
||||
}
|
||||
if (prompt.includes("moderation-agent-state.json") && !prompt.includes("Do not read or write")) {
|
||||
console.error("fixture prompt referenced legacy state outside the boundary warning");
|
||||
process.exit(4);
|
||||
|
|
@ -181,6 +185,8 @@ process.stdin.on("end", () => {
|
|||
$previousFixtureOutput = $env:VOID_RUMINATION_FIXTURE_OPERATION_OUTPUT
|
||||
$previousStatusDir = $env:VOID_RUMINATION_STATUS_DIR
|
||||
$previousLogDir = $env:VOID_RUMINATION_LOG_DIR
|
||||
$previousPublicRoomChannelId = $env:VOID_PUBLIC_ROOM_CHANNEL_ID
|
||||
$previousPublicRoomPersonaName = $env:VOID_PUBLIC_ROOM_PERSONA_NAME
|
||||
|
||||
try {
|
||||
$env:CODEX_EXECUTABLE = "node"
|
||||
|
|
@ -188,6 +194,8 @@ process.stdin.on("end", () => {
|
|||
$env:VOID_RUMINATION_FIXTURE_OPERATION_OUTPUT = $statusOperationPath
|
||||
$env:VOID_RUMINATION_STATUS_DIR = $fixtureStatusDir
|
||||
$env:VOID_RUMINATION_LOG_DIR = $fixtureLogDir
|
||||
$env:VOID_PUBLIC_ROOM_CHANNEL_ID = "fixture-public-room"
|
||||
$env:VOID_PUBLIC_ROOM_PERSONA_NAME = "Void"
|
||||
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\run-void-moderator-rumination.ps1 -StateFilePath $stateFilePath -NoPost | Out-Null
|
||||
} finally {
|
||||
|
|
@ -196,6 +204,8 @@ process.stdin.on("end", () => {
|
|||
$env:VOID_RUMINATION_FIXTURE_OPERATION_OUTPUT = $previousFixtureOutput
|
||||
$env:VOID_RUMINATION_STATUS_DIR = $previousStatusDir
|
||||
$env:VOID_RUMINATION_LOG_DIR = $previousLogDir
|
||||
$env:VOID_PUBLIC_ROOM_CHANNEL_ID = $previousPublicRoomChannelId
|
||||
$env:VOID_PUBLIC_ROOM_PERSONA_NAME = $previousPublicRoomPersonaName
|
||||
}
|
||||
|
||||
$status = Get-Content -LiteralPath $statusPath -Raw -Encoding UTF8 | ConvertFrom-Json
|
||||
|
|
@ -210,6 +220,10 @@ process.stdin.on("end", () => {
|
|||
if ($contextRaw -match '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}') {
|
||||
throw "Rumination fixture context leaked exact ISO timestamps into the prompt-facing packet."
|
||||
}
|
||||
$context = $contextRaw | ConvertFrom-Json
|
||||
if ($context.publicSpeechTarget.channelId -ne "fixture-public-room") {
|
||||
throw "Rumination fixture context did not project the configured public speech target."
|
||||
}
|
||||
|
||||
$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
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ process.stdout.write(JSON.stringify({ ok: true, mode: "channel", channelId }) +
|
|||
$previousStatusDir = $env:VOID_RUMINATION_STATUS_DIR
|
||||
$previousLogDir = $env:VOID_RUMINATION_LOG_DIR
|
||||
$previousSendScript = $env:VOID_SEND_DISCORD_SCRIPT
|
||||
$previousDisableRepoCursorAdvance = $env:VOID_RUMINATION_DISABLE_REPO_CURSOR_ADVANCE
|
||||
|
||||
try {
|
||||
$env:CODEX_EXECUTABLE = "node"
|
||||
|
|
@ -165,6 +166,7 @@ process.stdout.write(JSON.stringify({ ok: true, mode: "channel", channelId }) +
|
|||
$env:VOID_RUMINATION_STATUS_DIR = $fixtureStatusDir
|
||||
$env:VOID_RUMINATION_LOG_DIR = $fixtureLogDir
|
||||
$env:VOID_SEND_DISCORD_SCRIPT = $fakeSendPath
|
||||
$env:VOID_RUMINATION_DISABLE_REPO_CURSOR_ADVANCE = "1"
|
||||
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\run-void-moderator-rumination.ps1 -StateFilePath $stateFilePath | Out-Null
|
||||
} finally {
|
||||
|
|
@ -174,6 +176,7 @@ process.stdout.write(JSON.stringify({ ok: true, mode: "channel", channelId }) +
|
|||
$env:VOID_RUMINATION_STATUS_DIR = $previousStatusDir
|
||||
$env:VOID_RUMINATION_LOG_DIR = $previousLogDir
|
||||
$env:VOID_SEND_DISCORD_SCRIPT = $previousSendScript
|
||||
$env:VOID_RUMINATION_DISABLE_REPO_CURSOR_ADVANCE = $previousDisableRepoCursorAdvance
|
||||
}
|
||||
|
||||
$status = Get-Content -LiteralPath $statusPath -Raw -Encoding UTF8 | ConvertFrom-Json
|
||||
|
|
|
|||
Loading…
Reference in a new issue