Class: RobotLab::To::NotesManager

Inherits:
Object
  • Object
show all
Defined in:
lib/robot_lab/to/notes_manager.rb

Overview

Manages the cross-iteration notes file (notes.md).

Written by the orchestrator only. The robot reads it at the start of every iteration to understand prior work.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ NotesManager

Returns a new instance of NotesManager.



12
13
14
# File 'lib/robot_lab/to/notes_manager.rb', line 12

def initialize(path)
  @path = Pathname.new(path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/robot_lab/to/notes_manager.rb', line 10

def path
  @path
end

Instance Method Details

#append_decision(decision, iteration) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/robot_lab/to/notes_manager.rb', line 96

def append_decision(decision, iteration)
  append(<<~MD)

    ### Iteration #{iteration} [DECISION]

    **Raised:** #{decision.question}
    **Blocking:** #{decision.blocking? ? "yes" : "no"}
    **Recommendation:** #{decision.recommendation}
    **File:** #{decision.path}
  MD
end

#append_error(error, iteration) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/robot_lab/to/notes_manager.rb', line 87

def append_error(error, iteration)
  append(<<~MD)

    ### Iteration #{iteration} [ERROR]

    **Error:** #{error.class}: #{error.message}
  MD
end

#append_failure(result, iteration) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/robot_lab/to/notes_manager.rb', line 46

def append_failure(result, iteration)
  learnings_md = bullet_list(result.key_learnings)
  append(<<~MD)

    ### Iteration #{iteration} [FAIL]

    **Summary:** #{result.summary}

    **Learnings:**
    #{learnings_md}
  MD
end

#append_no_improvement(result, detail, iteration) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/robot_lab/to/notes_manager.rb', line 59

def append_no_improvement(result, detail, iteration)
  append(<<~MD)

    ### Iteration #{iteration} [NO IMPROVEMENT]

    **Summary:** #{result.summary}

    **Score:** #{detail}

    The change passed the gate but did not beat the parent commit, so it was
    rolled back. Try a different approach next iteration.
  MD
end

#append_success(result, iteration) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/robot_lab/to/notes_manager.rb', line 30

def append_success(result, iteration)
  changes_md = bullet_list(result.key_changes)
  learnings_md = bullet_list(result.key_learnings)
  append(<<~MD)

    ### Iteration #{iteration}

    **Summary:** #{result.summary}

    **Changes:**
    #{changes_md}
    **Learnings:**
    #{learnings_md}
  MD
end

#append_verify_failure(result, output, iteration) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/robot_lab/to/notes_manager.rb', line 73

def append_verify_failure(result, output, iteration)
  append(<<~MD)

    ### Iteration #{iteration} [VERIFY FAILED]

    **Summary:** #{result.summary}

    **Verification output:**
    ```
    #{output}
    ```
  MD
end

#readObject



26
27
28
# File 'lib/robot_lab/to/notes_manager.rb', line 26

def read
  @path.exist? ? @path.read : ""
end

#setup(run) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/robot_lab/to/notes_manager.rb', line 16

def setup(run)
  AtomicFile.write(@path, <<~HEADER)
    # robot-to run: #{run.run_id}

    Objective: #{run.objective}

    ## Iteration Log
  HEADER
end