Skip to content

Datetime & node id in console logs#1131

Draft
juliankuners wants to merge 4 commits intomasterfrom
datetime-node-id-console-logs
Draft

Datetime & node id in console logs#1131
juliankuners wants to merge 4 commits intomasterfrom
datetime-node-id-console-logs

Conversation

@juliankuners
Copy link
Copy Markdown
Contributor

This PR adds the current datetime & node id to console log cheatcode prints to stdout.

Having the datetime in the output can help figure out how long kontrol took to execute a given piece of code. This is especially useful in print-f style debugging with autonomously inserted console logs by AI. Having the node id helps differentiate between different branches and was a suggestion by @anvacaru .

The console log cheatcode is implemented in kontrol via a custom step. However, custom steps currently do not have access to the current node id. Therefore, this PR requires small upstream changes in pyk and kevm before merging.

Copy link
Copy Markdown
Contributor

@anvacaru anvacaru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest splitting the PR and merging only the timestamp now. We can add the node printing once the custom_step harness is updated in pyk.

Comment thread src/kontrol/foundry.py Outdated
)

_LOGGER: Final = logging.getLogger(__name__)
_CONSOLE_LOG_DATETIME_FORMAT: Final = '%Y-%m-%d %H:%M:%S'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving this to a utils.py file so we can reuse it if needed in the future.

automergerpr-permission-manager Bot pushed a commit to runtimeverification/k that referenced this pull request Apr 9, 2026
This PR adds a new parameter that is passed to custom steps in pyk.
Specifically, the `node_id` is passed so that it can be used in
downstream custom steps.

This is required for a downstream PR in kontrol
(runtimeverification/kontrol#1131) that adds the
node id to console log cheatcode logging, which is implemented by means
of a custom step.

This PR will require adjustments in some downstream dependencies as well
such as kevm. However, not all downstream dependencies make use of
custom steps such as, e.g., wasm-semantics and komet.
@ehildenb
Copy link
Copy Markdown
Member

This feels somewhat messy. The custom step primitive initially didn't have anything to do with the KCFG structure (such as the node id) for some reason, though I can't recall.

Is the log that is produced on stderr not enough for teh AI to be able to trace the execution? It prints node ids and timestamps and branching information and everything, so you could just add _logger.info(...) steps to that, and have the AI consume that?

I won't block merging this, but can you check if the already produced logs are enough?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants