stateful / runme

DevOps Workflows Built with Markdown
https://runme.dev
Apache License 2.0
901 stars 30 forks source link

Create machine logs to support AI retraining #585

Closed jlewi closed 1 month ago

jlewi commented 1 month ago

To support collecting implicit feedback and retraining an AI we need to create machine readable logs that contain the actual command executed.

The design is described in #574.

With this change and ai logs enabled here is what the logs look like.

On the console a sample log message looks like the following in dev mode

2024-05-22T18:05:57.469-0700    INFO    cmd/server.go:98    started listening   {"addr": "127.0.0.1:7890"}
{"level":"info","ts":1716508179.861355,"caller":"runner/service.go:231","msg":"received initial request","_id":"01HYKXRFCN5W0NAM6A0ZT1HA36","knownID":"01HYKXRFCM4635SGV5FZ7K519R","req":{"commandMode":"COMMAND_MODE_INLINE_SHELL","commands":["echo 1","sleep 1","echo 2"],"knownId":"01HYKXRFCM4635SGV5FZ7K519R","programName":"bash"}}

In non dev mode the console output is

{"level":"info","ts":1716426636.145299,"caller":"cmd/server.go:98","msg":"started listening","addr":"127.0.0.1:7890"}

In the JSON log we get a log message like the following

{"level":"info","ts":1716426810.6269372,"caller":"cmd/server.go:98","function":"github.com/stateful/runme/v3/internal/cmd.serverCmd.func2","msg":"started listening","addr":"127.0.0.1:7890"}
{"level":"info","ts":1716426817.861532,"caller":"runner/service.go:207","function":"github.com/stateful/runme/v3/internal/runner.(*runnerService).Execute","msg":"running Execute in runnerService","_id":"01HYHG5GA5YQDWGN4RG5DQ0B29"}
{"level":"info","ts":1716508331.223864,"caller":"runner/service.go:231","function":"github.com/stateful/runme/v3/internal/runner.(*runnerService).Execute","msg":"received initial request","_id":"01HYKXX36Q3DDH8HBK18STME3M","req":{"commands":["ls"]}}

Note that "req" is logged as a nested json object; its not string field containing the serialized JSON of the request.

Prior to this change here's what the console logs look like.

In dev mode:

2024-05-22T18:02:20.122-0700    INFO    cmd/server.go:97    started listening   {"addr": "127.0.0.1:7890"}

In non dev mode:

{"level":"info","ts":1716426314.946205,"caller":"cmd/server.go:97","msg":"started listening","addr":"127.0.0.1:7890"}

Related to #574

jlewi commented 1 month ago

@sourishkrout This is ready for you.

jlewi commented 1 month ago

@sourishkrout PTAL; I did the rename of the logging directory.