Conversation
Hotfixes found while auditing the AI extension against production logs, where `search_resources` failed on every call and leaked the SQL error to the provider: - `Sensor` and the resource search referenced `sensor_type`, a column dropped by an earlier migration. Use `type`. - Search each resource type in its own try/catch so one failure no longer takes down the whole search, and report it as an unavailable search instead. - Build search terms from reference-like tokens only: never run LIKE against `status`, `type` or `uuid`, and skip the search when nothing useful remains. - Convert order amount thresholds from dollars to minor units using the currency exponent, and expose the currency on insights. - Scope the AI capability queries with `applyDirectivesForPermissions` so answers stay within what the user may see. Adds the tool-calling surface the AI extension now drives: - `propose_create_order` and `fleetops_search` tools, registered when the AI extension is installed. - `FleetOpsAiConsoleCommands`: navigate, create, view and import commands for orders, drivers, vehicles, contacts, customers, places, fleets, issues, work orders, maintenances and the Fleet-Ops settings pages. The AI may only propose these; the user confirms and the server re-authorizes before anything runs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #330 +/- ##
=============================================
- Coverage 100.00% 99.99% -0.01%
- Complexity 11887 11990 +103
=============================================
Files 582 586 +4
Lines 44715 45132 +417
=============================================
+ Hits 44715 45131 +416
- Misses 0 1 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Auditing the Fleetbase AI extension against a production log export turned up a hard failure on this side:
fleet-ops.search_resourcesthrew on every call becauseSensorand the resource search still referencedsensor_type, a column an earlier migration had dropped. The full SQL error, company UUID included, was handed to the model provider, and the turns were still recorded as answered.Fixes
sensor_type→typeinSensor(slug, activity log, filter params,scopeByType, alert context) and in the resource search.LIKEagainststatus,typeoruuid, and the search is skipped when nothing useful is left. (The old behavior matched half the database on words like "the".)applyDirectivesForPermissionsis applied to the order insights, asset status and search queries, so AI answers stay inside what the user is allowed to see.New surface for the AI extension
propose_create_orderandfleetops_searchtools (registered only when the AI extension's tool interface is present).FleetOpsAiConsoleCommands: open, create, view and import commands for orders, drivers, vehicles, contacts, customers, places, fleets, issues, work orders and maintenances, plus the Fleet-Ops settings pages. They are built on the existing*-actionsservices. The model can only propose one; the user confirms and the server re-authorizes before anything runs.CreateOrderPreviewCapability::buildDraftaccepts a tool-supplied draft and an existing draft, instead of only parsing the prompt.Testing
2882 tests, 0 failures, 8 errors. The 8 errors are the local SQLite build lackingCONCATand fail the same way onmain; they pass on MySQL in CI. Run one file per process, as this suite requires.php-cs-fixeris clean on the changed files.Coverage for the new files has not been measured, and this repo's CI gate is 100%, so that may need a follow-up pass.
Related
The AI extension side is in fleetbase/ai; fleetbase/iam-engine#33 and fleetbase/dev-engine#46 add the resource-action services the console commands call into.