| 7656 | } |
| 7657 | |
| 7658 | static void install_tiered_agent_profiles(cbm_tiered_profile_set_t profiles, bool dry_run) { |
| 7659 | cbm_graph_access_t access = cbm_tiered_profile_set_access(profiles); |
| 7660 | for (int value = 0; value < (int)CBM_GRAPH_TIER_COUNT; value++) { |
| 7661 | cbm_graph_tier_t tier = (cbm_graph_tier_t)value; |
| 7662 | char path[CLI_BUF_1K]; |
| 7663 | if (cbm_tiered_profile_path(profiles.verify_path, tier, path, sizeof(path)) != CLI_OK) { |
| 7664 | record_agent_config_error(false, profiles.label, "agent_path", profiles.verify_path); |
| 7665 | continue; |
| 7666 | } |
| 7667 | if (g_install_plan) { |
| 7668 | plan_record(profiles.label, "agent", path); |
| 7669 | continue; |
| 7670 | } |
| 7671 | if (dry_run) { |
| 7672 | printf(" agent: %s\n", path); |
| 7673 | continue; |
| 7674 | } |
| 7675 | char *current = |
| 7676 | cbm_render_graph_profile(profiles.dialect, tier, access, profiles.binary_path); |
| 7677 | if (!current) { |
| 7678 | record_agent_config_error(false, profiles.label, "agent_render", path); |
| 7679 | continue; |
| 7680 | } |
| 7681 | cbm_graph_access_t alternate_access = |
| 7682 | access == CBM_GRAPH_ACCESS_DIRECT ? CBM_GRAPH_ACCESS_HANDOFF : CBM_GRAPH_ACCESS_DIRECT; |
| 7683 | char *alternate = cbm_render_graph_profile(profiles.dialect, tier, alternate_access, |
| 7684 | profiles.binary_path); |
| 7685 | char *codex_rc1 = |
| 7686 | profiles.dialect == CBM_GRAPH_DIALECT_CODEX && access == CBM_GRAPH_ACCESS_DIRECT |
| 7687 | ? cbm_render_graph_profile_codex_rc1(tier) |
| 7688 | : NULL; |
| 7689 | const char *released[3]; |
| 7690 | size_t released_count = 0U; |
| 7691 | if (alternate) { |
| 7692 | released[released_count++] = alternate; |
| 7693 | } |
| 7694 | if (codex_rc1) { |
| 7695 | released[released_count++] = codex_rc1; |
| 7696 | } |
| 7697 | if (tier == CBM_GRAPH_TIER_VERIFY && profiles.legacy_verify_content) { |
| 7698 | released[released_count++] = profiles.legacy_verify_content; |
| 7699 | } |
| 7700 | int result = prepare_config_parent(path) |
| 7701 | ? cbm_text_migrate_owned_document(path, current, released, released_count) |
| 7702 | : CLI_ERR; |
| 7703 | free(codex_rc1); |
| 7704 | free(alternate); |
| 7705 | free(current); |
| 7706 | if (result != CLI_OK) { |
| 7707 | if (result > CLI_OK) { |
| 7708 | printf(" agent: preserved modified profile %s\n", path); |
| 7709 | } |
| 7710 | record_agent_config_error(false, profiles.label, "agent_install", path); |
| 7711 | continue; |
| 7712 | } |
| 7713 | printf(" agent: %s\n", path); |
| 7714 | } |
| 7715 | } |
no test coverage detected