Esempi di scansione
Output reali su tre applicazioni di prova, dalla scansione al context pack.
Gli output di questa pagina sono reali: sono stati prodotti da si-engine 1.1.0 su tre piccole applicazioni di prova, in modalità --source-only (senza un SQL Server collegato). Sono stati abbreviati solo dove indicato con «…». Le applicazioni sono fixture di analisi: un MVC con ordini e clienti, una Razor Pages e una API minimal.
Tre applicazioni, tre scansioni
| Applicazione | File | Pagine | Endpoint | Regole | Entità | Relazioni |
|---|---|---|---|---|---|---|
| Sample MVC | 22 | 6 | 10 | 29 | 100 | 247 |
| Sample Razor Pages | 16 | 4 | 0 | 9 | 39 | 56 |
| Sample API | 4 | 0 | 9 | 12 | 42 | 82 |
Ogni scansione dura circa un secondo. Lo stato finale è completed_with_warnings perché la copertura è parziale: il database non è stato analizzato e il report lo dice.
1. Scansione
$ si-engine init
$ si-engine app add --name "Sample MVC" --repository ./SampleMvcApplication
$ si-engine scan --application sample-mvc --source-only
Scan sample-mvc-scan-001 of 'Sample MVC': completed_with_warnings - partial coverage (mode: source-only, 977 ms)
files 22, projects 1, symbols 107, pages 6, endpoints 10, tables 0, database relationships 0, rules 29
knowledge: 100 entities, 247 relationships; warnings 0, errors 0
coverage: PARTIAL - analysed: aspnet, business rules, data access, discovery, source
NOT analysed - database: Database analysis disabled (source-only): tables, columns,
constraints, procedures and database rules were not analysed; tables are known only from the code.
Next: si-engine status --application sample-mvcLe tabelle sono 0 perché il database non è stato letto, ma ORDERS compare comunque nel modello perché il codice la usa: la riga «known only from code» lo dichiara.
$ si-engine status --application sample-mvc
Last scan sample-mvc-scan-001: completed_with_warnings (mode: source-only)
knowledge: 100 entities, 247 relationships; warnings 0, errors 0
entities: action 10, api_endpoint 10, application 1, business_rule 29, component 4, controller 3,
entity 3, menu 5, module 8, page 6, permission 4, project 1, repository 6, scan 1,
service 4, stored_procedure 2, table 32. Ricerca
$ si-engine search --application sample-mvc --query ordini --limit 5
5 result(s) for 'ordini' (sqlite-fts, bm25; higher score = more relevant):
1.00 table ORDERS
table:dbo.orders (Data/Repositories.cs, Data/SalesDbContext.cs)
1.00 controller Orders [module Orders]
controller:SampleMvcApplication|SampleMvcApplication.Controllers.OrdersController (Controllers/OrdersController.cs)
1.00 entity Order [module Models]
symbol:SampleMvcApplication|SampleMvcApplication.Models.Order (Models/Order.cs)
1.00 module Orders
1.00 menu OrdersLa parola italiana «ordini» trova elementi chiamati Order e ORDERS: merito del glossario bilingue. Ogni risultato ha un id stabile e i file in cui compare.
3. Analisi di impatto
$ si-engine impact --application sample-mvc --target table:dbo.orders
Impact analysis: table:dbo.orders
Target: ORDERS (table)
Risk (indicator, not a prediction): HIGH - 17 confirmed item(s) (direct 2, transitive 15) in 4 group(s);
0 possible and 1 unverified item(s) are NOT counted: the risk may be underestimated
Counts: direct 2, transitive 15, possible 0, unverified 1
Coverage: PARTIAL
SERVICES:
- EfOrderRepository [direct, distance 1, confidence 0.80]
reads ORDERS (fact); DbSet query (Order), FromSqlRaw
- OrdersController.Create [transitive, distance 1, confidence 0.72, deduced]
writes ORDERS (deduced); via OrdersController.Create -> OrderService.CreateOrder
-> EfOrderRepository.AddAsync -> writes table:dbo.orders
- AdoOrderReportRepository [unverified]
builds SQL dynamically (hasDynamicSql): static analysis cannot tell whether it
accesses ORDERS; this is NOT a verified dependency.
PAGES:
- Views/Orders/Create.cshtml [transitive, confidence 0.69, deduced] writes ORDERS
- endpoint:POST /Orders/Create [transitive, confidence 0.65, deduced]
- menu: Orders > New order [transitive, confidence 0.62, deduced]
RULES:
- 'The order is already closed.' references ORDERS (deduced, confidence 0.70)
TESTS:
No tests detected: the knowledge model does not contain test entities. Nothing is inferred.Notare tre cose: ogni passo ha una confidenza e dice se è fatto o dedotto; la catena di chiamate è mostrata per intero; e AdoOrderReportRepository è messo tra i non verificati perché costruisce SQL dinamico, invece di essere dichiarato dipendente o indipendente a caso.
4. Context pack per un agente
$ si-engine context --application sample-mvc --query "modifica gestione ordini" --max-tokens 1200
CONTEXT PACK: ordini
SCAN: sample-mvc-scan-001; COVERAGE: PARTIAL (not analysed: database)
BUDGET: about 1147 tokens (ESTIMATE, approx-chars-div-4) of max 1200
PAGES:
- Views/Orders/Create.cshtml (route /Orders/Create; reads CUSTOMERS; writes ORDERS;
requires CanCreateOrders, authenticated)
SERVICES:
- OrderService (type service; calls AdoOrderReportRepository, CustomerService, EfOrderRepository)
- EfOrderRepository (type repository; reads ORDERS; writes ORDERS)
TABLES:
- ORDERS (read by EfOrderRepository; written by EfOrderRepository; known only from code (no catalog))
RULES:
- OrdersController.Close: Requires one of the roles: Admin,Manager
- Orders cannot be created for inactive customers. (when !customer.IsActive; then Throws InvalidOperationException)
- Quantity must be positive. (when quantity <= 0; then Throws ArgumentOutOfRangeException)
…
EXCLUDED: 59 element(s) left out (entity 40, relationship 19; the full list is in the JSON field 'excluded')Il pack sta nel budget richiesto, dichiara la stima di token e dice che cosa ha lasciato fuori. È ciò che un agente riceve al posto di migliaia di file.
5. Documentazione generata
$ si-engine export human --application sample-mvc
Exported 'human' of Sample MVC (scan sample-mvc-scan-001): 79 file(s)
$ si-engine export llm --application sample-mvc
Exported 'llm' of Sample MVC (scan sample-mvc-scan-001): 146 file(s)Estratto da human/security/index.md: chi richiede quale permesso.
| Permesso | Tipo | Richiesto da |
|---|---|---|
Admin | role | Customers, Orders.Close, GET /customers, POST /customers/{id}/deactivate, … |
authenticated | authenticated | Orders, /Orders/Create, /Orders/Details/{id?}, … |
CanCreateOrders | policy | /Orders/Create, Orders.Create, POST /Orders/Create |
Manager | role | Orders.Close, POST /Orders/Close/{id?} |
Estratto da una regola di business, human/business-rules/financial-…credit-limit.md:
# The order exceeds the customer credit limit.
> Categoria `financial`. Provenienza: `static_analysis`, fatto, confidence 0.80;
> metodo di estrazione `roslyn_syntax`.
## Condizione
total > customer.CreditLimit
## Effetto
- Effetto: `Throw`
- Messaggio di errore: The order exceeds the customer credit limit.
## Origine
Simbolo di origine: `SampleMvcApplication.Services.OrderService.CreateOrder`E il diagramma dell'architettura, in Mermaid (human/architecture.mmd), pronto per un renderer qualsiasi:
flowchart LR
n1["Pagine: 6"]
n2["Endpoint API: 10"]
n3["Controller: 3"]
n4["Servizi: 4"]
n5["Repository: 6"]
n6["Tabelle e viste: 3"]
n7["Stored procedure e funzioni: 2"]
n8["Regole business: 29"]
n1 -->|"READS x4"| n6
n1 -->|"WRITES x1"| n6
n5 -->|"CALLS x2"| n7
n4 -->|"CALLS x3"| n5
n4 -->|"ENFORCES x9"| n86. Scansione incrementale e diff
Aggiunta una classe ReportService al progetto e rilanciata la scansione:
$ si-engine scan --application sample-mvc --source-only --incremental
Scan sample-mvc-scan-002 of 'Sample MVC': completed_with_warnings (mode: source-only, 963 ms)
knowledge: 101 entities, 248 relationships; warnings 0, errors 0
incremental (based on sample-mvc-scan-001): files 24 = 0 reused + 24 re-analysed;
added 1, modified 0, deleted 0; database objects changed 0/0
$ si-engine diff --application sample-mvc --from 1 --to 2
Diff sample-mvc-scan-001 -> sample-mvc-scan-002 of 'Sample MVC': changes found
entities: +1 -0 ~2
relationships: +1 -0 ~0
added entities:
+ service ReportService [symbol:SampleMvcApplication|SampleMvcApplication.Services.ReportService]Il riuso è per fase, non per file: un file C# modificato rianalizza il codice e tutto ciò che segue. Lo dice il limite noto, e il report mostra «0 reused».
7. Database non raggiungibile
Applicazione registrata con --database-ref env:SIE_DEMO_DB che punta a un server inesistente:
$ si-engine scan --application sample-mvc-db
Scan sample-mvc-db-scan-001 of 'Sample MVC DB': completed_with_warnings - partial coverage (mode: full, 3482 ms)
knowledge: 100 entities, 247 relationships; warnings 1, errors 0
coverage: PARTIAL - analysed: aspnet, business rules, data access, discovery, source
NOT analysed - database: Database extraction failed (sql_error_10061): tables, columns,
constraints, procedures and database rules were not analysed.
warnings:
1 x [warning] database.extraction_failed - Database extraction failed (sql_error_10061);
the scan continues in source-only mode. Run 'database test' for details.
$ echo $?
0
$ si-engine database test --application sample-mvc-db
Connection FAILED (env:SIE_DEMO_DB)
$ echo $?
3La scansione prosegue e produce lo stesso modello del caso senza database. Il dettaglio dell'errore va nel log, senza la password. database test resta un errore (codice 3), perché lì la connessione è proprio ciò che si verifica. Una scansione degradata diventa quella attiva: rilanciala quando il database è di nuovo raggiungibile.