Portfolio Environment Analysis
Start Every Task
- Read the user's prompt and any supplied answer template/schema. The template is the output contract; match its keys, ordering notes, constants, rounding, and "JSON only" requirements exactly.
- Read the runtime access file for the environment base URL, token, and allowed endpoints. Use only those access details for network calls.
- Fetch authoritative data from the environment. Prefer endpoint JSON for clarity; use
POST /api/querywith{"sql": "..."}when a scoped SQL query is simpler. - Treat
status,closed_at,duplicate_of,work_type,labels,title,team,product_area,release_id, andmilestone_idas authoritative. Ignore stale/export fields such asmirror_statusandlegacy_categoryunless the prompt explicitly asks to report that they were ignored.
Expected endpoint families:
/api/work-items: work items with ids, dates, status, duplicate link, team, product area, release/milestone ids, owner, severity, priority, work type, labels, title, and stale mirror/export fields./api/mix-targets: target mix rows withscope_id, quarter, product area/team group, and category percentages stored as decimals./api/sla-policy: severity-to-days policy. Use it only when an item lacks an authoritativedue_at./api/releases,/api/releases/{release_id},/api/milestones,/api/blockers,/api/dependencies: release readiness data.
Canonical Work Items
Use primary records for denominators and counts:
- Exclude records whose
statusisDuplicateor whoseduplicate_ofis populated. - Exclude
Cancelledrecords from primary populations unless the template asks for excluded/cancelled ids. - If reporting duplicates, group them by
duplicate_ofwhen present and sort clusterprimary_idvalues andduplicate_idslexicographically. If a duplicate lacks a canonical id, report it only in the requested exclusion list. - Complete statuses are
Closed,Done,Verified,Deployed, andComplete. TreatIn Progress,Review,Backlog,Reopened,Blocked, duplicates, and cancelled records as non-complete unless a task gives a narrower rule.
Portfolio Category Resolution
When category signals conflict, classify from authoritative work_type, labels, and title; do not use legacy_category or mirror_status. Normalize strings to lowercase. Apply this precedence so each included item gets exactly one category:
Security:work_typeisSecurityorCompliance, or labels/title include security signals such assecurity,cve,auth,encryption, orcompliance.Reliability:work_typeisReliability,Incident, orBug, or labels/title include reliability signals such asreliability,incident,outage,latency, orflaky.TechDebt:work_typeisRefactor,Chore, orDependency, or labels/title include debt signals such ascleanup,refactor,migration,dependency,tech-debt, orlegacy.NewFeature:work_typeisFeatureorEnhancement, or labels/title include feature signals such asfeature,rollout,enhancement, orcustomer-request.
If no rule matches, inspect the item title/labels and choose the least surprising portfolio category, documenting nothing in the final JSON unless the schema asks for a flag.
Portfolio Mix Reviews
Use this workflow for closed-work mix, target-gap, and rebalance tasks:
- Parse the quarter, teams, product area(s), scope id, and target scope id from the prompt/template.
- Convert the quarter to an inclusive closed-date range.
- Select primary work items whose
teamandproduct_areamatch the scope, whoseclosed_atfalls in the quarter, and whose authoritative status is complete. - Put excluded same-scope records in the requested flags/lists:
- duplicate exclusions:
status == "Duplicate"orduplicate_ofpopulated; - cancelled exclusions:
status == "Cancelled"; - other distractors: same-scope records that fail the primary closed-work rule.
- duplicate exclusions:
- Order included ids by
closed_atascending, then id ascending, unless the template says otherwise. - Count items by category. Use item counts, not story points.
- Load the mix target row for the requested scope id. Convert decimal targets to percentage points by multiplying by 100.
- For the standard categories in the order requested by the template, compute:
actual_pct = count / total * 100, rounded to 1 decimal;gap_pct = actual_pct - target_pct, rounded to 1 decimal.
- Under-invested categories are categories with negative gaps, sorted from most negative to least negative.
- For rebalance recommendations, choose
REBALANCE_CAPACITYwhen any gap is negative; the primary category is the largest deficit, and the secondary category is the next-largest deficit when the schema has room for one. If anowner_teamis required, choose the team with the clearest responsibility for increasing that category from the scoped evidence, often the team already delivering that category or the team whose charter/name best matches the deficit.
SLA Aging And Breach Audits
Use this workflow for SLA population, overdue, aging bucket, hotspot, duplicate cluster, missing owner, breach-rate, and escalation tasks:
- Parse teams, categories, as-of date, and recent closed window from the prompt/template.
- Select primary work items whose team is in scope, whose resolved portfolio category is in scope, and whose
created_atis on or before the as-of date. - Include an item in the primary SLA population when, as of the snapshot, it is active or recently closed:
- active:
closed_atis null or after the as-of date; - recently closed:
closed_atis betweenas_of - recent_closed_window_daysandas_of, inclusive.
- active:
- Exclude duplicates/cancelled records from the primary population, but report matching duplicate clusters when requested.
- For each included primary item, set the resolution/snapshot date to
closed_atif it is on or before the as-of date, otherwise the as-of date. - An item is overdue when
due_atis before the resolution/snapshot date. Ifdue_atis missing, compute it ascreated_at + days_to_duefrom the SLA policy for the item's severity. Due today is not overdue. - Aging bucket days are calendar days from
created_atto the resolution/snapshot date. Use buckets0-3,4-7,8-14,15-30, and31+. - Sort id lists lexicographically unless the template defines another order.
- Team overdue counts should include every scoped team requested by the template when possible, ordered as instructed, commonly alphabetically.
- Hotspots are grouped by
(team, owner)over overdue primary items; useUNASSIGNEDfor missing owners. Choose the largest count, then break ties deterministically by worse severity mix, earlier due date, team, owner. - Missing-owner ids are included primary items whose owner is null or blank.
- Breach rate is
overdue_primary_count / included_primary_count, rounded to 3 decimals. - Escalation queues should order overdue primary work by severity rank
S1,S2,S3,S4, then earliestdue_at, then priority number, then id.
Release Readiness
Use this workflow for ship decisions, milestone completion, gating work, blockers, dependency chains, and readiness score:
- Parse the release id. Fetch the release detail, milestones, blockers, dependencies, and all work items for the release.
- Primary release work is
release_idmatching the release and not duplicate, not linked as a duplicate, and not cancelled. - For each milestone in the release, count primary work assigned to that milestone.
complete_primaryis the count with a complete authoritative status;primary_totalis the denominator.completion_pctis rounded to 1 decimal. Sort milestone rows bymilestone_idunless the template says otherwise. - Readiness score is total complete primary work divided by total primary work, rounded to 3 decimals.
- Unresolved blockers have no
resolved_atand status other thanResolved. High-impact blockers are severityCriticalorHigh. Count high-impact unresolved blockers by exactcausetext. - Gating work item ids are primary release work items that are non-complete and are blocked by a high-impact unresolved blocker or by a critical dependency chain. Sort and de-duplicate.
- Critical dependency chains start at non-complete primary release work and follow dependency records whose relation indicates readiness/security/validation impact, such as
blocks-release-readiness,security-review-required,validation-required, oraudit-evidence-required. Stop and emit a path when the terminal dependency is non-complete and not duplicate/cancelled. Avoid cycles and sort paths lexicographically by the full id sequence. - Ship decision defaults:
NO_SHIPwhen high-impact unresolved blockers, gating work, or critical dependency chains remain.SHIP_WITH_WATCHwhen no hard gate remains but readiness is below complete or lower-impact unresolved blockers remain.SHIPwhen primary work is complete and no unresolved blockers or critical dependencies remain. Follow stricter task-specific decision criteria when supplied.
Final JSON Discipline
- Return one JSON object and no prose when the task asks for JSON only.
- Preserve schema constants, required keys, array ordering rules, and category order exactly.
- Use JSON numbers for rounded numeric fields. Do not quote numbers unless the template explicitly requires strings.
- For empty results, output the schema-appropriate empty array/object rather than omitting the key.