| 7569 | } |
| 7570 | |
| 7571 | static void install_tiered_agent_profiles(cbm_tiered_profile_set_t profiles, bool dry_run) { |
| 7572 | cbm_graph_access_t access = cbm_tiered_profile_set_access(profiles); |
| 7573 | for (int value = 0; value < (int)CBM_GRAPH_TIER_COUNT; value++) { |
| 7574 | cbm_graph_tier_t tier = (cbm_graph_tier_t)value; |
| 7575 | char path[CLI_BUF_1K]; |
| 7576 | if (cbm_tiered_profile_path(profiles.verify_path, tier, path, sizeof(path)) != CLI_OK) { |
| 7577 | record_agent_config_error(false, profiles.label, "agent_path", profiles.verify_path); |
| 7578 | continue; |
| 7579 | } |
| 7580 | if (g_install_plan) { |
| 7581 | plan_record(profiles.label, "agent", path); |
| 7582 | continue; |
| 7583 | } |
| 7584 | if (dry_run) { |
| 7585 | printf(" agent: %s\n", path); |
| 7586 | continue; |
| 7587 | } |
| 7588 | char *current = |
| 7589 | cbm_render_graph_profile(profiles.dialect, tier, access, profiles.binary_path); |
| 7590 | if (!current) { |
| 7591 | record_agent_config_error(false, profiles.label, "agent_render", path); |
| 7592 | continue; |
| 7593 | } |
| 7594 | cbm_graph_access_t alternate_access = |
| 7595 | access == CBM_GRAPH_ACCESS_DIRECT ? CBM_GRAPH_ACCESS_HANDOFF : CBM_GRAPH_ACCESS_DIRECT; |
| 7596 | char *alternate = cbm_render_graph_profile(profiles.dialect, tier, alternate_access, |
| 7597 | profiles.binary_path); |
| 7598 | char *codex_rc1 = |
| 7599 | profiles.dialect == CBM_GRAPH_DIALECT_CODEX && access == CBM_GRAPH_ACCESS_DIRECT |
| 7600 | ? cbm_render_graph_profile_codex_rc1(tier) |
| 7601 | : NULL; |
| 7602 | const char *released[3]; |
| 7603 | size_t released_count = 0U; |
| 7604 | if (alternate) { |
| 7605 | released[released_count++] = alternate; |
| 7606 | } |
| 7607 | if (codex_rc1) { |
| 7608 | released[released_count++] = codex_rc1; |
| 7609 | } |
| 7610 | if (tier == CBM_GRAPH_TIER_VERIFY && profiles.legacy_verify_content) { |
| 7611 | released[released_count++] = profiles.legacy_verify_content; |
| 7612 | } |
| 7613 | int result = prepare_config_parent(path) |
| 7614 | ? cbm_text_migrate_owned_document(path, current, released, released_count) |
| 7615 | : CLI_ERR; |
| 7616 | free(codex_rc1); |
| 7617 | free(alternate); |
| 7618 | free(current); |
| 7619 | if (result != CLI_OK) { |
| 7620 | if (result > CLI_OK) { |
| 7621 | printf(" agent: preserved modified profile %s\n", path); |
| 7622 | } |
| 7623 | record_agent_config_error(false, profiles.label, "agent_install", path); |
| 7624 | continue; |
| 7625 | } |
| 7626 | printf(" agent: %s\n", path); |
| 7627 | } |
| 7628 | } |
no test coverage detected