File indexing completed on 2026-11-09 10:47:24
0001
0002 """propose-campaign-configs.py — the campaign configuration proposer:
0003 for every campaign edition with tasks and no Standard Production
0004 configuration, propose the ping and its remedy through the AI proposal
0005 subsystem (swf-monitor docs/PINGS.md § Pings with a remedy,
0006 docs/AI_PROPOSALS.md category standard_config). Logic in
0007 ``pcs.config_proposer``; the prod-ops agent's doer for the
0008 ``campaign_config_propose`` chain step, also runnable by hand.
0009
0010 Usage::
0011
0012 cd /data/wenauseic/github/swf-monitor/src
0013 source ../../swf-testbed/.venv/bin/activate && source ~/.env
0014 python ../scripts/propose-campaign-configs.py [--apply] [--created-by X]
0015
0016 Dry run by default: the findings are printed and nothing is proposed.
0017 """
0018 import argparse
0019 import json
0020 import os
0021 import sys
0022
0023 THIS_DIR = os.path.dirname(os.path.abspath(__file__))
0024 sys.path.insert(0, os.path.join(THIS_DIR, '..', 'src'))
0025 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'swf_monitor_project.settings')
0026
0027 import django
0028 django.setup()
0029
0030 from pcs.config_proposer import propose_campaign_configs
0031
0032
0033 def main():
0034 parser = argparse.ArgumentParser()
0035 parser.add_argument('--apply', action='store_true',
0036 help='submit the proposals (default: report only)')
0037 parser.add_argument('--created-by', default='prodops_agent')
0038 args = parser.parse_args()
0039 result = propose_campaign_configs(created_by=args.created_by,
0040 apply=args.apply)
0041 for f in result['findings']:
0042 print(f"finding: {f['edition']} ({f['campaign']}, {f['lifecycle']}), "
0043 f"{f['tasks']} tasks, no Standard Production configuration")
0044 if not result['findings']:
0045 print('no edition lacks its Standard Production configuration')
0046 summary = {
0047 'findings': len(result['findings']),
0048 'editions': [f['edition'] for f in result['findings']],
0049 'applied': bool(args.apply),
0050 'pings': result['pings'], 'remedies': result['remedies'],
0051 'withdrawn': result['withdrawn'],
0052 'fulfilled': result['fulfilled'], 'errors': result['errors'],
0053 }
0054 print('SUMMARY ' + json.dumps(summary))
0055 return 0
0056
0057
0058 if __name__ == '__main__':
0059 sys.exit(main())