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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
# GitHub Copilot Execution Playbook
## How to Implement the KDD Data Agent Observatory Blueprint Phase by Phase

This document explains how to use the architecture blueprint safely and effectively with GitHub Copilot.

The governing architecture document is:

```text
KDD_Data_Agent_Observatory_Phased_Architecture_Blueprint.md
```

The blueprint defines the target architecture, phases, interfaces, acceptance criteria, and dependencies. This playbook defines the execution discipline: how to brief Copilot, how to review each phase, how to test, and when to commit.

---

# 1. Core Strategy

Do not ask Copilot to implement the full blueprint in one request.

Use this cycle for every phase:

```text
Phase selection
→ repository inspection
→ implementation plan
→ plan review
→ implementation
→ static checks
→ unit tests
→ integration tests
→ manual smoke test
→ artifact inspection
→ acceptance-criteria audit
→ commit
→ update implementation ledger
→ proceed to next phase
```

Each phase must be treated as an independently releasable change.

The blueprint is the architecture contract. The phase prompt is the execution contract.

---

# 2. Files to Add to the Repository Before Implementation

Place these files under the repository:

```text
docs/
  implementation/
    KDD_Data_Agent_Observatory_Phased_Architecture_Blueprint.md
    COPILOT_EXECUTION_PLAYBOOK.md
    IMPLEMENTATION_LEDGER.md
    DECISIONS.md
```

## 2.1 IMPLEMENTATION_LEDGER.md

Use this to track completion.

Recommended structure:

```markdown
# Implementation Ledger

## Current Baseline

- Branch:
- Base commit:
- Test command:
- Existing test result:
- Current known failures:
- Python version:
- Dependency manager:
- Streamlit entrypoint:
- CLI entrypoint:

## Phase Status

| Phase | Status | Branch | Commit | Tests | Acceptance | Notes |
|---|---|---|---|---|---|---|
| Phase 0 | Not started | | | | | |
| Phase 1 | Not started | | | | | |
...

## Phase Details

### Phase 0

- Started:
- Completed:
- Files changed:
- Tests added:
- Commands executed:
- Known limitations:
- Deferred work:
- Evidence:
```

## 2.2 DECISIONS.md

Record deviations and architecture decisions.

```markdown
# Architecture and Implementation Decisions

## DEC-001

- Date:
- Phase:
- Decision:
- Reason:
- Alternatives:
- Consequences:
- Blueprint impact:
```

No important blueprint deviation should remain only in a Copilot chat.

---

# 3. Branch and Commit Strategy

Use one branch per phase.

Recommended naming:

```text
feature/observatory-phase-00-baseline
feature/observatory-phase-01-run-service
feature/observatory-phase-02-evaluation-service
feature/observatory-phase-03-run-intelligence
...
```

For larger phases, use sub-branches only if necessary:

```text
feature/observatory-phase-07-plan-checkpoint
```

## Commit policy

Prefer one to three meaningful commits per phase:

```text
refactor(run): extract shared execution service
test(run): add execution service and CLI compatibility coverage
docs(run): record phase 1 implementation evidence
```

Do not make one commit for every tiny edit.

Do not commit until:

- tests pass,
- manual checks pass,
- artifacts are inspected,
- acceptance criteria are audited,
- unrelated file changes are removed.

## Commit message convention

```text
<type>(<scope>): <description>
```

Examples:

```text
test(cli): capture existing run and eval command contracts
refactor(run): extract reusable multi-task execution service
feat(ui): add predefined task run launcher
feat(steering): add persistent plan review checkpoint
feat(eval): compare guided and autonomous task cohorts
docs(observatory): update phase implementation ledger
```

---

# 4. Phase Execution Protocol

Each phase has four Copilot interactions.

## Interaction A — Repository Inspection and Plan

Copilot must inspect the repository and produce a plan only.

No code changes during this interaction.

It must identify:

- reusable code,
- current call paths,
- exact files to modify,
- exact files to create,
- tests affected,
- compatibility risks,
- ambiguities,
- planned validation commands.

Review this response before authorizing implementation.

## Interaction B — Implementation

After approving the plan, tell Copilot to implement the phase.

Copilot must:

- stay within phase scope,
- use existing conventions,
- update tests,
- preserve CLI compatibility,
- avoid placeholder implementations,
- avoid unrelated cleanup.

## Interaction C — Verification and Repair

Ask Copilot to run the complete validation matrix.

It must:

- run formatting/linting/type checks,
- run focused tests,
- run relevant broader tests,
- run CLI smoke tests,
- inspect generated artifacts,
- fix failures,
- rerun checks.

Do not accept “tests should pass.”

Require actual command output summaries.

## Interaction D — Completion Audit and Commit Preparation

Copilot must compare the implementation to every acceptance criterion.

It must provide:

- pass/fail for each criterion,
- files changed,
- test evidence,
- generated artifacts,
- known limitations,
- recommended commit message,
- implementation ledger update.

Only then commit.

---

# 5. Master Phase Prompt

Use this prompt for every phase, replacing the placeholders.

```text
You are implementing one phase of the KDD Data Agent Observatory architecture.

GOVERNING DOCUMENTS
1. docs/implementation/KDD_Data_Agent_Observatory_Phased_Architecture_Blueprint.md
2. docs/implementation/COPILOT_EXECUTION_PLAYBOOK.md
3. docs/implementation/IMPLEMENTATION_LEDGER.md
4. docs/implementation/DECISIONS.md

TARGET PHASE
Phase <PHASE_NUMBER>: <PHASE_NAME>

MODE FOR THIS REQUEST
Inspection and implementation planning only. Do not modify code yet.

OBJECTIVE
Read the complete target phase in the blueprint and inspect the current repository implementation. Produce an implementation plan grounded in the actual codebase.

MANDATORY REPOSITORY INSPECTION
Inspect at minimum:
- the current CLI entrypoint and relevant commands;
- all backend functions called by those commands;
- existing domain/config models;
- current artifact layout;
- current tests for the affected area;
- Streamlit pages/components if this phase affects UI;
- evaluator, runner, trace, replay, or checkpoint code relevant to this phase;
- current import and dependency conventions.

REQUIRED OUTPUT
Provide:

1. Current-state analysis
   - Existing relevant behavior.
   - Existing reusable functions/classes.
   - Current call graph.
   - Current artifact files and schemas.
   - Current tests.

2. Gap analysis against the blueprint
   - Requirement-by-requirement gap.
   - What is already complete.
   - What is partially complete.
   - What is missing.
   - What should not be rebuilt.

3. Proposed implementation
   - Exact files to create.
   - Exact files to modify.
   - Public interfaces and signatures.
   - Data model changes.
   - Persistence changes.
   - CLI changes.
   - Streamlit changes, if applicable.
   - Migration/backward-compatibility strategy.

4. Test plan
   - Unit tests.
   - Integration tests.
   - CLI smoke tests.
   - Streamlit smoke tests, if relevant.
   - Fixture requirements.
   - Failure and edge cases.
   - Exact commands to run.

5. Risks and decisions
   - Regression risks.
   - Concurrency/state risks.
   - Artifact compatibility risks.
   - Any ambiguity in the blueprint.
   - Recommended decision for each ambiguity.

6. Scope control
   - Explicit in-scope work.
   - Explicit out-of-scope work.
   - Unrelated cleanup that must not be performed.

7. Execution sequence
   - Ordered coding steps.
   - Validation after each major step.
   - Expected final artifacts.

RULES
- Do not change code in this planning request.
- Do not create a parallel execution or evaluation implementation.
- CLI and Streamlit must use shared services.
- Preserve existing CLI behavior unless the blueprint explicitly changes it.
- Do not place business logic in Streamlit.
- Do not use shell subprocess calls from Streamlit to invoke the CLI.
- Do not silently change artifact schemas.
- Do not claim something exists without opening and inspecting it.
- Call out conflicts between the blueprint and current repository.
- Prefer the smallest correct change that satisfies the complete phase.
```

---

# 6. Implementation Authorization Prompt

After reviewing Copilot's plan, use:

```text
Implement Phase <PHASE_NUMBER>: <PHASE_NAME> using the approved plan.

GOVERNING DOCUMENTS
- docs/implementation/KDD_Data_Agent_Observatory_Phased_Architecture_Blueprint.md
- docs/implementation/COPILOT_EXECUTION_PLAYBOOK.md
- docs/implementation/IMPLEMENTATION_LEDGER.md
- docs/implementation/DECISIONS.md

APPROVED PLAN
<PASTE OR REFERENCE THE APPROVED PLAN>

IMPLEMENTATION REQUIREMENTS
- Implement the complete phase, including production code, tests, documentation, and migrations required by the blueprint.
- Reuse existing runners, evaluators, repositories, and models where appropriate.
- Preserve existing CLI commands and artifact compatibility.
- Keep Streamlit as a thin adapter.
- Add type hints and public API docstrings.
- Use atomic writes for mutable manifest/state files.
- Handle failure and partial-artifact states explicitly.
- Do not add placeholders, fake metrics, hard-coded demo values, or TODO-only implementations.
- Do not perform unrelated refactoring.
- Record any necessary architecture deviation in docs/implementation/DECISIONS.md.
- Update docs/implementation/IMPLEMENTATION_LEDGER.md only after verification succeeds.

WORKING METHOD
1. Implement in small logical steps.
2. After each major step, run the narrowest relevant tests.
3. Fix failures before continuing.
4. At the end, run the complete phase validation matrix.
5. Do not commit automatically.

FINAL RESPONSE FORMAT
1. Summary of implementation.
2. Files created.
3. Files modified.
4. Interfaces introduced or changed.
5. Tests added.
6. Commands executed and results.
7. Generated artifacts inspected.
8. Acceptance criteria status.
9. Known limitations.
10. Suggested commit grouping and commit messages.
```

---

# 7. Verification and Repair Prompt

Use after implementation:

```text
Perform the verification and repair pass for Phase <PHASE_NUMBER>: <PHASE_NAME>.

Do not add new scope. Validate the implementation against the blueprint and repair only issues required to make this phase complete and regression-safe.

MANDATORY CHECKS

1. Repository hygiene
- Show git status.
- Identify unrelated modified or untracked files.
- Confirm no secrets, generated large artifacts, local paths, or temporary files will be committed.

2. Static validation
- Run the repository formatter check.
- Run linting.
- Run type checking if configured.
- Run import/compile checks.
- Fix all new issues introduced by this phase.

3. Focused tests
- Run all tests added for this phase.
- Run existing tests for affected modules.
- Run failure-path tests.
- Run backward-compatibility tests.

4. Integration tests
- Execute the relevant service through Python without CLI or Streamlit.
- Execute the relevant CLI command with fixture or safe test data.
- Verify generated artifacts and schemas.
- If Streamlit is affected, verify the app imports and the page loads without executing work on import.

5. Regression tests
- Run the broader practical test suite for the affected package.
- Verify existing commands remain available.
- Verify old artifact layouts remain readable where required.

6. Acceptance audit
For every acceptance criterion in the target phase:
- quote the criterion;
- mark PASS or FAIL;
- provide evidence;
- repair failures and rerun validation.

7. Artifact inspection
Open and inspect the generated JSON, JSONL, CSV, Markdown, or manifest files. Validate:
- required fields;
- valid values;
- no secrets;
- no fabricated values;
- consistent run/task IDs;
- correct state transitions;
- backward-compatible paths.

8. Final report
Return:
- commands run;
- test totals;
- failures found and fixed;
- final git diff summary;
- acceptance matrix;
- residual limitations;
- whether the phase is ready to commit.

Do not state that the phase is ready to commit unless all critical acceptance criteria pass.
Do not commit automatically.
```

---

# 8. Commit Preparation Prompt

Use only after verification passes:

```text
Prepare Phase <PHASE_NUMBER>: <PHASE_NAME> for commit.

Do not modify production behavior unless required to correct documentation or remove accidental files.

Tasks:
1. Review the final git diff.
2. Remove unrelated changes.
3. Confirm generated runtime artifacts are excluded unless they are intentional test fixtures.
4. Confirm no secrets or machine-specific paths are present.
5. Update docs/implementation/IMPLEMENTATION_LEDGER.md with:
   - phase status;
   - branch;
   - files changed;
   - tests and results;
   - acceptance-criteria status;
   - known limitations;
   - deferred work.
6. Update docs/implementation/DECISIONS.md for any architecture decisions made.
7. Recommend one to three commit groups.
8. Provide exact git add and git commit commands, but do not execute the commit.

Final response:
- final files to stage;
- files not to stage;
- commit group(s);
- exact commit message(s);
- final phase status;
- next phase dependency check.
```

---

# 9. Testing Ladder

Run tests in increasing scope.

## Level 1 — Syntax and imports

Examples:

```bash
python -m compileall src
python -c "import data_agent_baseline"
```

Use the project's actual environment command, such as `uv run`, if required.

## Level 2 — Focused unit tests

```bash
pytest tests/unit/application/test_run_execution_service.py -q
```

## Level 3 — Affected package tests

```bash
pytest tests/unit/application tests/unit/repositories -q
```

## Level 4 — CLI tests

```bash
pytest tests/integration/cli -q
```

Also inspect:

```bash
dabench --help
dabench run-lang-task --help
dabench eval-v2 --help
```

## Level 5 — Fixture integration

Execute against a reduced fixture run.

Examples:

```bash
dabench eval-v2 <fixture-run> --mode standard
dabench eval-v2 <fixture-run> --mode verbose
dabench eval-v2 <fixture-run> --mode research
```

## Level 6 — Streamlit startup

At minimum:

- import app,
- load affected page,
- confirm no execution on import,
- confirm service dependency can be mocked.

Where practical, run Streamlit headlessly and check startup logs.

## Level 7 — Real smoke test

Use one small real task before committing execution-related phases.

Do not run a full benchmark for every phase.

Use a full or 50-task run only at milestone gates.

---

# 10. Commit Gate Checklist

Before every commit, verify:

```text
[ ] Phase scope is complete.
[ ] All critical acceptance criteria pass.
[ ] Existing CLI commands remain functional.
[ ] New backend services can be called independently.
[ ] Streamlit contains no duplicated business logic.
[ ] Tests were actually run.
[ ] Manual smoke test passed where applicable.
[ ] Generated artifacts were inspected.
[ ] No secrets or machine-specific paths were added.
[ ] No unrelated changes are staged.
[ ] Documentation is updated.
[ ] Implementation ledger is updated.
[ ] Architecture decisions are recorded.
[ ] Known limitations are explicit.
[ ] Next phase dependencies are satisfied.
```

---

# 11. Phase-Specific Execution Guidance

## Phase 0 — Baseline Protection

### Test before coding

Capture:

```bash
git status
git rev-parse HEAD
pytest <current relevant suite>
dabench --help
dabench run-lang-task --help
dabench eval-v2 --help
```

### Commit after

- CLI contract tests,
- reduced fixtures,
- architecture inventory,
- current baseline results.

### Do not combine with UI work

Phase 0 should establish trustworthy regression protection.

---

## Phase 1 — Shared Run Execution Service

### Minimum manual test

Run one predefined task through:

1. the service directly,
2. the existing CLI.

Compare:

- run path,
- task path,
- success/failure status,
- prediction path,
- trace path,
- manifest,
- events.

### Commit gate

The execution loop must no longer live in the Typer command.

---

## Phase 2 — Evaluation Service

### Minimum manual test

For one fixture run:

- call service directly,
- run CLI in standard mode,
- run CLI in verbose mode,
- run CLI in research mode,
- compare artifact outputs,
- confirm warnings/errors semantics.

### Commit gate

No metric formula should accidentally change unless explicitly intended and tested.

---

## Phase 3 — Run Intelligence

### Minimum manual test

Open:

- valid evaluated run,
- run with warnings,
- partially evaluated run,
- missing evaluation,
- malformed optional artifact.

### Commit gate

Every high-level finding must link to task or metric evidence.

---

## Phase 4 — Run Launcher

### Minimum manual test

Launch:

- one task,
- multiple tasks,
- invalid selection,
- duplicate click scenario.

### Commit gate

Streamlit rerun must not create duplicate runs.

---

## Phase 5 — Live Execution

### Minimum manual test

- start task,
- refresh browser,
- observe restored state,
- observe task completion,
- observe failed task.

### Commit gate

The UI must read structured events, not console logs.

---

## Phase 6 — Custom Tasks

### Minimum manual test

- CSV task,
- multiple files,
- unsupported file,
- empty question,
- custom task without gold truth.

### Commit gate

Benchmark and custom tasks must enter the same canonical runner contract.

---

## Phase 7 — Plan Review Checkpoint

### Minimum manual test

- approve unchanged,
- revise plan,
- cancel,
- duplicate submit,
- refresh while paused,
- resume after process/UI restart if supported.

### Commit gate

The agent must resume from persisted state and not simply rerun the whole task.

---

## Phase 8 — Intervention Delta

### Minimum manual test

- no-change approval,
- one modified step,
- added/removed steps,
- unknown score before,
- cost delta available/unavailable.

### Commit gate

Unknown values must remain unknown, not be coerced to zero.

---

## Phase 9 — Guided vs Autonomous Evaluation

### Minimum manual test

- paired task,
- unpaired autonomous task,
- guided task without gold,
- improved case,
- degraded case.

### Commit gate

No correctness comparison for custom tasks without ground truth.

---

## Phase 10 — Ask This Run

### Minimum manual test

Ask:

- ranking question,
- filtering question,
- cohort comparison,
- failure question,
- intervention question,
- unsupported causal question.

### Commit gate

Queries must be read-only and evidence-linked.

---

# 12. Milestone Test Runs

Do not wait until the end for broad validation.

## Milestone A — after Phase 5

Run:

- one single task,
- one three-task run,
- one failed task case,
- eval-v2 all modes,
- Streamlit launch and live tracking,
- Run Intelligence drill-down.

## Milestone B — after Phase 6

Run:

- one benchmark task,
- one custom CSV task,
- one custom multi-source task,
- compare artifact completeness.

## Milestone C — after Phase 9

Run a small controlled experiment:

- 3–5 tasks autonomous,
- same 3–5 tasks guided,
- at least one useful intervention,
- at least one neutral or failed intervention,
- generate comparative run evaluation.

## Milestone D — final

Run the intended 50-task benchmark and selected guided/custom cases.

Generate:

- final evaluation,
- research report,
- run intelligence,
- intervention evidence,
- demo artifacts.

---

# 13. How to Handle Copilot Deviations

If Copilot proposes a different architecture, require a decision record before implementation.

Use:

```text
Your proposal differs from the governing blueprint.

Before changing code:
1. identify the exact blueprint requirement;
2. describe the proposed deviation;
3. explain why the current repository makes the blueprint approach unsuitable;
4. compare both options;
5. describe compatibility and migration consequences;
6. recommend one option;
7. draft the DECISIONS.md entry.

Do not implement until the deviation is approved.
```

---

# 14. How to Prevent Common Copilot Failure Modes

## Failure: UI-only implementation

Respond:

```text
This phase is not complete. The blueprint requires the capability in a reusable backend service. Move execution/evaluation/state logic out of Streamlit and add direct service tests.
```

## Failure: duplicate implementation

Respond:

```text
Do not create a second runner/evaluator. Identify the existing implementation and refactor it behind the shared service interface.
```

## Failure: placeholder data

Respond:

```text
Remove all hard-coded or fabricated metrics. The UI must load actual artifacts or show an explicit unavailable state.
```

## Failure: silent schema change

Respond:

```text
Document the schema change, add schema versioning or compatibility handling, update readers and validators, and add migration tests.
```

## Failure: tests not run

Respond:

```text
Run the exact validation commands now. Report actual results and repair failures before claiming completion.
```

## Failure: broad unrelated refactor

Respond:

```text
Revert unrelated changes. Keep the diff limited to the target phase and its required tests/documentation.
```

## Failure: full task rerun after steering

Respond:

```text
This does not satisfy the checkpoint requirement. Persist the checkpoint state and resume from the defined workflow boundary. Record preserved and invalidated work.
```

---

# 15. Recommended First Copilot Request

Start with Phase 0 only.

Use:

```text
You are implementing the KDD Data Agent Observatory architecture.

Read:
- docs/implementation/KDD_Data_Agent_Observatory_Phased_Architecture_Blueprint.md
- docs/implementation/COPILOT_EXECUTION_PLAYBOOK.md

Target:
Phase 0 — Baseline Protection and Architecture Inventory.

For this request, perform repository inspection and planning only. Do not modify code.

Inspect the actual repository and produce:
1. an inventory of the relevant CLI commands and backend call graph;
2. current artifact contracts;
3. current tests and coverage gaps;
4. representative fixture strategy;
5. exact files to create or modify;
6. exact tests to add;
7. exact commands to establish the baseline;
8. risks and scope boundaries;
9. a step-by-step implementation plan;
10. a mapping from every Phase 0 acceptance criterion to planned evidence.

Pay particular attention to:
- run-lang-task;
- run-lang-benchmark;
- eval-v2;
- view-task-v2;
- current runner functions;
- evaluator and hardening functions;
- current Streamlit entrypoint and task pages;
- artifact paths under runs;
- existing test conventions.

Rules:
- do not implement yet;
- do not redesign later phases;
- do not create a parallel runner or evaluator;
- preserve existing behavior;
- identify any hard-coded paths and testability issues without fixing unrelated items;
- state explicitly what should not be changed in Phase 0.
```

After approving the plan, use the implementation authorization prompt.

---

# 16. Recommended Working Rhythm

For each phase:

## Day or session start

```text
git checkout main
git pull
git checkout -b feature/observatory-phase-XX-name
```

## Baseline

Run the current relevant tests before edits.

Record failures as pre-existing.

## Copilot inspection

Use the planning prompt.

Review the plan yourself.

## Copilot implementation

Use the authorization prompt.

## Verification

Use the verification prompt.

## Manual inspection

Open generated artifacts and affected UI yourself.

## Commit

Use the commit-preparation prompt, then execute the commit manually.

## Merge

Merge only after:

- phase tests pass,
- milestone tests pass when applicable,
- ledger is updated.

---

# 17. Final Recommendation

Use the blueprint as a permanent repository document, not as a one-time prompt.

For every phase:

1. give Copilot the blueprint and playbook paths;
2. request inspection and planning only;
3. review and approve the plan;
4. request implementation;
5. request verification and repair;
6. manually inspect artifacts/UI;
7. request commit preparation;
8. commit manually;
9. update the ledger;
10. proceed only after the stop/go gate passes.

This creates strong control without requiring you to micromanage individual code edits. It also ensures that each phase is testable, reviewable, reversible, and independently committable.