I need a very thorough exploration of the work queue ranking and ordering systems in…
Private research annotation
Sign in to add a private research label or note.
- User
I need a very thorough exploration of the work queue ranking and ordering systems in this codebase. The goal is to understand ALL the different ordering/prioritization mechanisms and whether they conflict with each other.
Specifically investigate:
-
engine/_work_queue/ranking.py- The main ranking algorithm. Read it fully. Understand how mechanical vs subjective items are ordered. Look atitem_sort_keyand all the sort tuple construction. -
engine/_work_queue/core.py- How_apply_plan_order()works and how it interacts with ranking. Read fully. -
engine/_work_queue/helpers.py- Any helper functions related to ordering. -
engine/_work_queue/plan_order.py- New file, read it. -
engine/_scoring/policy/core.py- Find SUBJECTIVE_WEIGHT_FRACTION and understand how scoring weights work. What are the actual weight fractions for subjective vs mechanical? -
engine/work_queue.py- The facade. How does it compose the ordering? -
engine/planning/queue_policy.py- Queue policy for planning. Read it. -
engine/planning/select.py- How items are selected. -
engine/_work_queue/ranking.pylines 100-130 especially - the mechanical vs subjective sort key construction. -
desloppify/app/commands/helpers/subjective.py- How subjective items are handled in commands. -
engine/_scoring/results/core.py- How scores are computed. -
Look for ANY other files that influence queue ordering - grep for "sort_key", "queue_order", "ranking", "priority", "work_queue" across the codebase.
-
Check
engine/_plan/operations.pyfor plan-based ordering. -
Check
engine/planning/core.pyfor how planning interacts with queue.
For each file, provide the FULL content of the [REDACTED], not just summaries. I need to understand the exact logic.
-
Assistant
I'll conduct a thorough exploration of the work queue ranking and ordering systems. Let me start by reading all the key files in parallel.
Assistant
Now let me read the remaining files in parallel.
Assistant
Now let me read the scoring policy core, the health score computation, and search for other ordering-related files.
Assistant
Now let me read a few more key files that influence queue ordering.
Assistant
Now let me check the scorecard_projection and a few additional files that appear in the ordering pipeline.
Assistant
Now let me check the
CONFIDENCE_ORDERusage and any remaining queue-related files.Assistant
- User
I need to understand how to compute the "marginal score impact" of fixing a work queue item in the desloppify codebase. This is for a planned overhaul where queue items should be prioritized by how much they'd improve the overall score.
Specifically investigate:
-
engine/_scoring/results/health.py— Read fully. How is the overall health score computed from mechanical and subjective dimensions? How doesSUBJECTIVE_WEIGHT_FRACTION(0.60) andMECHANICAL_WEIGHT_FRACTION(0.40) factor in? What are the formulas? -
engine/_scoring/results/core.py— Read fully. How are individual dimension scores computed? How does fixing a finding change a dimension score? -
engine/_scoring/results/impact.py— Read fully if it exists. Any existing impact estimation? -
engine/_scoring/policy/core.py— Read the weight constants:MECHANICAL_DIMENSION_WEIGHTS, . What's the total weight pool for each?
-
Assistant
I'll systematically investigate the scoring system to understand marginal score impact computation. Let me start by reading all the key files in parallel.
- User
I need to understand all the consumers of the work queue ordering in the desloppify codebase, so I know what would break if we change the ordering system.
Find and read all call sites of:
build_work_queue— who calls it and with what options?item_sort_key— is it used anywhere outside ofranking.pyandplan_order.py?_apply_subjective_interleave_guardrail— only used incore.py?get_next_itemsfromengine/planning/select.py— the legacy API, who calls it?build_open_plan_queuefromengine/planning/queue_policy.py— who calls it?
Also look at: 6. Tests — what tests exercise the queue ordering? Search in
tests/for tests that import from_work_queueor test queue ordering behavior. Read the test file names and key test function names (not full content). 7. Thenextcommand (app/commands/next.py) — how does it use the queue? 8. Theshowcommand (app/commands/show/cmd.py) — how does it use the queue? 9. Theplancommand — how does it use the queue? 10. The command — does it use the queue? Assistant
Good, I have the main files. Now let me read the policy constants and the detection/weighting logic.
Assistant
I'll systematically search for all consumers of the work queue ordering system. Let me start with parallel searches for all the key functions and imports.
Assistant
Now let me look at the relevant grep results more closely, plus the work queue ranking to see how impact is currently used.
Assistant
Good, I have the initial search results. Now let me read the key source files to understand the actual implementations and call sites.
Assistant
Now let me see how
compute_score_impactis actually used in the narrative/next command rendering, and let me check the subjective scoring to understand the full picture.Assistant
Now let me read the command files that consume the queue, and dig into the callers.
Assistant
Now let me check the
_estimate_wontfix_strict_deltain the resolve selection, as it's another existing delta estimator.Assistant
Now let me read the remaining consumer files -- the plan queue render, queue_progress helper, the plan_cmd shim, and the test files.
Assistant
Now let me search for any other callers of
get_next_itemsorget_next_item(the legacy API), and look at the test files.Assistant
Now let me read the test files that exercise queue ordering.
Assistant
Let me get the test function names from the key queue test files and also read the narrative module and scan_workflow to see if they use queue ordering.
Assistant
Let me check a few more areas -- the scan workflow (which uses queue for narrative), and check whether
build_open_plan_queueis called from anywhere other than the policy module.Assistant
Now I have a comprehensive picture. Let me also check the
_work_queue/helpers.pymodule for thebuild_subjective_itemsand any ordering-relevant code there.Assistant
Let me also check the review preflight, which is another consumer I see.
Assistant
Assistant
- User
Assistant
I'll explore the codebase thoroughly to understand the current implementation before designing the plan. Let me start by reading the key files.
Assistant
Now let me read the scoring infrastructure files that will provide the impact data.
Assistant
Now let me look at the scoring policy to understand dimensions, detector mappings, and confidence weights.
Assistant
Now let me look at the test files to understand existing test patterns and what assertions need updating.
Assistant
Now let me check the remaining test files and the consumers that care about ordering.
Assistant
Let me check the
CONFIDENCE_ORDERused in the sort key, and also look at how_collapse_clustersis imported/used in the test file and what other tests reference the interleave guardrail.Assistant
Let me check how the consumers use the queue and also verify the
_collapse_clustersimport in test_auto_cluster.py.Assistant
Now let me check how
suppressed_countis used downstream (to understand the impact of removing backlog_gated).Assistant
Let me check how
queue_progress.pyuses thesuppressed_countto understand the full downstream impact.Assistant
Now I have a thorough understanding of the codebase. Let me also verify the
DETECTOR_SCORING_POLICIESto understand the detector-to-dimension mapping used for impact estimation, and check theDIMENSIONS_BY_NAMEstructure.Assistant
Assistant
Good. All
backlog_gatedand_apply_subjective_interleavereferences in tests are only inwork_queue_cases.py. Let me also check theexplaintest assertions to see if the ranking_factors assertions will break.Assistant
I notice there's a parallel
integration/work_queue_cases.pyfile. Let me check it.Assistant
Good -- the integration copy doesn't reference the removed behaviors. Now let me verify one more thing:
test_review_items_sort_by_issue_weight_within_tier-- this test asserts ordering of two review findings. With impact-aware sorting, both arereviewdetector findings (which havedimension=NoneinDETECTOR_SCORING_POLICIES), meaningget_dimension_for_detector("review")returnsNone. So both getestimated_impact = 0.0, and tiebreakers (review_weight) still determine order. This test should pass without changes.Assistant
Good. Both
reviewfindings haveget_dimension_for_detector("review") -> None, so both getestimated_impact = 0.0. The tie breaks toreview_weightwhich is10.0for holistic vs1.0for standard. The holistic one still sorts first. This test passes without changes.Now let me verify the
test_review_items_sort_by_issue_weight_within_tierlogic under the new sort key. The sort key for a review finding (non-subjective, sinceis_subjective_findingchecks forsubjective_assessmentorholistic_reviewdetectors, notreview):python# review findings: is_subjective = False (detector is "review", not "subjective_assessment" or "holistic_review") # is_review = True # So they use the mechanical branch: (1, -0.0, CONFIDENCE_ORDER["high"], -review_weight, -count, id) = (1, 0.0, 0, -10.0, 0, "review::src/a.py::logic") # holistic = (1, 0.0, 0, -1.0, 0, "review::src/a.py::naming") # standardAssistant