Add DB-driven pulse/company/project review chain with management projects

This commit is contained in:
David Baity
2026-04-28 11:23:53 -04:00
parent d9e17b5120
commit 3ecf27a8a6

View File

@@ -1,5 +1,5 @@
name: pulse_check name: pulse_check
description: "Crimson Leaf holding company health scan -- Edgar checks all subsidiaries every 3 hours." description: "Crimson Leaf holding company health scan -- Edgar checks all DB companies every 3 hours."
debug: true debug: true
model: power model: power
system: agent_prompt system: agent_prompt
@@ -20,95 +20,59 @@ builders:
{steps[0].text} {steps[0].text}
steps: steps:
# Step 0: pull live data for ALL companies currently in the database
- type: tool - type: tool
action: get_portfolio_report action: get_portfolio_report
output_key: portfolio_data output_key: portfolio_data
# Step 1: identify subsidiary company slugs (exclude crimson_leaf -- that is us)
- type: think - type: think
max_tokens: 4000 max_tokens: 600
hint: | hint: |
You are Edgar, CEO of Crimson Leaf Holdings. You just received the portfolio report above. You are Edgar, CEO of Crimson Leaf Holdings.
Analyze it as a systems operator would: The portfolio report above lists every company registered in the system database.
1. Which companies are active? Which are idle (no recent activity)? Extract the slug of every company EXCEPT "crimson_leaf" (that is the holding company -- us).
2. Are any tasks stuck (in_progress but old)? Any unusually high failure rates?
3. Are adjudication pass rates healthy (>65%) or concerning?
4. Is the system healthy (workers online, queue depth reasonable)?
Be concise and data-driven. Flag only what needs human attention. Output ONLY a JSON array of slug strings on a single line. No explanation. No markdown.
For each issue, format as: "David, [action needed]: [details]" Example: ["crimson_leaf_publishing","crimson_leaf_marketing","crimson_leaf_research"]
If everything looks healthy, say so briefly -- don't invent problems. If there are no subsidiary companies, output: []
Also assess Crimson Leaf Publishing production status: # Step 2: package the array so foreach can source it
- The portfolio report includes a project_breakdown array for each company. - type: package
- Each project entry has: name, slug, company_slug, tasks_in_progress, tasks_completed, schema: '{"company_slugs": "array"}'
last_activity_utc, hours_since_activity, and is_idle (true/false).
- is_idle is true when tasks_in_progress=0 AND hours_since_activity > 4.
- Identify which project has is_idle=true and the highest hours_since_activity.
- That is the project most overdue for a chapter dispatch.
- type: think
max_tokens: 200
output_key: dispatch_target
hint: | hint: |
Read the portfolio report data above. The previous step produced a JSON array of company slugs.
Package it as: {"company_slugs": [...array of slug strings...]}
Find the single project with is_idle=true and the highest hours_since_activity. # Step 3: dispatch a company_review task to the management project of each subsidiary
If no projects are idle, output exactly: none - type: foreach
source: company_slugs
If a project is found, output two lines -- nothing else: step:
COMPANY: <company_slug from the portfolio data> type: tool
PROJECT: <project slug from the portfolio data>
Rules: use the exact slug values from the data. No explanation. No punctuation.
If ALL projects have is_idle=false (tasks currently in progress), output: none
- type: think
max_tokens: 50
output_key: dispatch_company_slug
hint: |
Read dispatch_target above.
If dispatch_target is "none", output exactly: none
Otherwise, output ONLY the value after "COMPANY:" -- one word, no spaces, no newline.
- type: think
max_tokens: 50
output_key: dispatch_project_slug
hint: |
Read dispatch_target above.
If dispatch_target is "none", output exactly: none
Otherwise, output ONLY the value after "PROJECT:" -- one word, no spaces, no newline.
- type: tool
action: enqueue_strategy action: enqueue_strategy
optional: true optional: true
params: params:
company_slug: "{dispatch_company_slug}" company_slug: "{loop.item}"
project_slug: "{dispatch_project_slug}" project_slug: "management"
task_type: "chapter_production" task_type: "company_review"
content: "Pulse-check trigger: resume chapter production for this project." content: "Pulse-check: Edgar requesting company review for all active projects."
# Step 4: brief health summary to Discord
- type: think - type: think
max_tokens: 200 max_tokens: 150
output_key: status_summary
hint: | hint: |
Write a brief 2-line status update for the Discord #general channel. Write a 2-line status update for the Discord #general channel.
This should be punchy and informative -- David reads this to know if anything needs attention. Line 1: "Pulse [HEALTHY/ATTENTION/IDLE] -- <N> subsidiaries reviewed"
Line 2: one sentence noting anything flagged (failures, idle companies, workers down) or "All systems nominal."
Format: Use data from the portfolio report. 2 lines max. No extra commentary.
Line 1: "Pulse check -- [time context] -- [one word health: HEALTHY / ATTENTION / IDLE]"
Line 2: "[What action was taken or what was observed. Dispatch fired? All idle? Issue flagged?]"
Use project and company names from the portfolio data -- do not invent names.
Keep it to 2 lines maximum. No extra commentary.
- type: reply - type: reply
target: channel target: channel
channel_name: "crimson_leaf:general" channel_name: "crimson_leaf:general"
hint: | hint: |
Post the status_summary above to the channel. Output it exactly as written. Post the 2-line status summary above verbatim. No preamble.
Do not add any explanation, preamble, or additional context.
adjudication: adjudication:
enabled: false enabled: false