Skip to content

Missed commit recovery #74

Merged
jkool702 merged 4 commits into
NEXT/main_3from
main
Oct 28, 2025
Merged

Missed commit recovery #74
jkool702 merged 4 commits into
NEXT/main_3from
main

Conversation

@jkool702
Copy link
Copy Markdown
Owner

@jkool702 jkool702 commented Oct 18, 2025

Summary by Sourcery

Implement missed commit recovery by reconstructing orphaned background forks and functions, improve debug trap control and log processing, refine output formatting, and update test fixtures.

New Features:

  • Add recovery logic for missing background function and fork log entries

Bug Fixes:

  • Fix detection of ‘set -m’ commands for disabling signal relay
  • Resolve missed commit issues by reconstructing orphaned logs during flamegraph combination
  • Correct parsing of empty commands and indices in log processing

Enhancements:

  • Introduce timep_SKIP_DEBUG_UNTIL_FUNC_FLAG to control debug trapping until first function
  • Enhance trap cleanup and background-function flag handling for more accurate exit tracing
  • Refactor log sorting and formatting routines for flamegraph/profile reports
  • Streamline variable declarations and remove redundant initializations

Tests:

  • Update and normalize reference output fixtures across multiple TESTS directories

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Oct 18, 2025

Reviewer's Guide

This PR extends the timep profiling framework to detect and synthesize missing log entries for orphaned background forks, tightens regexes in the log parser, defers debug trapping until actual user functions run, enriches background-function profiling, consolidates trap and variable declaration logic, refines sed-based log merging (with hotfixes for empty commands), and refreshes all test fixtures accordingly.

Sequence diagram for missed commit recovery and synthetic background fork log entry creation

sequenceDiagram
    participant ParentProcess
    participant ChildProcess
    participant LogProcessor
    participant LogFile

    ParentProcess->>ChildProcess: Forks background job
    ChildProcess->>LogFile: Writes log entries
    LogProcessor->>LogFile: Reads parent and child logs
    LogProcessor->>LogFile: Checks for missing child log entries in parent log
    alt Orphaned log detected
        LogProcessor->>LogFile: Synthesizes << (BACKGROUND FORK): ... >> entry in parent log
    end
    LogProcessor->>LogFile: Updates parent log with synthetic entry
    LogProcessor->>ParentProcess: Continues log processing
Loading

Entity relationship diagram for log files and synthetic entries

erDiagram
    LOG_FILE ||--o{ LOG_ENTRY : contains
    LOG_FILE ||--o{ SYNTHETIC_ENTRY : contains
    LOG_ENTRY {
        string id
        string type
        string command
        string timestamp
    }
    SYNTHETIC_ENTRY {
        string id
        string type
        string command
        string timestamp
        string reason
    }
Loading

Class diagram for updated timep profiling state and flags

classDiagram
    class TimepState {
        - timep_IS_BG_FLAG : bool
        - timep_IS_SUBSHELL_FLAG : bool
        - timep_IS_FUNC_FLAG : bool
        - timep_IS_BG_FUNC_FLAG : array<bool>
        - timep_SKIP_DEBUG_FLAG : bool
        - timep_SKIP_DEBUG_UNTIL_FUNC_FLAG : bool
        - timep_BG_FUNC_RETURN_TRAP_FLAG : bool
        - timep_SUBSHELL_INIT_FLAG : bool
        - timep_NO_PRINT_FLAG : bool
        - timep_NEXEC_A : array<int>
        - timep_FNEST : array<int>
        - timep_NEXEC_HASH_A : array<string>
        - timep_BASH_COMMAND_PREV : array<string>
        + trapSetup()
        + logEntryRecovery()
        + processLog()
    }

    class LogProcessor {
        + processLog()
        + synthesizeBackgroundForkEntry()
        + mergeLogs()
    }

    TimepState <|-- LogProcessor
Loading

Class diagram for log entry parsing and merging routines

classDiagram
    class LogEntry {
        - tw : string
        - pw : string
        - tc : string
        - pc : string
        - cnt : string
        - nd : string
        - lno : string
        - cind : string
        - cmd : string
    }

    class LogParser {
        + parseLogEntry(line: string) LogEntry
        + mergeLogEntries(entries: LogEntry[])
        + hotfixEmptyCommand(entry: LogEntry)
    }

    LogParser --> LogEntry
Loading

File-Level Changes

Change Details Files
Auto-recover orphaned logs by inserting synthesized background-fork entries
  • Detect missing child nexec in parent logs and warn
  • Compute and adjust start/end wall and CPU timestamps
  • Append synthetic << (BACKGROUND FORK): ... >> lines in combine routine
timep.bash
Fix and tighten regex patterns in _timep_PROCESS_LOG for robust parsing
  • Normalize leading digits and blank lines before splitting entries
  • Extend character classes to include ! and ^ in command endings
  • Strip and re-quote commands more accurately
timep.bash
Introduce skip-debug-until-function flag to defer DEBUG traps
  • Add timep_SKIP_DEBUG_UNTIL_FUNC_FLAG and integrate into trap logic
  • Reset debug trap only after entering the first user function
  • Initialize the flag in setup and main invocation
timep.bash
Enhance background-function profiling with dedicated flags and simpler traps
  • Use timep_IS_BG_FUNC_FLAG array to tag background functions
  • Remove redundant BG_FUNC_LAST_FLAG and simplify RETURN/EXIT traps
  • Capture and log background-function returns in the RETURN trap handler
timep.bash
Streamline variable declarations and unify trap setup across processes
  • Consolidate declare -g/ga/x blocks, remove unused flags
  • Comment out extraneous declare -f timep calls
  • Align DEBUG, RETURN, and EXIT trap setup in main and child
timep.bash
Refactor sed-based log parsing and merging, add hotfixes for empty command fields
  • Simplify nested sed calls and de-duplicate blank-line handling
  • Hotfix merge key when cmd is empty by shifting fields
  • Adjust output re-sorting logic to preserve function blocks
timep.bash
Update and regenerate flamegraph/profile test fixtures
  • Refresh GENERAL and language-specific out.flamegraph and out.profile files
  • Add new output files under TESTS and remove stale ones
TESTS/GENERAL
TESTS/*

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@jkool702 jkool702 merged commit 0430e25 into NEXT/main_3 Oct 28, 2025
5 checks passed
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.

1 participant