1.6 KiB
1.6 KiB
Contract Queue Serial Execution
Problem
Multiple contracts arrive at once but workflow only processes one at a time (shared /tmp/contract-review/). When auto_notify script is down, no automatic serial scheduling exists.
Solution: run_contract_queue.sh
Location: ~/.hermes/scripts/run_contract_queue.sh
Usage:
bash ~/.hermes/scripts/run_contract_queue.sh \
"合同1.docx" "合同2.docx" "合同3.docx"
Behavior:
- Cleans /tmp/contract-review/ between each contract (preserves rules/)
- Creates uwf thread + executes synchronously (not --background)
- If suspended: auto-retries once, then skips to next
- Logs to /tmp/contract_queue.log
- Reports final tally (success/fail counts)
When to use
- auto_notify script is down and multiple contracts need processing
- Manual batch processing after catching up on a backlog
- Pair with a wrapper that polls current running thread before starting queue
Wrapper pattern for waiting on current thread
# Poll until current thread finishes, then run queue
while true; do
STATUS=$(uwf thread show <THREAD_ID> --format json 2>&1 | \
python3 -c "import sys,json; print(json.load(sys.stdin).get('value',{}).get('status','unknown'))")
[ "$STATUS" != "running" ] && break
sleep 30
done
exec bash ~/.hermes/scripts/run_contract_queue.sh "file1.docx" "file2.docx"
2026-06-15 context
5 contracts arrived, auto_notify was dead since June 12. Gold蛋糕 contract ran manually, then queue script was written to handle remaining 3 (赵巷消防→练塘健康积分→徐泾维保) after 端午节 contract finished.