| 7718 | } |
| 7719 | |
| 7720 | static void install_tiered_agent_profiles(cbm_tiered_profile_set_t profiles, bool dry_run) { |
| 7721 | cbm_graph_access_t access = cbm_tiered_profile_set_access(profiles); |
| 7722 | for (int value = 0; value < (int)CBM_GRAPH_TIER_COUNT; value++) { |
| 7723 | cbm_graph_tier_t tier = (cbm_graph_tier_t)value; |
| 7724 | char path[CLI_BUF_1K]; |
| 7725 | if (cbm_tiered_profile_path(profiles.verify_path, tier, path, sizeof(path)) != CLI_OK) { |
| 7726 | record_agent_config_error(false, profiles.label, "agent_path", profiles.verify_path); |
| 7727 | continue; |
| 7728 | } |
| 7729 | if (g_install_plan) { |
| 7730 | plan_record(profiles.label, "agent", path); |
| 7731 | continue; |
| 7732 | } |
| 7733 | if (dry_run) { |
| 7734 | printf(" agent: %s\n", path); |
| 7735 | continue; |
| 7736 | } |
| 7737 | char *current = |
| 7738 | cbm_render_graph_profile(profiles.dialect, tier, access, profiles.binary_path); |
| 7739 | if (!current) { |
| 7740 | record_agent_config_error(false, profiles.label, "agent_render", path); |
| 7741 | continue; |
| 7742 | } |
| 7743 | cbm_graph_access_t alternate_access = |
| 7744 | access == CBM_GRAPH_ACCESS_DIRECT ? CBM_GRAPH_ACCESS_HANDOFF : CBM_GRAPH_ACCESS_DIRECT; |
| 7745 | char *alternate = cbm_render_graph_profile(profiles.dialect, tier, alternate_access, |
| 7746 | profiles.binary_path); |
| 7747 | char *codex_rc1 = |
| 7748 | profiles.dialect == CBM_GRAPH_DIALECT_CODEX && access == CBM_GRAPH_ACCESS_DIRECT |
| 7749 | ? cbm_render_graph_profile_codex_rc1(tier) |
| 7750 | : NULL; |
| 7751 | const char *released[3]; |
| 7752 | size_t released_count = 0U; |
| 7753 | if (alternate) { |
| 7754 | released[released_count++] = alternate; |
| 7755 | } |
| 7756 | if (codex_rc1) { |
| 7757 | released[released_count++] = codex_rc1; |
| 7758 | } |
| 7759 | if (tier == CBM_GRAPH_TIER_VERIFY && profiles.legacy_verify_content) { |
| 7760 | released[released_count++] = profiles.legacy_verify_content; |
| 7761 | } |
| 7762 | int result = prepare_config_parent(path) |
| 7763 | ? cbm_text_migrate_owned_document(path, current, released, released_count) |
| 7764 | : CLI_ERR; |
| 7765 | free(codex_rc1); |
| 7766 | free(alternate); |
| 7767 | free(current); |
| 7768 | if (result != CLI_OK) { |
| 7769 | if (result > CLI_OK) { |
| 7770 | printf(" agent: preserved modified profile %s\n", path); |
| 7771 | } |
| 7772 | record_agent_config_error(false, profiles.label, "agent_install", path); |
| 7773 | continue; |
| 7774 | } |
| 7775 | printf(" agent: %s\n", path); |
| 7776 | } |
| 7777 | } |
no test coverage detected