-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
729 lines (557 loc) · 13.6 KB
/
Copy pathapp.py
File metadata and controls
729 lines (557 loc) · 13.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
import streamlit as st
import sqlite3
import pandas as pd
# --------------------------------------------------
# PAGE CONFIG
# --------------------------------------------------
st.set_page_config(
page_title="EDI Labs",
page_icon="🧠",
layout="wide"
)
# --------------------------------------------------
# DATABASE
# --------------------------------------------------
from pathlib import Path
BASE_DIR = Path(__file__).parent
DB_PATH = BASE_DIR / "edis.db"
conn = sqlite3.connect(
DB_PATH,
check_same_thread=False
)
cursor = conn.cursor()
import os
backup_dir = BASE_DIR / "backups"
backup_dir.mkdir(
exist_ok=True
)
cursor.execute("""
CREATE TABLE IF NOT EXISTS learning_records (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT,
category TEXT,
impact TEXT,
confidence INTEGER,
owner TEXT,
situation TEXT,
decision TEXT,
assumptions TEXT,
expected_outcome TEXT,
actual_outcome TEXT,
success_rating TEXT,
learning TEXT,
evidence TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
""")
conn.commit()
try:
cursor.execute(
"ALTER TABLE learning_records ADD COLUMN success_rating TEXT"
)
conn.commit()
except:
pass
try:
cursor.execute(
"ALTER TABLE learning_records ADD COLUMN category TEXT"
)
conn.commit()
except:
pass
try:
cursor.execute(
"ALTER TABLE learning_records ADD COLUMN impact TEXT"
)
conn.commit()
except:
pass
try:
cursor.execute(
"ALTER TABLE learning_records ADD COLUMN confidence INTEGER"
)
conn.commit()
except:
pass
try:
cursor.execute(
"ALTER TABLE learning_records ADD COLUMN owner TEXT"
)
conn.commit()
except:
pass
# --------------------------------------------------
# FUNCTIONS
# --------------------------------------------------
def load_records():
return pd.read_sql_query(
"""
SELECT
id,
title,
category,
impact,
confidence,
owner,
situation,
decision,
assumptions,
expected_outcome,
actual_outcome,
success_rating,
learning,
evidence,
created_at
FROM learning_records
ORDER BY id DESC
""",
conn
)
def save_learning_record(
title,
category,
impact,
confidence,
owner,
situation,
decision,
assumptions,
expected_outcome,
evidence
):
cursor.execute(
"""
INSERT INTO learning_records (
title,
category,
impact,
confidence,
owner,
situation,
decision,
assumptions,
expected_outcome,
evidence
)
VALUES (?, ?, ?, ?, ?, ?,?, ?, ?, ?)
""",
(
title,
category,
impact,
confidence,
owner,
situation,
decision,
assumptions,
expected_outcome,
evidence
)
)
conn.commit()
def update_outcome(
record_id,
actual_outcome,
success_rating,
learning
):
cursor.execute(
"""
UPDATE learning_records
SET
actual_outcome = ?,
success_rating = ?,
learning = ?
WHERE id = ?
""",
(
actual_outcome,
success_rating,
learning,
record_id
)
)
conn.commit()
# --------------------------------------------------
# HEADER
# --------------------------------------------------
st.title("EDI Labs")
st.subheader(
"Enterprise Decision Infrastructure"
)
st.caption(
"Testing the hypothesis that autonomous enterprises will require systems of record for decisions, just as they require systems of record for customers, transactions, work, and data."
)
st.markdown("""
### Organizations have systems of record for:
• Customers (CRM)
• Transactions (ERP)
• Work (Project Systems)
• Data (Data Platforms)
# They do not have systems of record for decisions.
""")
st.info(
"""
Organizations can usually answer:
✓ What happened?
✓ Who did it?
✓ When did it happen?
Organizations often struggle to answer:
✕ Why was a decision made?
✕ Which assumptions drove it?
✕ Which assumptions proved wrong?
✕ What should future teams learn?
"""
)
st.markdown("---")
# --------------------------------------------------
# TABS
# --------------------------------------------------
# --------------------------------------------------
# EXECUTIVE DASHBOARD
# --------------------------------------------------
df = load_records()
total_decisions = len(df)
total_reviews = len(
df[df["actual_outcome"].notna()]
)
total_learnings = len(
df[df["learning"].notna()]
)
coverage = round(
(total_learnings / max(total_decisions, 1)) * 100
)
success_count = len(
df[
df["success_rating"].isin(
[
"Exceeded Expectations",
"Met Expectations"
]
)
]
)
success_rate = round(
success_count /
max(total_reviews, 1) * 100
)
col1, col2, col3, col4, col5 = st.columns(5)
with col1:
st.metric("Decisions", total_decisions)
with col2:
st.metric("Reality Checks", total_reviews)
with col3:
st.metric("Learnings", total_learnings)
with col4:
st.metric(
"Memory Coverage",
f"{coverage}%"
)
with col5:
st.metric(
"Success Rate",
f"{success_rate}%"
)
st.markdown("---")
tab1, tab2, tab3, tab4 = st.tabs(
[
"Decision Workspace",
"Decision Memory",
"Decision Analysis",
"Decision Intelligence"
]
)
# ==================================================
# TAB 1
# ==================================================
with tab1:
st.header("The Decision Record")
category = st.selectbox(
"Decision Category",
[
"Strategic Partnership",
"Enterprise AI",
"Vendor Selection",
"Technology Adoption",
"Product Launch",
"Capital Allocation",
"Hiring"
]
)
impact = st.selectbox(
"Business Impact",
[
"Low",
"Medium",
"High",
"Critical"
]
)
confidence = st.slider(
"Decision Confidence",
0,
100,
70
)
owner = st.text_input(
"Decision Owner",
placeholder="Strategy Team"
)
title = st.text_input(
"Decision Title",
placeholder="Enter decision title"
)
st.caption(
"""
Examples:
• Enterprise AI Transformation
• Strategic Partnership
• Vendor Selection
• Capital Allocation
• Product Launch
• Autonomous Agent Deployment
"""
)
situation = st.text_area(
"Context",
placeholder="""
Describe the business context, stakeholders, constraints, and factors influencing this decision.
"""
)
decision = st.text_area(
"Decision",
placeholder="""
Describe the decision being considered.
"""
)
assumptions = st.text_area(
"Assumptions",
placeholder="""
What assumptions must be true for this decision to succeed?
Examples:
- Market demand exists
- Adoption targets are realistic
- Required resources are available
- Regulatory conditions remain favorable
"""
)
expected_outcome = st.text_area(
"Expected Outcome",
placeholder="""
What outcome do you expect if these assumptions prove correct?
"""
)
evidence = st.text_area(
"Evidence",
placeholder="""
Links, research, decks, documents, supporting information.
"""
)
if st.button(
"Save Decision Record",
use_container_width=True
):
if (
title.strip() == ""
or situation.strip() == ""
or decision.strip() == ""
):
st.error(
"Decision Title, Context and Decision are required."
)
else:
save_learning_record(
title,
category,
impact,
confidence,
owner,
situation,
decision,
assumptions,
expected_outcome,
evidence
)
st.success(
"Decision Record Created"
)
st.rerun()
# ==================================================
# TAB 2
# ==================================================
with tab2:
st.header("Decision Repository")
df = load_records()
st.metric(
"Total Decision Records",
len(df)
)
display_cols = [
"id",
"title",
"owner",
"category",
"impact",
"confidence",
"success_rating",
"created_at"
]
available_cols = [
c for c in display_cols
if c in df.columns
]
st.dataframe(
df[available_cols],
use_container_width=True
)
csv = df.to_csv(index=False)
st.download_button(
"Export Decision Memory",
csv,
"decision_memory.csv",
"text/csv"
)
# ==================================================
# TAB 3
# ==================================================
with tab3:
st.header("Reality Check")
df = load_records()
if len(df) == 0:
st.info(
"No Decision Records available."
)
else:
record_id = st.selectbox(
"Select Decision Record",
df["id"].tolist()
)
selected = df[
df["id"] == record_id
].iloc[0]
st.subheader(selected["title"])
created_date = str(
selected["created_at"]
).split(" ")[0]
st.caption(
f"Created: {created_date}"
)
st.write("### Decision")
st.write(selected["decision"])
st.write("### Expected Outcome")
st.write(selected["expected_outcome"])
actual_outcome = st.text_area(
"Actual Outcome",
value=""
if pd.isna(selected["actual_outcome"])
else selected["actual_outcome"]
)
success_rating = st.selectbox(
"Outcome Rating",
[
"Exceeded Expectations",
"Met Expectations",
"Partially Successful",
"Failed"
]
)
learning = st.text_area(
"Learning",
value=""
if pd.isna(selected["learning"])
else selected["learning"]
)
if st.button(
"Save Reality Check",
use_container_width=True
):
update_outcome(
record_id,
actual_outcome,
success_rating,
learning
)
st.success(
"Decision Memory Updated"
)
# ==================================================
# TAB 4
# ==================================================
with tab4:
st.header("Ask EDI")
st.info(
"""
Future Decision Intelligence Layer
Examples:
• Why did similar decisions fail?
• Which assumptions repeatedly break?
• What have we learned about partnerships?
• What should future teams know?
• Which decisions created the most value?
This will become the retrieval layer for organizational decision memory.
"""
)
st.info(
"""
Future Enterprise Retrieval Layer
Examples:
• Should we deploy autonomous agents into production?
• Why did previous AI transformation initiatives fail?
• Which assumptions repeatedly break across strategic programs?
• What have we learned from high-risk enterprise decisions?
• Which decisions created durable organizational value?
This prototype demonstrates how organizational decision memory
can become queryable intelligence.
"""
)
question = st.text_input(
"Ask Decision Memory",
placeholder="Which assumptions repeatedly failed across strategic decisions?"
)
if question:
df = load_records()
if len(df) == 0:
st.warning(
"No Decision Records available."
)
else:
question_lower = question.lower()
matches = []
for _, row in df.iterrows():
text = " ".join(
[
str(row["title"]),
str(row["situation"]),
str(row["decision"]),
str(row["assumptions"]),
str(row["expected_outcome"]),
str(row["actual_outcome"]),
str(row["learning"])
]
).lower()
if any(
word in text
for word in question_lower.split()
):
matches.append(row)
if len(matches) == 0:
st.write(
"No matching decision records found."
)
else:
st.success(
f"Found {len(matches)} related records."
)
for row in matches:
with st.expander(
f"{row['id']} - {row['title']}"
):
st.write(
f"**Context:** {row['situation']}"
)
st.write(
f"**Decision:** {row['decision']}"
)
st.write(
f"**Learning:** {row['learning']}"
)