<commit_before>
#include <debug.h>
#include <tasks/train_master.h>
#include <tasks/train_blaster.h>
#include <tasks/train_control.h>
#include <tasks/path_admin.h>
#include <tasks/path_worker.h>
#include <tasks/name_server.h>
#include <tasks/priority.h>
#include <tasks/courier.h>
#include <tasks/clock_server.h>


typedef struct {
    int              train_id;
    int              train_gid;
    char             name[8];

    int              my_tid;             // tid of self
    int              blaster;            // tid of control task
    int              control;            // tid of control task


    int              path_admin;         // tid of the path admin
    int              path_worker;        // tid of the path worker

    int              checkpoint;         // sensor we last had update at
    int              checkpoint_offset;  // in micrometers
    int              checkpoint_time;

    int              destination;        // destination sensor
    int              destination_offset; // in centimeters

    int              path_steps;
    const path_node* path;

} master;


static inline bool master_try_fast_forward(master* const ctxt) {

    sensor start = { 0, 0 };
    for (int i = ctxt->path_steps; i >= 0; i--) {
        if (ctxt->path[i].type == PATH_SENSOR) {
            if (start.num == 0)
                start = pos_to_sensor(ctxt->path[i].data.sensor);

            if (ctxt->path[i].data.sensor == ctxt->checkpoint) {
                const sensor end =
                    pos_to_sensor(ctxt->path[i].data.sensor);

                log("[%s] %c%d >> %c%d",
                    ctxt->name, start.bank, start.num, end.bank, end.num);

                ctxt->path_steps = i; // successfully fast forwarded
                return true;
            }
        }
    }

    return false; // nope :(
}

static inline void
master_goto(master* const ctxt,<commit_msg>Rewind logic should not print a message unless actual rewinding occurred<commit_after>
#include <debug.h>
#include <tasks/train_master.h>
#include <tasks/train_blaster.h>
#include <tasks/train_control.h>
#include <tasks/path_admin.h>
#include <tasks/path_worker.h>
#include <tasks/name_server.h>
#include <tasks/priority.h>
#include <tasks/courier.h>
#include <tasks/clock_server.h>


typedef struct {
    int              train_id;
    int              train_gid;
    char             name[8];

    int              my_tid;             // tid of self
    int              blaster;            // tid of control task
    int              control;            // tid of control task


    int              path_admin;         // tid of the path admin
    int              path_worker;        // tid of the path worker

    int              checkpoint;         // sensor we last had update at
    int              checkpoint_offset;  // in micrometers
    int              checkpoint_time;

    int              destination;        // destination sensor
    int              destination_offset; // in centimeters

    int              path_steps;
    const path_node* path;

} master;


static inline bool master_try_fast_forward(master* const ctxt) {

    int start = -1;
    for (int i = ctxt->path_steps; i >= 0; i--) {
        if (ctxt->path[i].type == PATH_SENSOR) {

            if (start == -1) start = i;

            if (ctxt->path[i].data.sensor == ctxt->checkpoint) {

                if (start != i) {
                    const sensor head =
                        pos_to_sensor(ctxt->path[start].data.sensor);
                    const sensor tail =
                        pos_to_sensor(ctxt->path[i].data.sensor);

                    log("[%s] %c%d >> %c%d",
                        ctxt->name, head.bank, head.num, tail.bank, tail.num);
                }

                ctxt->path_steps = i; // successfully fast forwarded
                return true;
            }
        }
    }

    return false; // nope :(
}

static inline void
master_goto(master* const ctxt,
{'fraction_non_alphanumeric': 0.1037854098771622, 'fraction_numerical': 0.002256204562547004, 'mean_word_length': 1.49375, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '739332', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1124, 'n_words': 303}