Skip to content

fix: restore offline workflow, approval-first proposals, and 5-state Ollama engine - #2

Merged
aadiur merged 14 commits into
mainfrom
fix/sortsense-regression-restoration
Nov 18, 2026
Merged

aadiur merged 14 commits into
mainfrom
fix/sortsense-regression-restoration

Conversation

@aadiur

@aadiur aadiur commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

SortSense — Verification & Final Restoration Report

1. Root Cause Analysis (Confirmed & Corrected from FIXES.md)

  1. Deterministic analyzer had zero academic subject knowledge: It previously scored only high-level document types (invoice, assignment, question paper) and added only +0.05 for subject names if a document type matched first. Unclassified study notes with opaque filenames (e.g. DOC-WA0879845.pdf) scored 0.15–0.25, dropping to the review queue without intelligent categorization. The 0.85 threshold was never the problem—the evidence scoring lacked subject intelligence.
  2. organizer.decide() discarded content-derived filenames: When an unclassified document was analyzed, decide() rebuilt the filename from document_type, suggesting Unclassified.txt.
  3. Automatic file movement without user approval: The legacy GUI moved files automatically via private _safe_move, bypassing SafeFileExecutor and creating no history records (disabling Undo).
  4. Dishonest AI status badge: The GUI previously displayed active AI state based purely on configuration or server ping without validating model availability or tracking inference failures.
  5. PDF ingestion hard dependency on PyMuPDF: Without a fallback, environments without compiled fitz binaries failed all PDF processing.
  6. Configuration omission discovered during live testing: Settings model in app/config.py was missing ollama_timeout, causing live inference via _make_client() to crash with AttributeError.

2. Files Modified & Changes Beyond the ZIP

Beyond the files integrated from SortSense-fixed.zip, the following critical fixes and improvements were engineered:

  • app/config.py: Added ollama_timeout: float = 120.0 (with SORTSENSE_OLLAMA_TIMEOUT / FILEMIND_OLLAMA_TIMEOUT fallback) to resolve AttributeError during real Gemma client initialization.
  • app/gui.py:
    • save_settings(): Fixed race condition and GUI freeze by stopping and joining the background observer in a daemon worker thread before restarting.
    • _open_proposals(): Filtered out REJECTED and FAILED items so rejected proposals do not reappear upon queue refresh.
    • Review queue counters: Verified Pending tracks unapproved/unexecuted proposals, while Processed increments strictly on successful execution.
  • app/main.py: Replaced outdated "FileMind" branding with "SortSense — local AI file organizer" in banner and docstrings.
  • sortsense.spec: Added 'pypdf' to hidden_imports to prevent ModuleNotFoundError in packaged standalone binary.
  • .github/workflows/ci.yml:
    • Pinned Windows CI to Python 3.11 with pip cache.
    • Replaced ambiguous py -m pytest with explicit python -m pytest (avoiding runner Python 3.15 fallback).
    • Added upload-artifact@v4 step publishing dist/SortSense/ as SortSense-Windows-exe.
    • Added push triggers for fix/sortsense-regression-restoration.
  • .gitignore: Added .venv*/, *.pyo, pytest_*.txt, and *.exe.
  • RELEASE_NOTES_DRAFT.md: Pre-release v0.1-beta release notes draft.
  • INSTALL.md: Testing and installation guide for multi-PC evaluation.

3. Verified Working Features (With Concrete Evidence)

  • Zero-move before approval: Real filesystem testing verified that 12 opaque download files placed in Downloads/ remained untouched until explicit approval.
  • User-controlled editing: Filename entries and destination directories are completely editable in the Review Queue.
  • Custom destination override: Successfully redirected a DSA proposal from Downloads/DOC-WA0879845.pdf to custom folder Competitive Programming/Graph_Algorithms_BFS_DFS.pdf.
  • Selective rejection: Rejecting DOC-WA0926714.pdf left it completely untouched in Downloads/ while approved files were moved.
  • Safe Execution & Collision Avoidance: Only approved files moved; collisions receive numbered suffixes rather than overwriting.
  • Full History & Undo: Executing undo on the 11 moved files restored all files back to Downloads/ with their original opaque filenames preserved.
  • PyInstaller Packaging: Built dist/SortSense/SortSense.exe (14.8 MB), passed standalone smoke test with exit code 0 ([SMOKE TEST] ALL WORKFLOWS PASSED CLEANLY.).
  • GitHub Actions CI: Workflow run 44267894064 passed both Test Suite (Python 3.11) and Windows Desktop Packaging, uploading SortSense-Windows-exe artifact.

4. Deterministic-Mode Demo on the 12 Fixture Files

Ran with Ollama offline across mixed .pdf, .md, and .txt files:

File: DOC-WA0879845.pdf                  -> Proposed: Breadth_First_Search_and_Depth_First_Search.pdf | Cat: DSA                  | Conf: 0.92
     Evidence: [Matched 9 DSA terms: dsa, algorithms, stack, queue, breadth first search, depth first search, Subject terms appear in the document heading]
File: WhatsApp Document 2026-11-12.pdf   -> Proposed: Sorting_Algorithms.pdf                 | Cat: DSA                  | Conf: 0.92
     Evidence: [Matched 6 DSA terms: algorithm, algorithms, merge sort, quick sort, sorting, pivot, Subject terms appear in the document heading]
File: download_3.pdf                     -> Proposed: Binary_Search_Tree.pdf                 | Cat: DSA                  | Conf: 0.92
     Evidence: [Matched 7 DSA terms: data structures, algorithms, binary search tree, bst, binary search, inorder traversal, Subject terms appear in the document heading]
File: DOC-WA0926714.pdf                  -> Proposed: Graph_Theory_and_Trees.pdf             | Cat: Discrete Mathematics | Conf: 0.90
     Evidence: [Matched 8 Discrete Mathematics terms: discrete mathematics, graph theory, vertices, edges, spanning trees, cycles, Subject terms appear in the document heading]
File: assignment_final.txt               -> Proposed: Propositional_Logic.txt                | Cat: Discrete Mathematics | Conf: 0.90
     Evidence: [Matched 7 Discrete Mathematics terms: discrete mathematics, propositional logic, proposition, truth table, logical connectives, biconditional, Subject terms appear in the document heading]
File: IMG-WA0048217.pdf                  -> Proposed: Sets_Relations_and_Functions.pdf       | Cat: Discrete Mathematics | Conf: 0.90
     Evidence: [Matched 8 Discrete Mathematics terms: discrete mathematics, set theory, relations, reflexive, symmetric, antisymmetric, Subject terms appear in the document heading]
File: Notes_28112026.md                  -> Proposed: ACID_Properties.md                     | Cat: DBMS                 | Conf: 0.90
     Evidence: [Matched 6 DBMS terms: acid, transactions, commit, rollback, savepoint, database, Subject terms appear in the document heading]
File: DOC-WA0765319.pdf                  -> Proposed: Database_Normalization.pdf             | Cat: DBMS                 | Conf: 0.92
     Evidence: [Matched 8 DBMS terms: database management systems, normalization, 1nf, 2nf, 3nf, candidate key, Subject terms appear in the document heading]
File: WhatsApp Document 2026-11-15.pdf   -> Proposed: Inner_Join_and_Left_Outer_Join.pdf     | Cat: DBMS                 | Conf: 0.92
     Evidence: [Matched 6 DBMS terms: dbms, sql, join, inner join, left join, select, Subject terms appear in the document heading]
File: file (7).txt                       -> Proposed: Inheritance_and_Polymorphism.txt       | Cat: OOPS                 | Conf: 0.92
     Evidence: [Matched 8 OOPS terms: object oriented, inheritance, polymorphism, interface, method overriding, class, Subject terms appear in the document heading]
File: scan001.pdf                        -> Proposed: Abstract_Classes_and_Interfaces.pdf    | Cat: OOPS                 | Conf: 0.92
     Evidence: [Matched 6 OOPS terms: oops, abstraction, abstract class, interface, class, java, Subject terms appear in the document heading]
File: new_document.txt                   -> Proposed: Classes_Objects_and_Data_Hiding.txt    | Cat: OOPS                 | Conf: 0.92
     Evidence: [Matched 11 OOPS terms: oops, encapsulation, class, object, objects, access modifiers, Subject terms appear in the document heading]

5. Ollama & Gemma Engine State Verification

Each of the 5 engine states was tested directly against OllamaServiceManager.engine_state():

  1. Ollama package missing: ('deterministic', 'Deterministic Mode (Ollama not installed)')
  2. Ollama daemon stopped: ('ollama_unavailable', 'Ollama Unavailable - using Deterministic Mode')
  3. Model missing: ('model_missing', 'Ollama Available / Model Missing (nonexistent-model:99b)')
  4. Gemma running & reachable: ('gemma_active', 'Gemma AI Active (gemma4:e4b)')
  5. Inference failed / timeout: ('request_failed', 'Model Request Failed - using Deterministic Mode')

Real Inference Output (tests.smoke_test_live with gemma4:e4b on CPU):

  • Document: test_files/filemind_sample.pdf (69 chars, 1 page)
  • Document Type: Smoke Test Verification
  • Category: Testing
  • Suggested Filename: FileMind_SmokeTest_PDF.txt
  • Summary: A smoke-test PDF used to verify the end-to-end PDF ingestion process for FileMind.
  • Confidence: 0.95
  • Validation safeguard: VALID: False, ISSUES: ["new_filename 'FileMind_SmokeTest_PDF.txt' does not end with correct extension '.pdf'."] (Safeguard caught extension mismatch and prevented unsafe rename).

6. Automated Test Results

  • Full Test Suite: 279 passed, 0 failed, 0 skipped in 18.57s.
  • Suite with Ollama running: 279 passed, 0 failed in 18.57s.
  • Suite with Ollama stopped: 279 passed, 0 failed in 19.07s.
  • Packaging Lifecycle: 6 passed in 3.60s (including test_low_confidence_document_routed_to_review_despite_rule_match).
  • User-Controlled Workflow & 12-file Scenario: 31 tests passed in 6.42s.

7. Git & Repository Status

  • Active Branch: fix/sortsense-regression-restoration
  • Latest Commit: 6e80bcd (ci: ensure python -m executable invocation in GitHub Actions workflow and add *.exe to gitignore)
  • Working Tree: Clean (verified with git status).
  • Open Pull Request: PR fix: restore offline workflow, approval-first proposals, and 5-state Ollama engine #2 opened to main (not merged, awaiting approval).
  • GitHub Release: Not published (drafted in RELEASE_NOTES_DRAFT.md).

8. Remaining Limitations & Non-Verified Items

  1. No OCR Support: Scanned/image-only PDFs contain no text layer and are categorized as empty with original filename kept for manual review.
  2. Clean-Machine Windows VM Testing: Verified on host Windows 11 development machine and GitHub Actions windows-latest virtual runner. A bare Windows machine with zero developer runtimes has not been tested locally.
  3. SmartScreen Warning: Executable is currently unsigned; Windows Defender SmartScreen displays standard unsigned executable prompt on first launch.

@aadiur
aadiur merged commit fcf1d88 into main Nov 18, 2026
4 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